Nuitka / Nuitka

Nuitka is a Python compiler written in Python. It's fully compatible with Python 2.6, 2.7, 3.4-3.12. You feed it your Python app, it does a lot of clever things, and spits out an executable or extension module.
http://nuitka.net
Apache License 2.0
11.8k stars 639 forks source link

More flexible location arguments for output #3128

Open giokara-oqton opened 5 days ago

giokara-oqton commented 5 days ago

We are using Nuitka within the Bazel ecosystem. See a very basic example in https://github.com/giokara-oqton/nuitka-under-bazel. Bazel by default works with sandboxed environments and has a strict interpretation of where output files are written. The way that Nuitka allows to define where outputs are generated are not completely compatible with Bazel.

Of course this can be easily (or less easily) be circumvented by writing custom scripting in Bazel around the actual Nuitka call. Therefore this is more meant as a niche user feedback with the hope of ever getting one of below features to more flexibly deal with this issue in Bazel:

kayhayen commented 16 hours ago

You are misunderstanding the purpose of --output-filename, which you are not supposed to use unless you have specific needs.

This is its description:

Specify how the executable should be named. For extension modules there is no
choice, also not for standalone mode and using it will be an error. This may
include path information that needs to exist though.

As Python has a fixed idea of what extension modules must be called, there is not as much flexibility. And also, this influences the name inside of the standalone distribution, but not the folder name, but the onefile binary name, if used. It's complicated.

This is why Nuitka goes with specifying an output folder and applying defaults for the filenames (unless legally overridden) and I do not really fancy adding onefile specific behaviour of --output-filename which then must know how to interact with --output-dir. Maybe if the temporary directories were split into a separate option.

Plugins can do post-processing with various stages. Using onFinalResult means you get the path produced in whatever mode, and Nuitka is not going to do much more than reporting and running it if asked.

This is terribly complex stuff and I do not see myself touching it in the near future myself. But if somebody were to make all use cases continue to work well, catch all the possible user errors with the new behaviour, I would be fine, but I don't see it happening.