Skip to content

Commit 5c80c40

Browse files
committed
Move to setuptools_scm for version output.
1 parent 0ca79f6 commit 5c80c40

File tree

4 files changed

+31
-171
lines changed

4 files changed

+31
-171
lines changed

pyproject.toml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
11
[build-system]
2-
requires = ["setuptools", "wheel", "cython"]
2+
requires = [
3+
"cython",
4+
"setuptools>=42",
5+
"setuptools_scm[toml]>=3.4",
6+
"wheel",
7+
]
8+
9+
[tool.setuptools_scm]
10+
version_scheme = "post-release"
11+
write_to = "fasm/version.py"
12+
tag_regex = "v[0-9.]+"

setup.cfg

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
[metadata]
22
license_files = LICENSE
33

4-
[bdist_wheel]
5-
universal=1
4+
[options]
5+
setup_requires =
6+
wheel
7+
setuptools
8+
setuptools_scm

setup.py

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,18 @@
3232
long_description = fh.read()
3333

3434

35-
# Read in the version information
36-
FASM_VERSION_FILE = os.path.join(__dir__, 'fasm', 'version.py')
37-
with open(FASM_VERSION_FILE) as f:
38-
if 'UNKNOWN' in f.read():
39-
print(
40-
"Running update_version.py to generate {}".format(
41-
FASM_VERSION_FILE))
42-
subprocess.check_call(['python', 'update_version.py'], cwd=__dir__)
43-
with open(FASM_VERSION_FILE) as f:
44-
lines = f.readlines()
45-
version_line = [v.strip() for v in lines if v.startswith('version_str')]
46-
assert len(version_line) == 1, version_line
47-
version_value = version_line[0].split(' = ', 1)[-1]
48-
assert version_value[0] == '"', version_value
49-
assert version_value[-1] == '"', version_value
50-
version = version_value[1:-1]
35+
# Generate the version number
36+
def scm_version():
37+
def local_scheme(version):
38+
if version.tag and not version.distance:
39+
return version.format_with("")
40+
else:
41+
return version.format_choice("+{node}", "+{node}.dirty")
42+
return {
43+
"relative_to": __file__,
44+
"version_scheme": "guess-next-dev",
45+
"local_scheme": local_scheme
46+
}
5147

5248

5349
# Based on: https://www.benjack.io/2018/02/02/python-cpp-revisited.html
@@ -256,7 +252,7 @@ def run(self):
256252
setuptools.setup(
257253
# Package human readable information
258254
name="fasm",
259-
version=version,
255+
use_scm_version=scm_version(),
260256
author="SymbiFlow Authors",
261257
author_email="symbiflow@lists.librecores.org",
262258
description="FPGA Assembly (FASM) Parser and Generation library",
@@ -280,8 +276,10 @@ def run(self):
280276
setup_requires=[
281277
"wheel",
282278
"setuptools",
279+
"setuptools_scm",
283280
],
284281
install_requires=[
282+
"importlib_metadata; python_version<'3.8'", # for __version__
285283
'textx',
286284
],
287285
# C extension building

update_version.py

Lines changed: 0 additions & 151 deletions
This file was deleted.

0 commit comments

Comments
 (0)