astral-sh / rye

a Hassle-Free Python Experience
https://rye.astral.sh
MIT License
13.48k stars 460 forks source link

Patch build info at install time #646

Open mitsuhiko opened 7 months ago

mitsuhiko commented 7 months ago

Today sysconfig and all the files in lib/pkgconfig have incorrect paths. These paths should be fixed up when the interpreter is installed or maybe later at runtime when possible.

This way c extensions would build correctly. Basically /install would have to turn into sys.base_prefix.

A good test case after will be if rye add uwsgi && rye sync works.

bluss commented 5 months ago

Here's a script that does some of the patching - at least sysconfigdata, at least for linux (and macos?), and it passes the uwsgi test. It's a python script with no dependencies, so it could be included by rye. This is just a quick way to do it, I don't think there is a way to do it perfectly, or rather, some use cases for these saved variables can only be relevant if the same build environment is still installed on the present computer, which it obviously is not.

https://github.com/bluss/sysconfigpatcher

I am a bit mystified how the CC variable is supposed to be used and what a good value is to patch it with. In rye's pythons it is set to clang -pthread.

rye tools install Rye would make it easy to install it just like, like this :wink: `rye tools install --git 'https://github.com/bluss/sysconfigpatcher' sysconfigpatcher` or `uv tool install --from 'git+https://github.com/bluss/sysconfigpatcher' sysconfigpatcher`
LukeMathWalker commented 1 month ago

We're running into this issue with our Rust-Python interoperability course, which uses rye to setup Python reliably on students' machines.

sysconfigpatcher has been very useful to troubleshoot and patch students' machines, but it wasn't enough on its own.

SichangHe commented 1 week ago

Is this why my PyO3 tests fail if I use a Rye environment?

LukeMathWalker commented 1 week ago

Is this why my PyO3 tests fail if I use a Rye environment?

Most likely, yes.