indygreg / PyOxidizer

A modern Python application packaging and distribution tool
Mozilla Public License 2.0
5.49k stars 239 forks source link

How to set the output path for building? #495

Open sureshjoshi opened 2 years ago

sureshjoshi commented 2 years ago

I'm working on creating a basic pyoxidizer plugin for Pants (https://github.com/sureshjoshi/pants-pyoxidizer-plugin/) - and it's starting to work, however I cannot get the final binary to a useful directory, and then it's evicted from my Mac.

I'm investigating, but I believe Pants uses some tmp process-execution directories, which are immediately deleted. PyOxidizer appears to only build to relative locations. e.g.

/private/var/folders/18/q1r7phps28nc9rx5j_0t3jmm0000gp/T/process-executiongGTfnJ/./build/x86_64-apple-darwin/debug/exe/helloworld-bin

Is there any way to set the binary's output path to an absolute location?

I tried the OUT_DIR environment variable, but setting that before calling PyOxidizer doesn't appear to do anything.

jtk18 commented 2 years ago

I'm trying to figure out the same thing. I tried CARGO_TARGET_DIR and passing --var target-dir and neither worked.

Anyone have the secret to building elsewhere than tmp?

indygreg commented 2 years ago

There's a Starlark function for controlling the output directory (https://pyoxidizer.readthedocs.io/en/stable/pyoxidizer_config_global_state.html#starlark_pyoxidizer.set_build_path) but no way to set that directory from the command line invocation.

Scripting use cases warrant a mechanism to set the output directory and this is a viable feature request.

dae commented 2 years ago

This is what I use, along with --var build /path/to/folder:

set_build_path(VARS.get("build"))