Skip to content

Commit eb17d6f

Browse files
authored
update to miniver 0.7.0 (#290)
1 parent 366ffa0 commit eb17d6f

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

adaptive/_version.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import os
44
import subprocess
55
from collections import namedtuple
6-
from distutils.command.build_py import build_py as build_py_orig
76

7+
from setuptools.command.build_py import build_py as build_py_orig
88
from setuptools.command.sdist import sdist as sdist_orig
99

1010
Version = namedtuple("Version", ("release", "dev", "labels"))
@@ -15,6 +15,13 @@
1515
package_root = os.path.dirname(os.path.realpath(__file__))
1616
package_name = os.path.basename(package_root)
1717
distr_root = os.path.dirname(package_root)
18+
# If the package is inside a "src" directory the
19+
# distribution root is 1 level up.
20+
if os.path.split(distr_root)[1] == "src":
21+
_package_root_inside_src = True
22+
distr_root = os.path.dirname(distr_root)
23+
else:
24+
_package_root_inside_src = False
1825

1926
STATIC_VERSION_FILE = "_static_version.py"
2027

@@ -189,7 +196,11 @@ def run(self):
189196
class _sdist(sdist_orig):
190197
def make_release_tree(self, base_dir, files):
191198
super().make_release_tree(base_dir, files)
192-
_write_version(os.path.join(base_dir, package_name, STATIC_VERSION_FILE))
199+
if _package_root_inside_src:
200+
p = os.path.join("src", package_name)
201+
else:
202+
p = package_name
203+
_write_version(os.path.join(base_dir, p, STATIC_VERSION_FILE))
193204

194205

195206
cmdclass = dict(sdist=_sdist, build_py=_build_py)

0 commit comments

Comments
 (0)