Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@tylerjereddy
Copy link
Contributor

  • Fixes BUG: failed to build with PYTHONSAFEPATH=1 environment variable #24907

  • marked as WIP (and CI skipped) for now because this is ugly and we could also just decide not to fix it at all, and/or to error out when that env var is set with a clear error message

  • we can avoid PYTHONSAFEPATH causing our build to choke on the fact that the NumPy build requires Python code to execute an "unsafe" import from its own build dir

  • here, the chosen approach is to perform the import "manually," but we could also decide to refuse to build if that environment variable is set for example, depending on our view on the matter

[ci skip] [skip cirrus]

* Fixes numpy#24907

* we can avoid `PYTHONSAFEPATH` causing our build to choke
on the fact that the NumPy build requires Python code
to execute an "unsafe" import from its own build dir

* here, the chosen approach is to perform the import
"manually," but we could also decide to refuse to build
if that environment variable is set for example, depending
on our view on the matter

[ci skip] [skip cirrus]
@tylerjereddy tylerjereddy added the 36 - Build Build related PR label Oct 17, 2023
@seberg
Copy link
Member

seberg commented Oct 18, 2023

Maybe the fix is rather embrace the module nature, there already is an __init__.py! I.e. change the calling to:

python -m code_generators.generate_numpy_api ...

And fix the imports to use from . import genapi. I bet that will also fix that crazy get_annotations() function need in numpy_api.py.

@jorenham
Copy link
Member

jorenham commented Jan 8, 2026

Is this still relevant?

@mattip
Copy link
Member

mattip commented Jan 26, 2026

Doing pip wheel --no-binary numpy git+https://github.com/numpy/numpy after export PYTHONSAFEPATH=1 still fails, but I don't know if this is something we want to fix. If a user wants PYTHONSAFEPATH, overriding that by setting sys.path seems counter-productive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

25 - WIP 36 - Build Build related PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: failed to build with PYTHONSAFEPATH=1 environment variable

4 participants