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

Must provide PYO3_CROSS_LIB_DIR environment variable #1606

Closed
jdaruja opened this issue May 14, 2021 · 1 comment
Closed

Must provide PYO3_CROSS_LIB_DIR environment variable #1606

jdaruja opened this issue May 14, 2021 · 1 comment

Comments

@jdaruja
Copy link

jdaruja commented May 14, 2021

🐛 Bug Reports

When reporting a bug, please provide the following information. If this is not a bug report you can just discard this template.

🌍 Environment

  • Your operating system and version: Unbuntu 20.4
  • Your python version: 3.8
  • How did you install python (e.g. apt or pyenv)? Did you use a virtualenv?: apt / virtualenv- yes
  • Your Rust version (rustc --version):1.51.0
  • Your PyO3 version: 0.13.2
  • Have you tried using latest PyO3 main (replace version = "0.x.y" with git = "https://github.com/PyO3/pyo3")?: yes

💥 Reproducing

lib.rs

use pyo3::prelude::;
use pyo3::wrap_pyfunction;
use std::fs::File;
use std::io::prelude::
;
use std::path::Path;

#[allow(unused_parens)]
#[pyfunction]
/// Returns the file
fn return_file(a: String) -> PyResult {
let mut f = File::open(a)?;
let mut contents = String::new();
f.read_to_string(&mut contents)?;
Ok((contents))
}

/// This module is a python module implemented in Rust.
///
#[pymodule]
fn cross_compile(py: Python, m: &PyModule) -> PyResult<()> {
m.add_wrapped(wrap_pyfunction!(return_file))?;
Ok(())
}


When I cross build using - cross-rs/cross#556 instructions (Embedded/Rust)
after setting environment variable "PYO3_CROSS_LIB_DIR" using export PYO3_CROSS_LIB_DIR = "/usr/lib".
using command

$ cross build --target aarch64-unknown-linux-gnu

I am getting below error -

Error: "Must provide PYO3_CROSS_LIB_DIR environment variable when cross-compiling"

When I run $ echo $PYO3_CROSS_LIB_DIR, it shows /usr/lib.

Please help

@davidhewitt
Copy link
Member

Thanks for the question @jdaruja .

cross runs compilation inside a Docker container. To pass environment variables to the compilation you must follow the instructions at https://github.com/rust-embedded/cross#passing-environment-variables-into-the-build-environment

e.g. add this to your Cross.toml:

[build.env]
passthrough = [
    "PYO3_CROSS_LIB_DIR",
]

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

No branches or pull requests

2 participants