Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down
17 changes: 16 additions & 1 deletion tests/test_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'))

Expand All @@ -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")
Expand Down
17 changes: 16 additions & 1 deletion versioneer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down