Fix how the test rustapi_module is built

This commit is contained in:
Paul Ganssle 2018-08-08 09:31:41 -04:00
parent cca8eb43d6
commit 149a13cbfa
No known key found for this signature in database
GPG key ID: CD54FCE3D964BEFB
4 changed files with 34 additions and 13 deletions

View file

@ -0,0 +1,2 @@
[build-system]
requires = ["setuptools", "wheel", "setuptools_rust>=0.10.2"]

View file

@ -1,3 +1,3 @@
hypothesis>=3.55
pytest>=3.5.0
setuptools-rust>=0.9.1
setuptools-rust>=0.10.2

View file

@ -2,17 +2,7 @@ import sys
from setuptools import setup
from setuptools.command.test import test as TestCommand
try:
from setuptools_rust import RustExtension
except ImportError:
import subprocess
errno = subprocess.call([sys.executable, '-m', 'pip', 'install', 'setuptools-rust'])
if errno:
print("Please install setuptools-rust package")
raise SystemExit(errno)
else:
from setuptools_rust import RustExtension
from setuptools_rust import RustExtension
class PyTest(TestCommand):
@ -26,6 +16,20 @@ class PyTest(TestCommand):
raise SystemExit(errno)
def get_py_version_cfgs():
# For now each Cfg Py_3_X flag is interpreted as "at least 3.X"
version = sys.version_info[0:2]
if version[0] == 2:
return ['--cfg=Py_2']
py3_min = 5
out_cfg = []
for minor in range(py3_min, version[1]+1):
out_cfg.append('--cfg=Py_3_%d' % minor)
return out_cfg
setup_requires = ['setuptools-rust>=0.6.1']
install_requires = []
tests_require = install_requires + ['pytest', 'pytest-benchmark']
@ -43,7 +47,8 @@ setup(
'Operating System :: MacOS :: MacOS X',
],
packages=['rustapi_module'],
rust_extensions=[RustExtension('rustapi_module.datetime', 'Cargo.toml')],
rust_extensions=[RustExtension('rustapi_module.datetime', 'Cargo.toml',
rustc_flags=get_py_version_cfgs())],
install_requires=install_requires,
tests_require=tests_require,
setup_requires=setup_requires,

View file

@ -0,0 +1,14 @@
[tox]
envlist = py27,
py35,
py36,
py37,
minversion = 2.9.0
skip_missing_interpreters = true
[testenv]
description = Run the unit tests under {basepython}
deps = -rrequirements-dev.txt
usedevelop = True
commands = pip install -e .
pytest