You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This makes it difficult to build C extensions against this version of Python, since it looks like libraries tend to check INCLUDEPY.
Interestingly, include is fine:
$ python -msysconfig | grep include
include = "/Users/goldbaum/.local/share/uv/python/cpython-3.13.0+freethreaded-macos-aarch64-none/include/python3.13t"
platinclude = "/Users/goldbaum/.local/share/uv/python/cpython-3.13.0+freethreaded-macos-aarch64-none/include/python3.13t"
I see that there is prior discussion about these /install paths being hard to update, although maybe since one path is updated we can update INCLUDEPY?
We could also update the libraries to get the include path from 'include', but it would be nice if libraries that introspect Python to try to ask questions like this didn't have to get updates to work with python-build-standalone builds.
Thanks for the report. I wonder how include gets derived? It's not like the build knows it'll be unpacked there. I worry this is an upstream CPython behavior?
I stepped through the standard library in a debugger. It looks like sys.get_path('include') ends up going into _expand_varshere, which then substitutes the correct path from the templates in the _INSTALL_SCHEMES dictionary.
> /Users/goldbaum/.local/share/uv/python/cpython-3.13.0+freethreaded-macos-aarch64-none/lib/python3.13t/sysconfig/__init__.py(277)_expand_vars()
-> value = os.path.expanduser(value)
(Pdb) p _INSTALL_SCHEMES[scheme]['include']
'{installed_base}/include/{implementation_lower}{py_version_short}{abiflags}'
(Pdb) p _subst_vars('{installed_base}/include/{implementation_lower}{py_version_short}{abiflags}', vars)
'/Users/goldbaum/.local/share/uv/python/cpython-3.13.0+freethreaded-macos-aarch64-none/include/python3.13t'
INCLUDEPY on the other hand it looks like is directly written to the binary and comes from get_config_vars(). So it looks like this is the intended behavior and maybe the downstream libraries are doing the incorrect thing by checking INCLUDEPY?
I can certainly make a PyO3 patch that checks sysconfig.get_path('include') if INCLUDEPY isn't a valid path. I already did that for NumPy in numpy/numpy#27581.
Thank you! That makes sense to me. The alternative is to change the INCLUDEPY value when the standalone distributions are installed — but I don't think we can do anything at build time.
If we rewrote INCLUDEPY at install time, would it be such that we point to an absolute path, referencing the destination to which we unpacked the Python?
Activity
ngoldbaum commentedon Oct 18, 2024
We could also update the libraries to get the include path from
'include', but it would be nice if libraries that introspect Python to try to ask questions like this didn't have to get updates to work with python-build-standalone builds.ngoldbaum commentedon Oct 18, 2024
PyO3 uses
INCLUDEPYhere: https://github.com/PyO3/pyo3/blob/face5936ac275d386096b44ab42d1bca4089ef34/pyo3-ffi-check/build.rs#L8NumPy uses it here: https://github.com/numpy/numpy/blob/dc862b43e3bca09dcf5c235c46b2c7573e2e4b80/numpy/testing/_private/extbuild.py#L109
I don't know the history here or why this particular variable gets picked up so much.
zanieb commentedon Oct 18, 2024
Thanks for the report. I wonder how
includegets derived? It's not like the build knows it'll be unpacked there. I worry this is an upstream CPython behavior?zanieb commentedon Oct 18, 2024
Maybe relevant
ngoldbaum commentedon Oct 18, 2024
I stepped through the standard library in a debugger. It looks like
sys.get_path('include')ends up going into_expand_varshere, which then substitutes the correct path from the templates in the_INSTALL_SCHEMESdictionary.INCLUDEPYon the other hand it looks like is directly written to the binary and comes fromget_config_vars(). So it looks like this is the intended behavior and maybe the downstream libraries are doing the incorrect thing by checkingINCLUDEPY?I can certainly make a PyO3 patch that checks
sysconfig.get_path('include')ifINCLUDEPYisn't a valid path. I already did that for NumPy in numpy/numpy#27581.zanieb commentedon Oct 18, 2024
Thank you! That makes sense to me. The alternative is to change the
INCLUDEPYvalue when the standalone distributions are installed — but I don't think we can do anything at build time.ngoldbaum commentedon Oct 18, 2024
If it can be changed at install time I think that would be best, there's a lot of code out there checking for INCLUDEPY: https://github.com/search?q=INCLUDEPY&type=code
zanieb commentedon Oct 18, 2024
Related astral-sh/uv#7369
zanieb commentedon Oct 21, 2024
Opened astral-sh/uv#8429 to track this
charliermarsh commentedon Dec 11, 2024
If we rewrote
INCLUDEPYat install time, would it be such that we point to an absolute path, referencing the destination to which we unpacked the Python?zanieb commentedon Dec 11, 2024
I think so, yes.
charliermarsh commentedon Dec 17, 2024
This is now fixed at install-time in uv -- should we close out?
zanieb commentedon Dec 17, 2024
I think we may want to make it easier to apply the patches that uv does outside of uv, but perhaps we should track that separately.