From 45c8ee20479e79861c6eed8f34d8d0cb7a446933 Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Wed, 7 Dec 2022 22:52:41 +0000 Subject: [PATCH 1/3] Remove `__about__` file in favour of keeping constants in `__init__` This makes it possible for flit to auto-discover the version from this file. --- .github/workflows/lint.yml | 2 +- docs/conf.py | 2 +- noxfile.py | 2 +- packaging/__about__.py | 26 -------------------------- packaging/__init__.py | 30 ++++++++++-------------------- 5 files changed, 13 insertions(+), 49 deletions(-) delete mode 100644 packaging/__about__.py diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index df4390a0..712704c1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -39,7 +39,7 @@ jobs: # Linting verifies that the project is in an acceptable state to create files # for releasing. # And this action should be run whenever a release is ready to go public as - # the version number will be changed by editing __about__.py. + # the version number will be changed by editing __init__.py. needs: lint steps: diff --git a/docs/conf.py b/docs/conf.py index c2fffd40..202dd49b 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -8,7 +8,7 @@ ABOUT = {} _BASE_DIR = os.path.join(os.path.dirname(__file__), os.pardir) -with open(os.path.join(_BASE_DIR, "packaging", "__about__.py")) as f: +with open(os.path.join(_BASE_DIR, "packaging", "__init__.py")) as f: exec(f.read(), ABOUT) # -- General configuration ---------------------------------------------------- diff --git a/noxfile.py b/noxfile.py index 1636d7d0..ecf89fb2 100644 --- a/noxfile.py +++ b/noxfile.py @@ -95,7 +95,7 @@ def docs(session): @nox.session def release(session): package_name = "packaging" - version_file = Path(f"{package_name}/__about__.py") + version_file = Path(f"{package_name}/__init__.py") changelog_file = Path("CHANGELOG.rst") try: diff --git a/packaging/__about__.py b/packaging/__about__.py deleted file mode 100644 index 78b54d8c..00000000 --- a/packaging/__about__.py +++ /dev/null @@ -1,26 +0,0 @@ -# This file is dual licensed under the terms of the Apache License, Version -# 2.0, and the BSD License. See the LICENSE file in the root of this repository -# for complete details. - -__all__ = [ - "__title__", - "__summary__", - "__uri__", - "__version__", - "__author__", - "__email__", - "__license__", - "__copyright__", -] - -__title__ = "packaging" -__summary__ = "Core utilities for Python packages" -__uri__ = "https://github.com/pypa/packaging" - -__version__ = "22.1.dev0" - -__author__ = "Donald Stufft and individual contributors" -__email__ = "donald@stufft.io" - -__license__ = "BSD-2-Clause or Apache-2.0" -__copyright__ = "2014-2019 %s" % __author__ diff --git a/packaging/__init__.py b/packaging/__init__.py index 3c50c5dc..5c312928 100644 --- a/packaging/__init__.py +++ b/packaging/__init__.py @@ -2,24 +2,14 @@ # 2.0, and the BSD License. See the LICENSE file in the root of this repository # for complete details. -from .__about__ import ( - __author__, - __copyright__, - __email__, - __license__, - __summary__, - __title__, - __uri__, - __version__, -) +__title__ = "packaging" +__summary__ = "Core utilities for Python packages" +__uri__ = "https://github.com/pypa/packaging" -__all__ = [ - "__title__", - "__summary__", - "__uri__", - "__version__", - "__author__", - "__email__", - "__license__", - "__copyright__", -] +__version__ = "22.1.dev0" + +__author__ = "Donald Stufft and individual contributors" +__email__ = "donald@stufft.io" + +__license__ = "BSD-2-Clause or Apache-2.0" +__copyright__ = "2014-2019 %s" % __author__ From f0bbac4993e5c9ca14ad38befb676de49faedafd Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Wed, 7 Dec 2022 23:05:54 +0000 Subject: [PATCH 2/3] Move to src/ layout This ensures that tests are executed against the installed copy, rather than the in-tree copy. --- docs/conf.py | 2 +- noxfile.py | 4 ++-- {packaging => src/packaging}/__init__.py | 0 {packaging => src/packaging}/_elffile.py | 0 {packaging => src/packaging}/_manylinux.py | 0 {packaging => src/packaging}/_musllinux.py | 0 {packaging => src/packaging}/_parser.py | 0 {packaging => src/packaging}/_structures.py | 0 {packaging => src/packaging}/_tokenizer.py | 0 {packaging => src/packaging}/markers.py | 0 {packaging => src/packaging}/py.typed | 0 {packaging => src/packaging}/requirements.py | 0 {packaging => src/packaging}/specifiers.py | 0 {packaging => src/packaging}/tags.py | 0 {packaging => src/packaging}/utils.py | 0 {packaging => src/packaging}/version.py | 0 16 files changed, 3 insertions(+), 3 deletions(-) rename {packaging => src/packaging}/__init__.py (100%) rename {packaging => src/packaging}/_elffile.py (100%) rename {packaging => src/packaging}/_manylinux.py (100%) rename {packaging => src/packaging}/_musllinux.py (100%) rename {packaging => src/packaging}/_parser.py (100%) rename {packaging => src/packaging}/_structures.py (100%) rename {packaging => src/packaging}/_tokenizer.py (100%) rename {packaging => src/packaging}/markers.py (100%) rename {packaging => src/packaging}/py.typed (100%) rename {packaging => src/packaging}/requirements.py (100%) rename {packaging => src/packaging}/specifiers.py (100%) rename {packaging => src/packaging}/tags.py (100%) rename {packaging => src/packaging}/utils.py (100%) rename {packaging => src/packaging}/version.py (100%) diff --git a/docs/conf.py b/docs/conf.py index 202dd49b..d89b26aa 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -8,7 +8,7 @@ ABOUT = {} _BASE_DIR = os.path.join(os.path.dirname(__file__), os.pardir) -with open(os.path.join(_BASE_DIR, "packaging", "__init__.py")) as f: +with open(os.path.join(_BASE_DIR, "src", "packaging", "__init__.py")) as f: exec(f.read(), ABOUT) # -- General configuration ---------------------------------------------------- diff --git a/noxfile.py b/noxfile.py index ecf89fb2..6c480595 100644 --- a/noxfile.py +++ b/noxfile.py @@ -35,7 +35,7 @@ def coverage(*args): coverage( "run", "--source", - "packaging/", + "packaging", "-m", "pytest", "--strict-markers", @@ -95,7 +95,7 @@ def docs(session): @nox.session def release(session): package_name = "packaging" - version_file = Path(f"{package_name}/__init__.py") + version_file = Path(f"src/{package_name}/__init__.py") changelog_file = Path("CHANGELOG.rst") try: diff --git a/packaging/__init__.py b/src/packaging/__init__.py similarity index 100% rename from packaging/__init__.py rename to src/packaging/__init__.py diff --git a/packaging/_elffile.py b/src/packaging/_elffile.py similarity index 100% rename from packaging/_elffile.py rename to src/packaging/_elffile.py diff --git a/packaging/_manylinux.py b/src/packaging/_manylinux.py similarity index 100% rename from packaging/_manylinux.py rename to src/packaging/_manylinux.py diff --git a/packaging/_musllinux.py b/src/packaging/_musllinux.py similarity index 100% rename from packaging/_musllinux.py rename to src/packaging/_musllinux.py diff --git a/packaging/_parser.py b/src/packaging/_parser.py similarity index 100% rename from packaging/_parser.py rename to src/packaging/_parser.py diff --git a/packaging/_structures.py b/src/packaging/_structures.py similarity index 100% rename from packaging/_structures.py rename to src/packaging/_structures.py diff --git a/packaging/_tokenizer.py b/src/packaging/_tokenizer.py similarity index 100% rename from packaging/_tokenizer.py rename to src/packaging/_tokenizer.py diff --git a/packaging/markers.py b/src/packaging/markers.py similarity index 100% rename from packaging/markers.py rename to src/packaging/markers.py diff --git a/packaging/py.typed b/src/packaging/py.typed similarity index 100% rename from packaging/py.typed rename to src/packaging/py.typed diff --git a/packaging/requirements.py b/src/packaging/requirements.py similarity index 100% rename from packaging/requirements.py rename to src/packaging/requirements.py diff --git a/packaging/specifiers.py b/src/packaging/specifiers.py similarity index 100% rename from packaging/specifiers.py rename to src/packaging/specifiers.py diff --git a/packaging/tags.py b/src/packaging/tags.py similarity index 100% rename from packaging/tags.py rename to src/packaging/tags.py diff --git a/packaging/utils.py b/src/packaging/utils.py similarity index 100% rename from packaging/utils.py rename to src/packaging/utils.py diff --git a/packaging/version.py b/src/packaging/version.py similarity index 100% rename from packaging/version.py rename to src/packaging/version.py From 72f7e3e08e9a6fd6a21e80a008c06b596e308a91 Mon Sep 17 00:00:00 2001 From: Pradyun Gedam Date: Wed, 7 Dec 2022 23:06:45 +0000 Subject: [PATCH 3/3] Let Flit dynamically determine the package version This makes it possible to single-source the package version. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index b8d40174..9a145424 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "flit_core.buildapi" [project] name = "packaging" description = "Core utilities for Python packages" -version = "22.0" +dynamic = ["version"] readme = "README.rst" requires-python = ">=3.7" authors = [{name = "Donald Stufft", email = "donald@stufft.io"}]