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)
This commit is contained in:
toofar 2025-05-03 16:29:31 +12:00
parent f72ce65e8e
commit f9808b55ab
3 changed files with 8 additions and 4 deletions

View File

@ -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)

View File

@ -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:

View File

@ -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