-
-
Notifications
You must be signed in to change notification settings - Fork 236
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
Method for building Rust projects with a simple cargo build
#498
Comments
Oooh - this is really clever and the first potential solution for making Correct me if I'm wrong, but isn't a drawback of using Also, the PyO3 maintainers have been very generous in implementing features upstream to accommodate PyOxidizer's use cases. But if I were a PyO3 maintainer, I'd be highly skeptical of teaching the canonical Thank you again for contributing this. This looks like a great idea! |
According to this, crates.io ignores I think a better solution will require This dependency could be PyOxidizer-specific, which would be very similar to the build script above, and require the user to either run Alternatively, the dependency can be very generic, with the published version just being a no-op. The user could then patch it to supply custom config file generation logic, which may or may not depend on PyOxidizer. I'm thinking something like this being added to
|
Also, what are the advantages of using |
My goal was to build a Rust project that embeds python and all dependencies via a simple
cargo build
. I finally figured out a method for doing this, but it's pretty much one big hack. Nevertheless, it may be helpful to others and could guide future development.The problem with the project structure created by
pyoxidizer init-rust-project
is that thepyo3-build-config
dependency needsPYO3_CONFIG_FILE
to point topyo3-build-config-file.txt
, which is generated bypyoxidizer run-build-script
. As a result, the only way to get a working build is to generate the artifacts first and then pass the relevant environment variables tocargo build
, as described in #467. Running the generatedbuild.rs
inbuild-mode-pyoxidizer-exe
mode does not work since all thepyo3
dependencies are already built by that point using the default configuration.A way to get everything to work with a one
cargo build
command is to havepyo3-build-config
runpyoxidizer run-build-script
directly. I used a [patch] override to do that. Essentially, I created my ownpyo3-build-config
package that runspyoxidizer
. It depends on the realpyo3-build-config
to avoid re-implementing most of the functionality.Below are the relevant file contents. I've omitted
./py/pyoxidizer.bzl
and other files generated bypyoxidizer init-rust-project
because those are all standard. Use at your own risk.Note that this still does not solve #466.
./Cargo.toml
:./py/Cargo.toml
:./py/build.rs
:./py/pyo3-build-config/Cargo.toml
:./py/pyo3-build-config/build.rs
:./py/pyo3-build-config/src/lib.rs
:The text was updated successfully, but these errors were encountered: