File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#!/usr/bin/env python
22
3+ import os
34import sys
4- import versioneer
55
66from distutils .text_file import TextFile
77from skbuild import setup
88
9+ # Add current folder to path
10+ # This is required to import versioneer in an isolated pip build
11+ sys .path .append (os .path .dirname (os .path .abspath (__file__ )))
12+
13+ import versioneer # noqa: E402
14+
915
1016with open ('README.rst' , 'r' ) as fp :
1117 readme = fp .read ()
Original file line number Diff line number Diff line change 33import pytest
44import textwrap
55
6- from path import Path
6+ from path import Path , matchers
77
88DIST_DIR = os .path .abspath (os .path .join (os .path .dirname (__file__ ), '../dist' ))
99
@@ -26,6 +26,21 @@ def _check_cmake_install(virtualenv, tmpdir):
2626 assert output [:len (expected )].lower () == expected .lower ()
2727
2828
29+ @pytest .mark .skipif (not Path (DIST_DIR ).exists (), reason = "dist directory does not exist" )
30+ def test_source_distribution (virtualenv , tmpdir ):
31+ sdists = Path (DIST_DIR ).files (match = matchers .CaseInsensitive ("*.tar.gz" ))
32+ if not sdists :
33+ pytest .skip ("no source distribution available" )
34+ assert len (sdists ) == 1
35+
36+ if "SETUP_CMAKE_ARGS" in os .environ :
37+ virtualenv .env ["SKBUILD_CONFIGURE_OPTIONS" ] = os .environ ["SETUP_CMAKE_ARGS" ]
38+ virtualenv .run ("pip install %s" % sdists [0 ])
39+ assert "cmake" in virtualenv .installed_packages ()
40+
41+ _check_cmake_install (virtualenv , tmpdir )
42+
43+
2944@pytest .mark .skipif (not Path (DIST_DIR ).exists (), reason = "dist directory does not exist" )
3045def test_wheel (virtualenv , tmpdir ):
3146 wheels = Path (DIST_DIR ).files (match = "*.whl" )
Original file line number Diff line number Diff line change @@ -1283,7 +1283,22 @@ def render_pep440_post(pieces):
12831283 if pieces ["closest-tag" ]:
12841284 rendered = pieces ["closest-tag" ]
12851285 if pieces ["distance" ] or pieces ["dirty" ]:
1286- rendered += ".post%d" % pieces ["distance" ]
1286+ if ".post" in rendered :
1287+ # update the existing post tag
1288+ start = rendered .index (".post" ) + 5
1289+ if len (rendered ) == start :
1290+ rendered += "%d" % pieces ["distance" ]
1291+ else :
1292+ end = start + 1
1293+ while end <= len (rendered ) and rendered [start :end ].isdigit ():
1294+ end += 1
1295+ end -= 1
1296+ distance = pieces ["distance" ]
1297+ if start != end :
1298+ distance += int (rendered [start :end ])
1299+ rendered = rendered [:start ] + "%d" % distance + rendered [end :]
1300+ else :
1301+ rendered += ".post%d" % pieces ["distance" ]
12871302 if pieces ["dirty" ]:
12881303 rendered += ".dev0"
12891304 rendered += plus_or_dot (pieces )
You can’t perform that action at this time.
0 commit comments