Skip to content

Cache the Rust build #152

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

Closed
Bendabir opened this issue Jul 8, 2021 · 5 comments
Closed

Cache the Rust build #152

Bendabir opened this issue Jul 8, 2021 · 5 comments

Comments

@Bendabir
Copy link

Bendabir commented Jul 8, 2021

Hello,
I was wondering if there was any solution to cache the build of the Rust bindings. I sometimes need to build my Python package several times to test stuff I cannot really test with automated tests and it takes a lot of time. I couldn't find a way to cache the Rust build as my bindings are not changing very often. Any idea ?

Thanks for your help !
Ben

@davidhewitt
Copy link
Member

Hi @Bendabir, cargo (which setuptools-rust delegates work to) has pretty good caching built in for you. In addition, it's possible to configure cargo to use additional caches such as sccache. I think it's out of scope of setuptools-rust to configure this kind of stuff.

If the problem is that you are frequently experiencing unneeded rebuilds, perhaps PyO3/pyo3#1708 is what you are also experiencing?

@Bendabir
Copy link
Author

Hi,
thanks for the reply ! I know that cargo has a caching mecanism and I usually don't have any issue with it when running the tests of my app. It seems to only occur at build time. I'm using PyO3 0.12.3 so I'm sure it could be related to the issue you mentionned. I might doing something wrong somewhere, I'll investiguate further !

@Bendabir
Copy link
Author

Ok, it seems to be related to pip that is caching the wheel build when using pip install. Thanks again.

@davidhewitt
Copy link
Member

Thanks. Is there any advice on that point you think I should add to the setuptools-rust docs to help future users?

@Bendabir
Copy link
Author

I've noticed that running the build before running pip for installation fixed the issue. For example :

python setup.py bdist_wheel
pip install .

If I only run pip install ., it rebuilds the Rust bindings every time.

For information, I'm using :

  • pip 21.1.2 (but I've noticed this issue since earlier versions of pip, probably 20.x)
  • rust 1.48.0
  • pyo3 0.12.3

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

2 participants