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

Skip to content

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

@GalaxySnail

Description

@GalaxySnail

Describe the issue:

Failed to build numpy 1.26.0 or main branch with PYTHONSAFEPATH=1 environment variable.

Please refer to: https://docs.python.org/3/using/cmdline.html#envvar-PYTHONSAFEPATH

Reproduce the code example:

export PYTHONSAFEPATH=1
pip wheel --no-binary numpy numpy==1.26.0
# or main branch
pip wheel --no-binary numpy git+https://github.com/numpy/numpy

Error message:

Traceback (most recent call last):
  File "/tmp/pip-wheel-vdqy4dbr/numpy_1f47512b2a0a4ad3899813685753144f/.mesonpy-2dh000d4/build/../../numpy/core/code_generators/generate_ufunc_api.py", line 4, in <module>
    import genapi
ModuleNotFoundError: No module named 'genapi'
full meson log
The Meson build system
Version: 1.2.99
Source dir: /tmp/pip-wheel-vdqy4dbr/numpy_1f47512b2a0a4ad3899813685753144f
Build dir: /tmp/pip-wheel-vdqy4dbr/numpy_1f47512b2a0a4ad3899813685753144f/.mesonpy-2dh000d4/build
Build type: native build
Project name: NumPy
Project version: 1.26.0
C compiler for the host machine: cc (gcc 13.2.1 "cc (GCC) 13.2.1 20230801")
C linker for the host machine: cc ld.bfd 2.41.0
C++ compiler for the host machine: c++ (gcc 13.2.1 "c++ (GCC) 13.2.1 20230801")
C++ linker for the host machine: c++ ld.bfd 2.41.0
Cython compiler for the host machine: cython (cython 3.0.3)
Host machine cpu family: x86_64
Host machine cpu: x86_64
Program python found: YES (/usr/bin/python)
Found pkg-config: /usr/bin/pkg-config (1.8.1)
Run-time dependency python found: YES 3.11
Has header "Python.h" with dependency python-3.11: YES
Compiler for C supports arguments -fno-strict-aliasing: YES
Test features "SSE SSE2 SSE3" : Supported
Test features "SSSE3" : Supported
Test features "SSE41" : Supported
Test features "POPCNT" : Supported
Test features "SSE42" : Supported
Test features "AVX" : Supported
Test features "F16C" : Supported
Test features "FMA3" : Supported
Test features "AVX2" : Supported
Test features "AVX512F" : Supported
Test features "AVX512CD" : Supported
Test features "AVX512_KNL" : Supported
Test features "AVX512_KNM" : Supported
Test features "AVX512_SKX" : Supported
Test features "AVX512_CLX" : Supported
Test features "AVX512_CNL" : Supported
Test features "AVX512_ICL" : Supported
Test features "AVX512_SPR" : Supported
Configuring npy_cpu_dispatch_config.h using configuration
Message:
CPU Optimization Options
  baseline:
    Requested : min
    Enabled   : SSE SSE2 SSE3
  dispatch:
    Requested : max -xop -fma4
    Enabled   : SSSE3 SSE41 POPCNT SSE42 AVX F16C FMA3 AVX2 AVX512F AVX512CD AVX512_KNL AVX512_KNM AVX512_SKX AVX512_CLX AVX512_CNL AVX512_ICL AVX512_SPR

Library m found: YES
Run-time dependency openblas found: YES
Checking if "CBLAS" with dependency openblas: links: YES
Dependency openblas found: YES unknown (cached)
Program _build_utils/process_src_template.py found: YES (/usr/bin/python /tmp/pip-wheel-vdqy4dbr/numpy_1f47512b2a0a4ad3899813685753144f/numpy/_build_utils/process_src_template.py)
Program _build_utils/tempita.py found: YES (/tmp/pip-wheel-vdqy4dbr/numpy_1f47512b2a0a4ad3899813685753144f/numpy/_build_utils/tempita.py)
Configuring __config__.py using configuration
Checking for size of "short" : 2
Checking for size of "int" : 4
Checking for size of "long" : 8
Checking for size of "long long" : 8
Checking for size of "float" : 4
Checking for size of "double" : 8
Checking for size of "long double" : 16
Checking for size of "off_t" : 8
Checking for size of "Py_intptr_t" with dependency python-3.11: 8
Checking for size of "PY_LONG_LONG" with dependency python-3.11: 8
Has header "complex.h" : YES
Checking for type "complex float" : YES
Checking for size of "struct {float __x; float __y;}" : 8
Checking for type "complex double" : YES
Checking for size of "struct {double __x; double __y;}" : 16
Checking for type "complex long double" : YES
Checking for size of "struct {long double __x; long double __y;}" : 32
Checking for function "sin" : YES
Checking for function "cos" : YES
Checking for function "tan" : YES
Checking for function "sinh" : YES
Checking for function "cosh" : YES
Checking for function "tanh" : YES
Checking for function "fabs" : YES
Checking for function "floor" : YES
Checking for function "ceil" : YES
Checking for function "sqrt" : YES
Checking for function "log10" : YES
Checking for function "log" : YES
Checking for function "exp" : YES
Checking for function "asin" : YES
Checking for function "acos" : YES
Checking for function "atan" : YES
Checking for function "fmod" : YES
Checking for function "modf" : YES
Checking for function "frexp" : YES
Checking for function "ldexp" : YES
Checking for function "expm1" : YES
Checking for function "log1p" : YES
Checking for function "acosh" : YES
Checking for function "asinh" : YES
Checking for function "atanh" : YES
Checking for function "rint" : YES
Checking for function "trunc" : YES
Checking for function "exp2" : YES
Checking for function "copysign" : YES
Checking for function "nextafter" : YES
Checking for function "strtoll" : YES
Checking for function "strtoull" : YES
Checking for function "cbrt" : YES
Checking for function "log2" : YES
Checking for function "pow" : YES
Checking for function "hypot" : YES
Checking for function "atan2" : YES
Checking for function "csin" : YES
Checking for function "csinh" : YES
Checking for function "ccos" : YES
Checking for function "ccosh" : YES
Checking for function "ctan" : YES
Checking for function "ctanh" : YES
Checking for function "creal" : YES
Checking for function "cimag" : YES
Checking for function "conj" : YES
Checking for function "cabs" : YES
Checking for function "cabsf" : YES
Checking for function "cabsl" : YES
Checking for function "cacos" : YES
Checking for function "cacosf" : YES
Checking for function "cacosl" : YES
Checking for function "cacosh" : YES
Checking for function "cacoshf" : YES
Checking for function "cacoshl" : YES
Checking for function "carg" : YES
Checking for function "cargf" : YES
Checking for function "cargl" : YES
Checking for function "casin" : YES
Checking for function "casinf" : YES
Checking for function "casinl" : YES
Checking for function "casinh" : YES
Checking for function "casinhf" : YES
Checking for function "casinhl" : YES
Checking for function "catan" : YES
Checking for function "catanf" : YES
Checking for function "catanl" : YES
Checking for function "catanh" : YES
Checking for function "catanhf" : YES
Checking for function "catanhl" : YES
Checking for function "cexp" : YES
Checking for function "cexpf" : YES
Checking for function "cexpl" : YES
Checking for function "clog" : YES
Checking for function "clogf" : YES
Checking for function "clogl" : YES
Checking for function "cpow" : YES
Checking for function "cpowf" : YES
Checking for function "cpowl" : YES
Checking for function "csqrt" : YES
Checking for function "csqrtf" : YES
Checking for function "csqrtl" : YES
Checking for function "csin" : YES (cached)
Checking for function "csinf" : YES
Checking for function "csinl" : YES
Checking for function "csinh" : YES (cached)
Checking for function "csinhf" : YES
Checking for function "csinhl" : YES
Checking for function "ccos" : YES (cached)
Checking for function "ccosf" : YES
Checking for function "ccosl" : YES
Checking for function "ccosh" : YES (cached)
Checking for function "ccoshf" : YES
Checking for function "ccoshl" : YES
Checking for function "ctan" : YES (cached)
Checking for function "ctanf" : YES
Checking for function "ctanl" : YES
Checking for function "ctanh" : YES (cached)
Checking for function "ctanhf" : YES
Checking for function "ctanhl" : YES
Checking for function "isfinite" : YES
Header "Python.h" has symbol "isfinite" with dependency python-3.11: YES
Checking for function "isinf" : YES
Header "Python.h" has symbol "isinf" with dependency python-3.11: YES
Checking for function "isnan" : YES
Header "Python.h" has symbol "isnan" with dependency python-3.11: YES
Checking for function "signbit" : YES
Header "Python.h" has symbol "signbit" with dependency python-3.11: YES
Checking for function "fallocate" : YES
Header "Python.h" has symbol "HAVE_FTELLO" with dependency python-3.11: YES
Header "Python.h" has symbol "HAVE_FSEEKO" with dependency python-3.11: YES
Checking for function "strtold_l" : NO
Checking for function "strtold_l" : NO
Checking for function "backtrace" : YES
Checking for function "madvise" : YES
Has header "features.h" : YES
Has header "xlocale.h" : NO
Has header "dlfcn.h" : YES
Has header "execinfo.h" : YES
Has header "libunwind.h" : YES
Has header "sys/mman.h" : YES
Compiler for C supports arguments -O3: YES
Has header "endian.h" : YES
Has header "sys/endian.h" : NO
Header "inttypes.h" has symbol "PRIdPTR" : YES
Compiler for C supports function attribute visibility:hidden: YES
Configuring config.h using configuration
Configuring _numpyconfig.h using configuration
Configuring npymath.ini using configuration
Configuring mlib.ini using configuration
Generating multi-targets for "_umath_tests.dispatch.h"
  Enabled targets: AVX2, SSE41, baseline
Generating multi-targets for "argfunc.dispatch.h"
  Enabled targets: AVX512_SKX, AVX2, SSE42, baseline
Generating multi-targets for "simd_qsort.dispatch.h"
  Enabled targets: AVX512_SKX
Generating multi-targets for "simd_qsort_16bit.dispatch.h"
  Enabled targets: AVX512_SPR, AVX512_ICL
Generating multi-targets for "loops_arithm_fp.dispatch.h"
  Enabled targets: FMA3__AVX2, baseline
Generating multi-targets for "loops_arithmetic.dispatch.h"
  Enabled targets: AVX512_SKX, AVX512F, AVX2, SSE41, baseline
Generating multi-targets for "loops_comparison.dispatch.h"
  Enabled targets: AVX512_SKX, AVX512F, AVX2, SSE42, baseline
Generating multi-targets for "loops_exponent_log.dispatch.h"
  Enabled targets: AVX512_SKX, AVX512F, FMA3__AVX2, baseline
Generating multi-targets for "loops_hyperbolic.dispatch.h"
  Enabled targets: AVX512_SKX, FMA3__AVX2, baseline
Generating multi-targets for "loops_logical.dispatch.h"
  Enabled targets: AVX512_SKX, AVX2, baseline
Generating multi-targets for "loops_minmax.dispatch.h"
  Enabled targets: AVX512_SKX, AVX2, baseline
Generating multi-targets for "loops_modulo.dispatch.h"
  Enabled targets: baseline
Generating multi-targets for "loops_trigonometric.dispatch.h"
  Enabled targets: AVX512F, FMA3__AVX2, baseline
Generating multi-targets for "loops_umath_fp.dispatch.h"
  Enabled targets: AVX512_SKX, baseline
Generating multi-targets for "loops_unary.dispatch.h"
  Enabled targets: AVX512_SKX, AVX2, baseline
Generating multi-targets for "loops_unary_fp.dispatch.h"
  Enabled targets: SSE41, baseline
Generating multi-targets for "loops_unary_fp_le.dispatch.h"
  Enabled targets: SSE41, baseline
Generating multi-targets for "loops_unary_complex.dispatch.h"
  Enabled targets: AVX512F, FMA3__AVX2, baseline
Generating multi-targets for "loops_autovec.dispatch.h"
  Enabled targets: AVX2, baseline
Generating multi-targets for "_simd.dispatch.h"
  Enabled targets: SSE42, AVX2, FMA3, FMA3__AVX2, AVX512F, AVX512_SKX, baseline
Build targets in project: 101

NumPy 1.26.0

  User defined options
    Native files: /tmp/pip-wheel-vdqy4dbr/numpy_1f47512b2a0a4ad3899813685753144f/.mesonpy-2dh000d4/build/meson-python-native-file.ini
    buildtype   : release
    b_ndebug    : if-release
    b_vscrt     : md

Found ninja-1.11.1 at /usr/bin/ninja
+ /usr/bin/ninja
[1/498] Generating numpy/core/npy_math_internal.h with a custom command
[2/498] Generating numpy/__init__.pxd with a custom command
[3/498] Generating 'numpy/core/libnpymath.a.p/ieee754.c'
[4/498] Generating numpy/__init__.py with a custom command
[5/498] Generating numpy/__init__.cython-30.pxd with a custom command
[6/498] Generating 'numpy/core/libnpymath.a.p/npy_math_complex.c'
[7/498] Generating numpy/core/_umath_doc_generated with a custom command
[8/498] Generating numpy/core/__umath_generated with a custom command
[9/498] Generating numpy/core/__ufunc_api with a custom command
FAILED: numpy/core/__ufunc_api.c numpy/core/__ufunc_api.h
/usr/bin/python ../../numpy/core/code_generators/generate_ufunc_api.py -o numpy/core
Traceback (most recent call last):
  File "/tmp/pip-wheel-vdqy4dbr/numpy_1f47512b2a0a4ad3899813685753144f/.mesonpy-2dh000d4/build/../../numpy/core/code_generators/generate_ufunc_api.py", line 4, in <module>
    import genapi
ModuleNotFoundError: No module named 'genapi'
[10/498] Generating numpy/core/__multiarray_api with a custom command
FAILED: numpy/core/__multiarray_api.c numpy/core/__multiarray_api.h
/usr/bin/python ../../numpy/core/code_generators/generate_numpy_api.py -o numpy/core --ignore numpy/core/__umath_generated.c
Traceback (most recent call last):
  File "/tmp/pip-wheel-vdqy4dbr/numpy_1f47512b2a0a4ad3899813685753144f/.mesonpy-2dh000d4/build/../../numpy/core/code_generators/generate_numpy_api.py", line 5, in <module>
    import genapi
ModuleNotFoundError: No module named 'genapi'
[11/498] Compiling C object numpy/core/libnpymath.a.p/meson-generated_ieee754.c.o
[12/498] Compiling C object numpy/core/libnpymath.a.p/src_npymath_npy_math.c.o
[13/498] Compiling C object numpy/core/libnpymath.a.p/meson-generated_npy_math_complex.c.o
[14/498] Compiling C++ object numpy/core/libnpymath.a.p/src_npymath_halffloat.cpp.o
ninja: build stopped: subcommand failed.

Runtime information:

>>> print(sys.version)
3.11.5 (main, Sep  2 2023, 14:16:33) [GCC 13.2.1 20230801]

Context for the issue:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions