Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run 'python setup.py test' without running build_ext?

I try to run python setup.py test without running build_ext to ensure that any C extensions and project metadata are up-to-date ?

As explain here: https://pythonhosted.org/setuptools/setuptools.html#test-build-package-and-run-a-unittest-suite::

python setup.py test

first run build_ext and then run unittest.

I have a lot of stuff to compile, and sometime I want to run test without the build_ext (I know that I've not modify compiled thinks)

Is that possible ?

like image 940
user3313834 Avatar asked Aug 08 '26 16:08

user3313834


1 Answers

I use an environment variable for this. My setup.py file checks for the environment variable and sets the ext_modules argument to the setup function to an empty list if needed:

# setup.py

# ...

if os.getenv('NO_BUILD') == 'true':
    extensions = []
else:
    extensions = []

setup(
    # ...
    ext_modules=extensions,
)

Then running the test suite with NO_BUILD=true python setup.py skips re-building (assuming your shell supports passing environment variables that way).

like image 64
bbayles Avatar answered Aug 11 '26 05:08

bbayles



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!