Skip to content

Commit 29b99d5

Browse files
committed
Simplify setup.py
1 parent de4b34c commit 29b99d5

File tree

2 files changed

+4
-31
lines changed

2 files changed

+4
-31
lines changed

examples/simple-extension/setup.py

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,9 @@
11
import sys
22
from setuptools import find_packages, setup
3-
from setuptools.command.test import test as TestCommand
43
from setuptools_rust import RustExtension
54

65

7-
class PyTest(TestCommand):
8-
user_options = []
9-
10-
def run(self):
11-
self.run_command("test_rust")
12-
import subprocess
13-
errno = subprocess.call(['pytest', 'tests'])
14-
raise SystemExit(errno)
15-
16-
17-
def get_cfg_flags():
18-
version = sys.version_info[0:2]
19-
if version[0] == 2:
20-
return ['--cfg=Py_2']
21-
else:
22-
return ['--cfg=Py_3']
23-
24-
25-
def get_features():
26-
version = sys.version_info[0:2]
27-
if version[0] == 2:
28-
return ['numpy/python2']
29-
else:
30-
return ['numpy/python3']
31-
6+
PYTHON_MAJOR_VERSION = sys.version_info[0]
327

338
setup_requires = ['setuptools-rust>=0.6.0']
349
install_requires = ['numpy']
@@ -41,13 +16,12 @@ def get_features():
4116
rust_extensions=[RustExtension(
4217
'rust_ext.rust_ext',
4318
'./Cargo.toml',
44-
rustc_flags=get_cfg_flags(),
45-
features=get_features(),
19+
rustc_flags=['--cfg=Py_{}'.format(PYTHON_MAJOR_VERSION)],
20+
features=['numpy/python{}'.format(PYTHON_MAJOR_VERSION)],
4621
)],
4722
install_requires=install_requires,
4823
setup_requires=setup_requires,
4924
test_requires=test_requires,
5025
packages=find_packages(),
5126
zip_safe=False,
52-
cmdclass=dict(test=PyTest)
5327
)

examples/simple-extension/tox.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@ skip_missing_interpreters = true
1010
description = Run the unit tests under {basepython}
1111
deps = -rrequirements-dev.txt
1212
usedevelop = True
13-
commands = pip install -e .
14-
pytest
13+
commands = pytest

0 commit comments

Comments
 (0)