Skip to content
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

Cross compilation ignores PYO3_CROSS_PYTHON_VERSION #446

Closed
messense opened this issue Feb 25, 2021 · 4 comments · Fixed by #454
Closed

Cross compilation ignores PYO3_CROSS_PYTHON_VERSION #446

messense opened this issue Feb 25, 2021 · 4 comments · Fixed by #454

Comments

@messense
Copy link
Member

Please provide the following information:

  • Your python version (python -V): host Python 3.9, cross target Python 3.6
  • Your pip version (pip -V): -
  • The version of the bindings you're using, if any (e.g. pyo3, rust-cpython or cffi): pyo3
  • Does cargo build work? yes
  • If on windows, have you checked that you aren't accidentally using unix path (those with the forward slash /)? -

Please list the exact steps required to reproduce your error with all command output and if possible with a repository:

https://github.com/messense/manylinux2014-cross-arm/runs/1975989661?check_suite_focus=true

SetPYO3_CROSS_PYTHON_VERSION =3.6 and PYO3_CROSS_LIB_DIR according to https://pyo3.rs/v0.13.2/building_and_distribution.html#cross-compiling , maturin builds fine but produces cp39-cp39 wheels instead of cp36-cp36m.

@messense
Copy link
Member Author

It'd be nice if maturin can detect cross target Python version like pyo3 does https://github.com/PyO3/pyo3/blob/c02b71fc09017078034394c1f7d7011bddb5fd03/build.rs#L316

@messense
Copy link
Member Author

I guess this is essentially the same issue as #375 because of its poor cross compilation support.

@konstin
Copy link
Member

konstin commented Feb 25, 2021

Unless we require passing extra data, this will require copying (or extracting in a shared crate) of https://github.com/PyO3/pyo3/blob/master/build.rs#L311-L510

For future reference, that part could be used for parsing the version:

    if let Some(cross_python_version) = env::var_os("PYO3_CROSS_PYTHON_VERSION") {
        if bridge == BridgeModel::Bin {
            bail!("You can't use PYO3_CROSS_PYTHON_VERSION with bin bindings");
        }

        let expr = Regex::new(r"(\d+).(\d+)").unwrap();
        let capture = expr
            .captures(&cross_python_version.to_string_lossy())
            .context(format!(
                "Invalid PYO3_CROSS_PYTHON_VERSION value (should be a version like 3.10): '{}'",
                cross_python_version.to_string_lossy()
            ));
        let context = "Expected a digit";
        let major = capture
            .get(1)
            .unwrap()
            .as_str()
            .parse::<usize>()
            .context(context)?;
        let minor = capture
            .get(2)
            .unwrap()
            .as_str()
            .parse::<usize>()
            .context(context)?;
    }

@messense
Copy link
Member Author

messense commented Mar 7, 2021

I have found that you can workaround it by using the same major & minor version of Python for build and target. Eg: rust-cross/manylinux-cross@ef575f9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants