Skip to content

Commit 067fbc1

Browse files
committed
Use setuptools_scm
1 parent 56b34e1 commit 067fbc1

File tree

2 files changed

+7
-39
lines changed

2 files changed

+7
-39
lines changed

pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[build-system]
2+
requires = ["setuptools>=45", "wheel", "setuptools_scm>=6.2,<8"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[tool.setuptools_scm]
6+
write_to = "robotpy/version.py"

setup.py

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,10 @@
11
#!/usr/bin/env python3
22

3-
import sys
4-
5-
if sys.version_info < (3, 7):
6-
sys.stderr.write("ERROR: RobotPy requires Python 3.7+\n")
7-
exit(1)
8-
9-
import subprocess
103
from setuptools import find_packages, setup
114
from pathlib import Path
125

136
setup_dir = Path(__file__).parent
14-
git_dir = setup_dir / ".git"
157
base_package = "robotpy"
16-
version_file = setup_dir / base_package / "version.py"
17-
18-
# Automatically generate a version.py based on the git version
19-
if git_dir.exists():
20-
p = subprocess.Popen(
21-
["git", "describe", "--tags", "--long", "--dirty=-dirty"],
22-
stdout=subprocess.PIPE,
23-
stderr=subprocess.PIPE,
24-
)
25-
out, err = p.communicate()
26-
# Make sure the git version has at least one tag
27-
if err:
28-
print("Error: You need to create a tag for this repo to use the builder")
29-
sys.exit(1)
30-
31-
# Convert git version to PEP440 compliant version
32-
# - Older versions of pip choke on local identifiers, so we can't include the git commit
33-
v, commits, local = out.decode("utf-8").rstrip().split("-", 2)
34-
if commits != "0" or "-dirty" in local:
35-
v = "%s.post0.dev%s" % (v, commits)
36-
37-
# Create the version.py file
38-
with open(version_file, "w") as fp:
39-
fp.write("# Autogenerated by setup.py\n__version__ = '{0}'".format(v))
40-
41-
if version_file.exists():
42-
with open(version_file, "r") as fp:
43-
exec(fp.read(), globals())
44-
else:
45-
__version__ = "master"
468

479

4810
def get_reqs_from_path(path):
@@ -72,7 +34,6 @@ def get_reqs_from_path(path):
7234

7335
setup(
7436
name="robotpy",
75-
version=__version__,
7637
description="Meta package to make installing robotpy easier",
7738
long_description=long_description,
7839
author="RobotPy Development Team",
@@ -98,4 +59,5 @@ def get_reqs_from_path(path):
9859
"Topic :: Software Development",
9960
"Topic :: Software Development :: Testing",
10061
],
62+
use_scm_version=True,
10163
)

0 commit comments

Comments
 (0)