1
1
#!/usr/bin/env python3
2
2
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
10
3
from setuptools import find_packages , setup
11
4
from pathlib import Path
12
5
13
6
setup_dir = Path (__file__ ).parent
14
- git_dir = setup_dir / ".git"
15
7
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"
46
8
47
9
48
10
def get_reqs_from_path (path ):
@@ -72,7 +34,6 @@ def get_reqs_from_path(path):
72
34
73
35
setup (
74
36
name = "robotpy" ,
75
- version = __version__ ,
76
37
description = "Meta package to make installing robotpy easier" ,
77
38
long_description = long_description ,
78
39
author = "RobotPy Development Team" ,
@@ -98,4 +59,5 @@ def get_reqs_from_path(path):
98
59
"Topic :: Software Development" ,
99
60
"Topic :: Software Development :: Testing" ,
100
61
],
62
+ use_scm_version = True ,
101
63
)
0 commit comments