From 94f6248d87b085bd2dbade6a5dd505282f699552 Mon Sep 17 00:00:00 2001 From: konstin Date: Thu, 5 Sep 2019 13:13:06 +0200 Subject: [PATCH] Compile examples in debug mode --- examples/rustapi_module/setup.py | 42 +++++++++++++------------------- examples/word-count/setup.py | 2 +- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/examples/rustapi_module/setup.py b/examples/rustapi_module/setup.py index 2dbaebb0..2a277457 100644 --- a/examples/rustapi_module/setup.py +++ b/examples/rustapi_module/setup.py @@ -38,20 +38,21 @@ class CargoModifiedSdist(SdistCommand): super().make_release_tree(base_dir, files) import toml + # 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) - with open(cargo_loc, 'r') as f: + with open(cargo_loc, "r") as 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__) 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) @@ -69,6 +70,12 @@ def get_py_version_cfgs(): 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 = [] tests_require = install_requires + ["pytest", "pytest-benchmark"] @@ -86,29 +93,14 @@ setup( ], packages=["rustapi_module"], rust_extensions=[ - RustExtension( - "rustapi_module.othermod", "Cargo.toml", rustc_flags=get_py_version_cfgs() - ), - RustExtension( - "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(), - ), + make_rust_extension("rustapi_module.othermod"), + make_rust_extension("rustapi_module.datetime"), + make_rust_extension("rustapi_module.subclassing"), + make_rust_extension("rustapi_module.test_dict"), ], install_requires=install_requires, tests_require=tests_require, include_package_data=True, zip_safe=False, - cmdclass={ - 'test': PyTest, - 'sdist': CargoModifiedSdist, - }, + cmdclass={"test": PyTest, "sdist": CargoModifiedSdist}, ) diff --git a/examples/word-count/setup.py b/examples/word-count/setup.py index 153637f7..dfdbec75 100644 --- a/examples/word-count/setup.py +++ b/examples/word-count/setup.py @@ -81,7 +81,7 @@ setup( "Operating System :: MacOS :: MacOS X", ], 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, tests_require=tests_require, setup_requires=setup_requires,