From bd6c958f508b1d64142b62b08e9176cf9dfab1a7 Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Tue, 12 Jul 2022 16:24:54 +0100 Subject: [PATCH 1/2] Always use versioneer command classes in setup.py The GIT_DESCRIBE_TAG and VERSION_SUFFIX environment variables are used to control the name and version of the created conda/pypi package. They should, however, not be used to control the version of the installed package by overriding the versioneer cmdclass since that leaves an unmodified _version.py file in the installed package directory. A consequence is that the version reported by dask_cuda.__version__ is "0+unknown". To fix this, always use the versioneer-provided cmdclass. While we're here, bring the conda version string into line with the rest of the rapids ecosystem. --- conda/recipes/dask-cuda/meta.yaml | 7 ++----- setup.py | 11 ++--------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/conda/recipes/dask-cuda/meta.yaml b/conda/recipes/dask-cuda/meta.yaml index 088e7d570..9900d48b4 100644 --- a/conda/recipes/dask-cuda/meta.yaml +++ b/conda/recipes/dask-cuda/meta.yaml @@ -5,7 +5,6 @@ {% set data = load_setup_py_data() %} {% set version = environ.get('GIT_DESCRIBE_TAG', '0.0.0.dev').lstrip('v') + environ.get('VERSION_SUFFIX', '') %} -{% set git_revision_count=environ.get('GIT_DESCRIBE_NUMBER', 0) %} {% set py_version=environ.get('CONDA_PY', 36) %} package: name: dask-cuda @@ -15,10 +14,8 @@ source: git_url: ../../.. build: - number: {{ git_revision_count }} - string: py{{ py_version }}_{{ git_revision_count }} - script_env: - - VERSION_SUFFIX + number: {{ GIT_DESCRIBE_NUMBER }} + string: py{{ py_version }}_{{ GIT_DESCRIBE_HASH }}_{{ GIT_DESCRIBE_NUMBER }} requirements: host: diff --git a/setup.py b/setup.py index 976578953..23bb94413 100644 --- a/setup.py +++ b/setup.py @@ -9,17 +9,10 @@ with open(os.path.join(os.path.dirname(__file__), "README.md")) as f: long_description = f.read() -if "GIT_DESCRIBE_TAG" in os.environ: - version = os.environ["GIT_DESCRIBE_TAG"] + os.environ.get("VERSION_SUFFIX", "") - cmdclass = {} -else: - version = versioneer.get_version() - cmdclass = versioneer.get_cmdclass() - setup( name="dask-cuda", - version=version, - cmdclass=cmdclass, + version=versioneer.get_version(), + cmdclass=versioneer.get_cmdclass(), description="Utilities for Dask and CUDA interactions", long_description=long_description, long_description_content_type="text/markdown", From 221c883fd15898e2daeef5d262a207d0fe698ed8 Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Tue, 12 Jul 2022 17:27:51 +0100 Subject: [PATCH 2/2] Override versioneer.get_versions when GIT_DESCRIBE_TAG is defined Per PEP440, local version identifiers are disallowed for uploads to public index servers. In CI, when we build pypi packages, we override the versioneer-provided version with a PEP440-compatible version by defining GIT_DESCRIBE_TAG and VERSION_SUFFIX. These are glued together to produce a version which we then use to override the version produced by versioneer. This leaves us free to use the command classes provided by versioneer in all circumstances. Closes #336. --- setup.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/setup.py b/setup.py index 23bb94413..03511de32 100644 --- a/setup.py +++ b/setup.py @@ -9,6 +9,28 @@ with open(os.path.join(os.path.dirname(__file__), "README.md")) as f: long_description = f.read() +if "GIT_DESCRIBE_TAG" in os.environ: + # Disgusting hack. For pypi uploads we cannot use the + # versioneer-provided version for non-release builds, since they + # strictly follow PEP440 + # https://peps.python.org/pep-0440/#local-version-identifiers + # which disallows local version identifiers (as produced by + # versioneer) in public index servers. + # We still want to use versioneer infrastructure, so patch + # in our pypi-compatible version to the output of + # versioneer.get_versions. + + orig_get_versions = versioneer.get_versions + version = os.environ["GIT_DESCRIBE_TAG"] + os.environ.get("VERSION_SUFFIX", "") + + def get_versions(): + data = orig_get_versions() + data["version"] = version + return data + + versioneer.get_versions = get_versions + + setup( name="dask-cuda", version=versioneer.get_version(),