|
29 | 29 |
|
30 | 30 | directory = os.path.abspath(os.path.dirname(__file__))
|
31 | 31 | path = os.path.join(directory, "version.txt")
|
32 |
| -version_string = open(path).readline() |
| 32 | +with open(path) as f: |
| 33 | + version_string = f.readline() |
33 | 34 | match = re.match(r"\s*(?P<rel>(?P<ver>\d+\.\d+)(?:\.\S+)*)\s*", version_string)
|
34 | 35 | version = match.group("ver")
|
35 | 36 | release = match.group("rel")
|
36 | 37 |
|
| 38 | +#--------------------------------------------------------------------------- |
| 39 | +# Gather test requirements from the 'test_requirements.txt' file. |
| 40 | +# This is to allow installing test requirements with the following command: |
| 41 | +# pip install dragonfly[test]. |
| 42 | + |
| 43 | +def read(name): |
| 44 | + with open(os.path.join(os.path.dirname(__file__), name)) as f: |
| 45 | + return f.read() |
| 46 | + |
| 47 | +test_requirements = read("test_requirements.txt").split("\n")[:-1] |
| 48 | + |
37 | 49 | #---------------------------------------------------------------------------
|
38 | 50 | # Override the 'test' command to use pytest instead.
|
39 |
| -# Test requirements are located in the 'test_requirements.txt' file. |
40 | 51 |
|
41 | 52 | class test(Command):
|
42 | 53 | description = 'run unit tests and doctests after in-place build'
|
@@ -97,14 +108,9 @@ def _try_local_natlink_pyd(self):
|
97 | 108 | # module to sys.modules.
|
98 | 109 | if natlink: sys.modules["natlink"] = natlink
|
99 | 110 |
|
100 |
| - |
101 | 111 | #---------------------------------------------------------------------------
|
102 | 112 | # Set up package.
|
103 | 113 |
|
104 |
| -def read(*names): |
105 |
| - return open(os.path.join(os.path.dirname(__file__), *names)).read() |
106 |
| - |
107 |
| - |
108 | 114 | setup(
|
109 | 115 | name = "dragonfly",
|
110 | 116 | version = release,
|
@@ -140,10 +146,7 @@ def read(*names):
|
140 | 146 | ],
|
141 | 147 |
|
142 | 148 | extras_require={
|
143 |
| - "test": [ |
144 |
| - "pytest == 3.9.*;python_version<'3.8'", |
145 |
| - "pytest == 7.4.*;python_version>='3.8'", |
146 |
| - ], |
| 149 | + "test": test_requirements, |
147 | 150 | "accessibility": [
|
148 | 151 | "comtypes;platform_system=='Windows'",
|
149 | 152 | "enum34;python_version<'3.4'",
|
|
0 commit comments