-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
extension_module in cross compilation gives wrong architecture name #7049
Comments
This is a bug in the module as a whole, it always uses the running python interpreter to get the path to install modules to, which isn't right. |
It doesn't look like that to me. :/ INTROSPECT_COMMAND is run by the python returned from find_installation, and architecture name etc. comes from the introspected EXT_SUFFIX and other sysconfig variables. It seems to me that the problem here is I do see a different problem, which is that it doesn't seem to be hooked up to exe_wrapper and the introspection command may just utterly fail, resulting in the python module reporting that it is "not a valid python" and returning not-found. |
Somewhat related to this, |
I ran into this issue and am trying to fix this bug. But there's an issue here I think. State right now: for a setup with a regular build and host envs with a Python installed in both, and without specifying The problem with trying to fix this issue: say I have a cross file containing:
and now I want to specify the host Python binary:
That will fail with:
Makes sense - that's an
to make host Python run, the effect is that
because the cross-compilers are also exe-wrapped. The docs don't talk about this; for CMake specifically there seems to be a hack ( |
This is still quite confusing - I'd like to get some confirmation of what the intended design is here. We have the following ingredients: (1) a Python executable and dependency object from this canonical snippet in a py = import('python').find_installation(pure: false)
py_dep = py.dependency() (2) a native file which identifies a Python interpreter (used by [binaries]
python = '/path/to/build/env/python' (3) a cross file which may identify a Python interpreter (possibly necessary for all cross builds, unclear to me): [binaries]
python = '/path/to/host/env/python' (4) we may have to run the native Python interpreter for, e.g., codegen tasks. This can be done in two ways: # the .py file here must contain a shebang `!/usr/bin/env python3`
run_command('_codegen_script.py')
_decomp_update_pyx = custom_target('_a_target',
output: '_outfile.ext',
input: '_outfile.ext.in',
command: [_codegen_script.py, '@INPUT@', '-o', '@OUTDIR@'] or: # here `py` is the interpreter found by `py_mod.find_installation`
_decomp_update_pyx = custom_target('_a_target',
output: '_outfile.ext',
input: '_outfile.ext.in',
command: [py, _codegen_script.py, '@INPUT@', '-o', '@OUTDIR@']
) I believe @eli-schwartz suggested elsewhere that the shebang method must always be preferred. In SciPy I mostly use the (5) We also have a `dependency('python')` with its docs stating: "Note that It looks like @dcbaker and @bonzini are assuming that the Meson design is that Thoughts? |
@dcbaker @eli-schwartz, could we get your thoughts here? This will influence the upcoming scipy release, in the sense that some distributors have already said they'll have to carry patches (which we cannot merge into SciPy proper before the terminology is clearer). |
I'd like to fix this by taking inspiration from Gentoo's gpep517, which has already solved the problem. In Gentoo, we try hard to avoid exe wrappers like QEMU, as they greatly complicated matters for the package manager. Both Meson and gpep517 find Python's stdlib path by cheating slightly, combining the target host's prefix with the build host's Python stdlib path. This assumes that Python is configured in a similar way between the build and target hosts, but it's probably the best we can do. gpep517 goes one step further and uses the target's sysconfigdata file from stdlib. The exact filename is hard to predict, but there should only be one, so it looks for This is probably best done in python_info.py, but I'll see what works. |
You can do this without any explicit meson support. Set your python binary to a wrapper script that exports The problem with this approach is that not everything is in sysconfig_data, although several crucial cross-compilation things are, in particular the architecture name. Things that aren't:
It's not clear what to do for these bits of data aside for actually running the cross python itself. |
Until now, the build host's EXT_SUFFIX was used, resulting in native extensions being build and installed with the wrong filename. To do this, we load the sys_root sysconfigdata from its stdlib directory. We assume that the same Python version as the build host exists within the sys_root with the same stdlib directory, save for the prefix. If not, we fall back to the build host, as we did before. If the machine file points python at a Python within sys_root then this should still work. You should probably only run a sys_root's binary using some kind of wrapper, but either way, sysconfig will still return the correct values. We only read EXT_SUFFIX from the sys_root because paths are expected to be the same, save for the prefix, and other info such as the platform and limited API suffix cannot be determined this way. We could potentially guess the limited API suffix from the platform, as there are only a small number of possible values, but this can be done separately. Closes: mesonbuild#7049
Until now, the build host's EXT_SUFFIX was used, resulting in native extensions being build and installed with the wrong filename. To do this, we load the sys_root sysconfigdata from its stdlib directory. We assume that the same Python version as the build host exists within the sys_root with the same stdlib directory, save for the prefix. If not, we fall back to the build host, as we did before. If the machine file points python at a Python within sys_root then this should still work. You should probably only run a sys_root's binary using some kind of wrapper, but either way, sysconfig will still return the correct values. We only read EXT_SUFFIX from the sys_root because paths are expected to be the same, save for the prefix, and other info such as the platform and limited API suffix cannot be determined this way. We could potentially guess the limited API suffix from the platform, as there are only a small number of possible values, but this can be done separately. Closes: mesonbuild#7049
Until now, the build host's EXT_SUFFIX was used, resulting in native extensions being build and installed with the wrong filename. To do this, we load the sys_root sysconfigdata from its stdlib directory. We assume that the same Python version as the build host exists within the sys_root with the same stdlib directory, save for the prefix. If not, we fall back to the build host, as we did before. If the machine file points python at a Python within sys_root then this should still work. You should probably only run a sys_root's binary using some kind of wrapper, but either way, sysconfig will still return the correct values. We only read EXT_SUFFIX from the sys_root because paths are expected to be the same, save for the prefix, and other info such as the platform and limited API suffix cannot be determined this way. We could potentially guess the limited API suffix from the platform, as there are only a small number of possible values, but this can be done separately. Closes: mesonbuild#7049
Until now, the build host's EXT_SUFFIX was used, resulting in native extensions being build and installed with the wrong filename. To do this, we load the sys_root sysconfigdata from its stdlib directory. We assume that the same Python version as the build host exists within the sys_root with the same stdlib directory, save for the prefix. If not, we fall back to the build host, as we did before. If the machine file points python at a Python within sys_root then this should still work. You should probably only run a sys_root's binary using some kind of wrapper, but either way, sysconfig will still return the correct values. We only read EXT_SUFFIX from the sys_root because paths are expected to be the same, save for the prefix, and other info such as the platform and limited API suffix cannot be determined this way. We could potentially guess the limited API suffix from the platform, as there are only a small number of possible values, but this can be done separately. Closes: mesonbuild#7049
See #12190 for a fix. |
Until now, the build host's EXT_SUFFIX/SO was used, resulting in native extensions being build and installed with the wrong filename. To do this, we load the sys_root sysconfigdata from its stdlib directory. We assume that the same Python version as the build host exists within the sys_root with the same stdlib directory, save for the prefix. If not, we fall back to the build host, as we did before. If the machine file points python at a Python within sys_root then this should still work. You should probably only run a sys_root's binary using some kind of wrapper, but either way, sysconfig will still return the correct values. We only read EXT_SUFFIX/SO from the sys_root because paths are expected to be the same, save for the prefix, and other info such as the platform and limited API suffix cannot be determined this way. We could potentially guess the limited API suffix from the platform, as there are only a small number of possible values, but this can be done separately. Closes: mesonbuild#7049
Until now, the build host's EXT_SUFFIX/SO was used, resulting in native extensions being build and installed with the wrong filename. To do this, we load the sys_root sysconfigdata from its stdlib directory. We assume that the same Python version as the build host exists within the sys_root with the same stdlib directory, save for the prefix. If not, we fall back to the build host, as we did before. If the machine file points python at a Python within sys_root then this should still work. You should probably only run a sys_root's binary using some kind of wrapper, but either way, sysconfig will still return the correct values. We only read EXT_SUFFIX/SO from the sys_root because paths are expected to be the same, save for the prefix, and other info such as the platform and limited API suffix cannot be determined this way. We could potentially guess the limited API suffix from the platform, as there are only a small number of possible values, but this can be done separately. Closes: mesonbuild#7049
Until now, if the build machine's Python was used for cross, the wrong EXT_SUFFIX/SO was used, resulting in native extensions being built and installed with the wrong filename. To fix this, we load the sys_root sysconfigdata from its stdlib directory. We assume that the same Python version as the build machine exists within the sys_root with the same stdlib directory, save for the prefix. If not, we fall back to the build machine, as we did before. If the machine file points python at a Python within sys_root then this should still work. You should probably only run a sys_root's binary using some kind of wrapper, but either way, sysconfig will still return the correct values. We only read EXT_SUFFIX/SO from the sys_root because paths are expected to be the same, save for the prefix, and other info such as the platform and limited API suffix cannot be determined this way. We could potentially guess the limited API suffix from the platform, as there are only a small number of possible values, but this can be done separately. Closes: mesonbuild#7049
Until now, if the build machine's Python was used for cross, the wrong EXT_SUFFIX/SO was used, resulting in native extensions being built and installed with the wrong filename. To fix this, we load the sys_root sysconfigdata from its stdlib directory. We assume that the same Python version as the build machine exists within the sys_root with the same stdlib directory, save for the prefix. If not, we fall back to the build machine, as we did before. If the machine file points python at a Python within sys_root then this should still work. You should probably only run a sys_root's binary using some kind of wrapper, but either way, sysconfig will still return the correct values. We only read EXT_SUFFIX/SO from the sys_root because paths are expected to be the same, save for the prefix, and other info such as the platform and limited API suffix cannot be determined this way. We could potentially guess the limited API suffix from the platform, as there are only a small number of possible values, but this can be done separately. Closes: mesonbuild#7049
Describe the bug
I am cross-compiling a python extension module in a project I am working on into a shared library for an aarch64 platform. The name of the file becomes "pyworker.cpython-37m-x86_64-linux-gnu.so" which is not right. My build machine is a x86_64 but this is not the target platform.
In fact if I call "file" too see what type of file "pyworker.cpython-37m-x86_64-linux-gnu.so" I get:
I seem incapable of changing this name into something more appropriate and I have an issue with this.
To Reproduce
The code in the meson.build looks like this:
I am using a meson.cross file with
Expected behavior
I expect not to see the architecture name x86_64 in the file name, rather aarch64.
system parameters
The text was updated successfully, but these errors were encountered: