Skip to content

BLD: win32 not using python architecture  #24704

Description

@snowman2

From: pyproj4/pyproj#1330 (comment)

Host machine cpu: x86_64
        Program python found: YES (C:\Users\runneradmin\AppData\Local\Temp\cibw-run-dbhjql3e\cp39-win32\venv-test\Scripts\python.exe)
        Need python for x86_64, but found x86
        Run-time dependency python found: NO (tried sysconfig)
        
        ..\..\meson.build:43:12: ERROR: Python dependency not found

Possible to build based on python architecture and not host machine architecture? Other suggestions?

Activity

  1. mattip commented on Sep 14, 2023

    @mattip
    Member

    I commented on the issue. You should use --pre to get pre-build wheels for python3.12. This will improve the situation, but we do not yet have 32-bit wheels for 1.26-rc1. That was done in #24675 but the wheels are not generally available yet.

  2. andyfaff commented on Sep 14, 2023

    @andyfaff
    Member

    You may also need to set PIP_EXTRA_INDEX_URL.

  3. rgommers commented on Sep 14, 2023

    @rgommers
    Member

    The actual issue here is that MSVC for x86-64 is being used to try and build 32-bit Python extension modules:

    C compiler for the host machine: cl (msvc 19.35.32217.1 "Microsoft (R) C/C++ Optimizing Compiler Version 19.35.32217.1 for x64")
    

    To get past that problem, the 32-bit MSVC compiler must be activated so that it gets used for the whole build. The msdevshell GitHub Action is a convenient way of doing that, and is what we use in our own wheel build config:

    - name: Setup MSVC (32-bit)
    if: ${{ matrix.buildplat[1] == 'win32' }}
    uses: bus1/cabuild/action/msdevshell@e22aba57d6e74891d059d66501b6b5aed8123c4d # v1
    with:
    architecture: 'x86'
    .

    This problem is specific to Windows + 32-bit Python, so I don't expect to see more of these issues once we upload win32 wheels.

    I'll note that distutils didn't have this problem, because it could only worry about Python extension modules and hence default to the 32-bit compiler on a 64-bit OS when the user did not explicitly ask for that. Meson has many more languages to support, so compiler selection isn't going to be special-cased for the specific Python interpreter build you happen to be using.

  4. rgommers commented on Sep 14, 2023

    @rgommers
    Member

    Let's close this issue as soon as we have win32 wheels on PyPI for Python 3.12

  5. snowman2 commented on Sep 19, 2023

    @snowman2
    Author

    This has been resolved. Thanks!

  6. ngoldbaum commented on Mar 22, 2024

    @ngoldbaum
    Member

    The actual issue here is that MSVC for x86-64 is being used to try and build 32-bit Python extension modules:

    I just hit this trying to set up a 32 bit windows numpy development environment to run down an issue happening on CI.

    I eventually found this thread via a google search but would have gotten here faster with a nicer error message.

    @rgommers Is there a way for meson to detect that x64 MSVC is activated on x86 python and fail early?

  7. ngoldbaum commented on Mar 22, 2024

    @ngoldbaum
    Member

    also for anyone else trying to do this, I was able to build numpy with a 32 bit python in a VS command prompt after running vcvars32.bat.

  8. rgommers commented on Mar 22, 2024

    @rgommers
    Member

    The error message is pretty clear about the problem: Need python for x86_64, but found x86. The trouble is, it doesn't really tell you what you want to know here, which is how to avoid the problem. One way would be to amend the error message in Meson, if it can be made specific to Windows.

    Since dependency('python') fails, there's not much we can do to introspect the found installation. One thing we could do is to check a symbol from Python.h first, e.g. there's this we could fish out:

    /* The size of `uintptr_t', as computed by sizeof. */
    #define SIZEOF_UINTPTR_T 8
    

    Perhaps cc.sizeof('size_t') != SIZEOF_UINTPTR_T would work. The trouble is, to make sure we pick up the correct Python.h, we already need the py_dep object. Existing checks look like:

    cc.sizeof('Py_intptr_t', dependencies: py_dep, prefix: '#include <Python.h>'))

    So, doesn't look like there's anything we can check. I'll have a look at adding a sentence to the error message.

    xref mesonbuild/meson#11435 for the most relevant upstream issue.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    32 - InstallationProblems installing or compiling NumPy33 - QuestionQuestion about NumPy usage or development

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions