From c1a0a8511a6ffc4d34cfa68783b9ea98cf1e5ed8 Mon Sep 17 00:00:00 2001 From: mayeut Date: Sat, 8 May 2021 16:03:13 +0200 Subject: [PATCH 1/3] Add test_source_distribution --- tests/test_distribution.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/test_distribution.py b/tests/test_distribution.py index 773913771..7ef2da714 100644 --- a/tests/test_distribution.py +++ b/tests/test_distribution.py @@ -3,7 +3,7 @@ import pytest import textwrap -from path import Path +from path import Path, matchers DIST_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '../dist')) @@ -26,6 +26,21 @@ def _check_cmake_install(virtualenv, tmpdir): assert output[:len(expected)].lower() == expected.lower() +@pytest.mark.skipif(not Path(DIST_DIR).exists(), reason="dist directory does not exist") +def test_source_distribution(virtualenv, tmpdir): + sdists = Path(DIST_DIR).files(match=matchers.CaseInsensitive("*.tar.gz")) + if not sdists: + pytest.skip("no source distribution available") + assert len(sdists) == 1 + + if "SETUP_CMAKE_ARGS" in os.environ: + virtualenv.env["SKBUILD_CONFIGURE_OPTIONS"] = os.environ["SETUP_CMAKE_ARGS"] + virtualenv.run("pip install %s" % sdists[0]) + assert "cmake" in virtualenv.installed_packages() + + _check_cmake_install(virtualenv, tmpdir) + + @pytest.mark.skipif(not Path(DIST_DIR).exists(), reason="dist directory does not exist") def test_wheel(virtualenv, tmpdir): wheels = Path(DIST_DIR).files(match="*.whl") From b6c260e80efcaaaf576ded73c00632044fce311d Mon Sep 17 00:00:00 2001 From: mayeut Date: Sat, 8 May 2021 16:47:46 +0200 Subject: [PATCH 2/3] Fix versioneer import for sdist build in an isolated pip build --- setup.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 48c4f60a8..3c9a9db48 100755 --- a/setup.py +++ b/setup.py @@ -1,11 +1,17 @@ #!/usr/bin/env python +import os import sys -import versioneer from distutils.text_file import TextFile from skbuild import setup +# Add current folder to path +# This is required to import versioneer in an isolated pip build +sys.path.append(os.path.dirname(os.path.abspath(__file__))) + +import versioneer # noqa: E402 + with open('README.rst', 'r') as fp: readme = fp.read() From c5500a5c9096cd612cfd124c5ee1f8e15d94ca01 Mon Sep 17 00:00:00 2001 From: mayeut Date: Sat, 8 May 2021 21:45:35 +0200 Subject: [PATCH 3/3] Fix version returned by versioneer when "post" is already in an existing tag --- versioneer.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/versioneer.py b/versioneer.py index f250cde55..1e28dbff5 100644 --- a/versioneer.py +++ b/versioneer.py @@ -1283,7 +1283,22 @@ def render_pep440_post(pieces): if pieces["closest-tag"]: rendered = pieces["closest-tag"] if pieces["distance"] or pieces["dirty"]: - rendered += ".post%d" % pieces["distance"] + if ".post" in rendered: + # update the existing post tag + start = rendered.index(".post") + 5 + if len(rendered) == start: + rendered += "%d" % pieces["distance"] + else: + end = start + 1 + while end <= len(rendered) and rendered[start:end].isdigit(): + end += 1 + end -= 1 + distance = pieces["distance"] + if start != end: + distance += int(rendered[start:end]) + rendered = rendered[:start] + "%d" % distance + rendered[end:] + else: + rendered += ".post%d" % pieces["distance"] if pieces["dirty"]: rendered += ".dev0" rendered += plus_or_dot(pieces)