Compile examples in debug mode

This commit is contained in:
konstin 2019-09-05 13:13:06 +02:00
parent a4c9fb96a3
commit 94f6248d87
2 changed files with 18 additions and 26 deletions

View File

@ -38,20 +38,21 @@ class CargoModifiedSdist(SdistCommand):
super().make_release_tree(base_dir, files) super().make_release_tree(base_dir, files)
import toml import toml
# Cargo.toml is now staged and ready to be modified # Cargo.toml is now staged and ready to be modified
cargo_loc = os.path.join(base_dir, 'Cargo.toml') cargo_loc = os.path.join(base_dir, "Cargo.toml")
assert os.path.exists(cargo_loc) assert os.path.exists(cargo_loc)
with open(cargo_loc, 'r') as f: with open(cargo_loc, "r") as f:
cargo_toml = toml.load(f) cargo_toml = toml.load(f)
rel_pyo3_path = cargo_toml['dependencies']['pyo3']['path'] rel_pyo3_path = cargo_toml["dependencies"]["pyo3"]["path"]
base_path = os.path.dirname(__file__) base_path = os.path.dirname(__file__)
abs_pyo3_path = os.path.abspath(os.path.join(base_path, rel_pyo3_path)) abs_pyo3_path = os.path.abspath(os.path.join(base_path, rel_pyo3_path))
cargo_toml['dependencies']['pyo3']['path'] = abs_pyo3_path cargo_toml["dependencies"]["pyo3"]["path"] = abs_pyo3_path
with open(cargo_loc, 'w') as f: with open(cargo_loc, "w") as f:
toml.dump(cargo_toml, f) toml.dump(cargo_toml, f)
@ -69,6 +70,12 @@ def get_py_version_cfgs():
return out_cfg return out_cfg
def make_rust_extension(module_name):
return RustExtension(
module_name, "Cargo.toml", rustc_flags=get_py_version_cfgs(), debug=True
)
install_requires = [] install_requires = []
tests_require = install_requires + ["pytest", "pytest-benchmark"] tests_require = install_requires + ["pytest", "pytest-benchmark"]
@ -86,29 +93,14 @@ setup(
], ],
packages=["rustapi_module"], packages=["rustapi_module"],
rust_extensions=[ rust_extensions=[
RustExtension( make_rust_extension("rustapi_module.othermod"),
"rustapi_module.othermod", "Cargo.toml", rustc_flags=get_py_version_cfgs() make_rust_extension("rustapi_module.datetime"),
), make_rust_extension("rustapi_module.subclassing"),
RustExtension( make_rust_extension("rustapi_module.test_dict"),
"rustapi_module.datetime", "Cargo.toml", rustc_flags=get_py_version_cfgs()
),
RustExtension(
"rustapi_module.subclassing",
"Cargo.toml",
rustc_flags=get_py_version_cfgs(),
),
RustExtension(
"rustapi_module.test_dict",
"Cargo.toml",
rustc_flags=get_py_version_cfgs(),
),
], ],
install_requires=install_requires, install_requires=install_requires,
tests_require=tests_require, tests_require=tests_require,
include_package_data=True, include_package_data=True,
zip_safe=False, zip_safe=False,
cmdclass={ cmdclass={"test": PyTest, "sdist": CargoModifiedSdist},
'test': PyTest,
'sdist': CargoModifiedSdist,
},
) )

View File

@ -81,7 +81,7 @@ setup(
"Operating System :: MacOS :: MacOS X", "Operating System :: MacOS :: MacOS X",
], ],
packages=["word_count"], packages=["word_count"],
rust_extensions=[RustExtension("word_count.word_count", "Cargo.toml")], rust_extensions=[RustExtension("word_count.word_count", "Cargo.toml", debug=True)],
install_requires=install_requires, install_requires=install_requires,
tests_require=tests_require, tests_require=tests_require,
setup_requires=setup_requires, setup_requires=setup_requires,