Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tox, PyTest, sdist...requires usedevelop for idiomatic tox tests to work #3

Closed
cathalgarvey opened this issue Apr 10, 2017 · 4 comments

Comments

@cathalgarvey
Copy link

I discovered this by trial and error, so perhaps I'm off the mark here. People more familiar with the PyTest/Tox/Rust trifecta (??) may know a better way.

Basically, I've been trying to port a Cython-accelerated python module to Rust, as a learning exercise and as a way of bringing the module into 2017 (previously it was Py2 only). The module uses PyTest and Tox. I was at the point where, using setuptools-rust, I could build and manually test the code, and it worked great (thanks!).

However, it would consistently fail with tox, complaining that the rust extension module wasn't present.

In the end, I learned that tox uses sdist normally, and apparently this won't trigger Rust module build? Because, it was fixed when I added usedevelop=True to the [testenv] block of my tox.ini; because setuptools-rust supports build when pythonX setup.py develop is invoked, this magically solved my problem.

All of which is to say... does it make sense to add a build-hook somewhere to support tox when it's operating in the default sdist-centric mode? :)

Thanks again for this module, it's amazing to be able to ship Rust so easily, at last. Next thing is learning about how to do binary wheels...

@fafhrd91
Copy link
Collaborator

I am not very familiar with tox. if you know where to add hook or when, it'd helpful.

regarding wheel, "python setup.py build_wheel" should just work.

@cathalgarvey
Copy link
Author

I'm sure I know significantly less than you about setuptools' interfaces and options. :) It's not an essential "feature" anyway, but it was something I encountered that might be relevant to others.

Glad to hear that wheel-building should work OK out of the box. The only platform I care about, really, is Linux x86_64; ARM/ARM64 would be nice, though, so I may investigate how cross-compiling binary wheels would work, also. It looks like Python3 has support for importing platform-specific binaries (e.g. filenames like foolib.cpython-35m-x86_64-linux-gnu.so import successfully as import foolib), so perhaps just cross-compiling manually with cargo and stuffing them in the wheel will work? :)

pattonw added a commit to pattonw/rust-pyn5 that referenced this issue Mar 8, 2019
added usedevelop=True to [testenv]
Following PyO3/setuptools-rust#3
@althonos
Copy link
Member

A bit of necrobumping for people who may read this now: sdist is supposed to get your sources, so no compilation is involved. Compilation is going to happen when you pip install the source distribution sdist creates.

You need to make sure all your Rust sources are embedded in the source distribution using a MANIFEST.in configuration file, because they will not be by default (Python is not aware of Rust sources). When done right, tox should work without the usedevelop option.

1 similar comment
@althonos
Copy link
Member

A bit of necrobumping for people who may read this now: sdist is supposed to get your sources, so no compilation is involved. Compilation is going to happen when you pip install the source distribution sdist creates.

You need to make sure all your Rust sources are embedded in the source distribution using a MANIFEST.in configuration file, because they will not be by default (Python is not aware of Rust sources). When done right, tox should work without the usedevelop option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants