-
Notifications
You must be signed in to change notification settings - Fork 136
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
Example program #64
Comments
rust-cpython currently only works on Linux and OSX. I don't know how to correctly link with the python DLL on Windows. |
With a quick google search I found this: For example I have Python 3.6 installed at With that in mind one can compile for Windows. Also dont forget that 32 bit pyd files would have to be named (since 3.5) Maybe it is possible to allow people who are using this crate to define it in their |
Another idea is to look for the python libs in |
Finding the .lib is not the problem. |
hmm |
See my previous comment in this thread. |
ok, I think I made a somewhat better rewrite on the build script: extern crate target_build_utils;
use std::env;
use std::io::Write;
use target_build_utils::TargetInfo;
const CFG_KEY: &'static str = "py_sys_config";
#[cfg(feature="python27-sys")]
const PYTHONSYS_ENV_VAR: &'static str = "DEP_PYTHON27_PYTHON_FLAGS";
#[cfg(feature="python3-sys")]
const PYTHONSYS_ENV_VAR: &'static str = "DEP_PYTHON3_PYTHON_FLAGS";
fn main() {
// python{27,3.x}-sys/build.rs passes python interpreter compile flags via
// environment variable (using the 'links' mechanism in the cargo.toml).
let flags = match env::var(PYTHONSYS_ENV_VAR) {
Ok(flags) => flags,
Err(_) => {
writeln!(std::io::stderr(),
"Environment variable {} not found - this is supposed to be \
exported from the pythonXX-sys dependency, so the build chain is broken",
PYTHONSYS_ENV_VAR).unwrap();
std::process::exit(1);
}
};
let target = TargetInfo::new().expect("could not get target");
if target.target_vendor() == "x86_64-pc-windows-msvc" {
// MSVC Building here.
// This is where I think __declspec(dllimport) can be defined.
}
if target.target_vendor() == "i686-pc-windows-msvc" {
// MSVC Building here.
// This is where I think __declspec(dllimport) can be defined.
}
if target.target_vendor() == "x86_64-pc-windows-gnu" {
// gnu Building here.
}
if target.target_vendor() == "i686-pc-windows-gnu" {
// gnu Building here.
}
if flags.len() > 0 {
for f in flags.split(",") {
// write out flags as --cfg so that the same #cfg blocks can be used
// in rust-cpython as in the -sys libs
let key_and_val: Vec<&str> = f.split("=").collect();
let key = key_and_val[0];
let val = key_and_val[1];
if key.starts_with("FLAG") {
println!("cargo:rustc-cfg={}=\"{}\"", CFG_KEY, &key[5..])
} else {
println!("cargo:rustc-cfg={}=\"{}_{}\"", CFG_KEY, &key[4..], val);
}
}
}
} With this it would mean also adding this to Cargo.toml: [build-dependencies]
target_build_utils = "*" edit: now I see this on issue: rust-lang/rust#27438 |
Linking on |
I'm running into trouble trying to get the first example program on this project's main page to work for me. It builds OK, but running it does nothing but crash. I don't even know where to begin troubleshooting this:
I think it is failing at
let sys = py.import("sys").unwrap();
because the result is identical when everything after that line is commented out.My environment:
Windows
Rust 1.12.1 gnu 32 bit
Python 3.4.4 32 bit
What could I be doing wrong?
The text was updated successfully, but these errors were encountered: