From f9808b55ab59e0b3acfd9fc238e6aa3a8825c5bc Mon Sep 17 00:00:00 2001 From: toofar Date: Sat, 3 May 2025 16:29:31 +1200 Subject: [PATCH] Make description attribute static Hmm, seems the description can't be read from an attribute, why? Anyway, it's not like it changes often. Lets copy it, and add a note to change the python code to read from importlib.metadata, if we even want to? TODO: * compare the output file-by-file of pip install -e before and after * compare the output file-by-file of setup.py install/build/wheel or whatever and the corresponding build commands (and update makefile) * think about removing stuff that isn't used from `__init__.py`, or making it read from importlib.metadata * see how it looks with hatch (dynamic bits and build hooks) --- pyproject.toml | 8 +++++--- qutebrowser/qutebrowser.py | 1 + setup.py | 3 ++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d59e19979..0a69587a9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,6 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "qutebrowser" +description = "A keyboard-driven, vim-like browser based on Python and Qt." # What about the other libs in requirements.txt? dependencies = [ "jinja2", @@ -41,7 +42,6 @@ classifiers = [ # https://discuss.python.org/t/please-make-package-version-go-away/58501/11 dynamic = [ "version", - "description", ] [project.urls] @@ -57,8 +57,10 @@ funding = "https://github.com/qutebrowser/qutebrowser/blob/main/README.asciidoc# qutebrowser = "qutebrowser.qutebrowser:main" [tool.setuptools.dynamic] -version = {attr = "qutebrowser.__version__"} -description = {attr = "qutebrowser.__description__"} +# We can't import a variable from qutebrowser/__init__.py because when we put +# "qutebrowser" here setuptools resolves that to "qutebrowser/qutebrowser.py". +# So just import the attribute from that qutebrowser.py file. +version = {attr = "qutebrowser.qutebrowser.__version__"} [tool.setuptools.packages.find] include = ["qutebrowser", "qutebrowser.*"] # package names should match these glob patterns (["*"] by default) diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py index 044a6cceb..85a5e2180 100644 --- a/qutebrowser/qutebrowser.py +++ b/qutebrowser/qutebrowser.py @@ -23,6 +23,7 @@ import sys import json import qutebrowser +from qutebrowser import __version__ try: from qutebrowser.misc.checkpyver import check_python_version except ImportError: diff --git a/setup.py b/setup.py index 3715acb74..fbc748cb2 100755 --- a/setup.py +++ b/setup.py @@ -40,7 +40,7 @@ import setuptools # * version=_get_constant('version'), # * dynamic in setuptools # * description=_get_constant('description'), -# * dynamic option in setuptools +# * support reading from file, but not attribute # * author=_get_constant('author'), # * author_email=_get_constant('email'), # * both not dynamic and don't change much, duplicate or move @@ -48,6 +48,7 @@ import setuptools # * not dynamic, it's also not used anywhere else and doesn't change often # * just duplicate it and leave a comment or move it completely # +# Move duplicated stuff in __init__ to use importlib.metadata? # Args to setup() # https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html#setuptools-specific-configuration