From 5b33517acc33aca42421f80934f8f9a572b41265 Mon Sep 17 00:00:00 2001 From: Luiz Irber Date: Sat, 15 Dec 2018 17:28:31 +0000 Subject: [PATCH] [MRG] use setuptools_scm for version management (#471) * Use setuptools_scm for versioning - add setuptools_scm_git_archive support - update release docs * update setuptools_scm * fix variable name --- .git_archival.txt | 1 + .gitattributes | 1 + .gitignore | 5 +++++ Makefile | 3 +++ doc/release.md | 4 ++-- setup.py | 10 +++------- sourmash/VERSION | 1 - sourmash/__init__.py | 16 ++++++++++++---- 8 files changed, 27 insertions(+), 14 deletions(-) create mode 100644 .git_archival.txt create mode 100644 .gitattributes delete mode 100644 sourmash/VERSION diff --git a/.git_archival.txt b/.git_archival.txt new file mode 100644 index 000000000..95cb3eea4 --- /dev/null +++ b/.git_archival.txt @@ -0,0 +1 @@ +ref-names: $Format:%D$ diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..00a7b00c9 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +.git_archival.txt export-subst diff --git a/.gitignore b/.gitignore index 1193490cf..b763147ae 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,8 @@ _minhash.so .coverage sourmash_lib/_minhash.cpp sourmash/_minhash.cpp +.asv/ +.eggs/ +.pytest_cache +.python-version +sourmash/version.py diff --git a/Makefile b/Makefile index 6ffaf819a..c51b7ffcd 100644 --- a/Makefile +++ b/Makefile @@ -35,4 +35,7 @@ wheel: docker pull $${DOCKER_IMAGE} ; \ docker run --rm -v `pwd`:/io $${DOCKER_IMAGE} /io/travis/build-wheels.sh +last-tag: + git fetch -p -q; git tag -l | sort -V | tail -1 + FORCE: diff --git a/doc/release.md b/doc/release.md index 4710fdb15..924e72c06 100644 --- a/doc/release.md +++ b/doc/release.md @@ -27,7 +27,7 @@ cd sourmash and then tag the release candidate with the new version number prefixed by the letter 'v': ``` - git tag v${new_version}-${rc} + git tag -a v${new_version}-${rc} git push --tags git@github.com:dib-lab/sourmash.git ``` 3\. Test the release candidate. Bonus: repeat on Mac OS X: @@ -116,7 +116,7 @@ so: authorized account): ``` cd ../sourmash - git tag v${new_version} + git tag -a v${new_version} python setup.py register sdist upload ``` 2\. Delete the release candidate tag and push the tag updates to GitHub: diff --git a/setup.py b/setup.py index 085824e8d..40073807c 100644 --- a/setup.py +++ b/setup.py @@ -4,11 +4,6 @@ from setuptools import Extension import os -# retrieve VERSION from sourmash/VERSION. -thisdir = os.path.dirname(__file__) -version_file = open(os.path.join(thisdir, 'sourmash', 'VERSION')) -VERSION = version_file.read().strip() - EXTRA_COMPILE_ARGS = ['-std=c++11', '-pedantic'] EXTRA_LINK_ARGS=[] @@ -48,7 +43,6 @@ SETUP_METADATA = \ { "name": "sourmash", - "version": VERSION, "description": "tools for comparing DNA sequences with MinHash sketches", "long_description": LONG_DESCRIPTION, "long_description_content_type": "text/markdown", @@ -71,7 +65,9 @@ extra_compile_args=EXTRA_COMPILE_ARGS, extra_link_args=EXTRA_LINK_ARGS)], "install_requires": ["screed>=0.9", "ijson", "khmer>=2.1"], - "setup_requires": ['Cython>=0.25.2', "setuptools>=38.6.0"], + "setup_requires": ['Cython>=0.25.2', "setuptools>=38.6.0", + 'setuptools_scm', 'setuptools_scm_git_archive'], + "use_scm_version": {"write_to": "sourmash/version.py"}, "extras_require": { 'test' : ['pytest', 'pytest-cov', 'numpy', 'matplotlib', 'scipy','recommonmark'], 'demo' : ['jupyter', 'jupyter_client', 'ipython'], diff --git a/sourmash/VERSION b/sourmash/VERSION deleted file mode 100644 index 7385c4c8b..000000000 --- a/sourmash/VERSION +++ /dev/null @@ -1 +0,0 @@ -2.0.0a10 diff --git a/sourmash/__init__.py b/sourmash/__init__.py index 6a0403a66..2893023d2 100644 --- a/sourmash/__init__.py +++ b/sourmash/__init__.py @@ -20,7 +20,15 @@ from . import sbt_storage from . import signature -# retrieve VERSION from sourmash/VERSION. -thisdir = os.path.dirname(__file__) -version_file = open(os.path.join(thisdir, 'VERSION')) -VERSION = version_file.read().strip() +from pkg_resources import get_distribution, DistributionNotFound +try: + VERSION = get_distribution(__name__).version +except DistributionNotFound: # pragma: no cover + try: + from .version import version as VERSION # noqa + except ImportError: # pragma: no cover + raise ImportError( + "Failed to find (autogenerated) version.py. " + "This might be because you are installing from GitHub's tarballs, " + "use the PyPI ones." + )