-
Notifications
You must be signed in to change notification settings - Fork 628
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
Suggestion: uv bundle
, uv build --release
or similar to create a contained executable a la pyinstaller, py2exe
#5802
Comments
uv bundle
or similar to create a contained executable a la pyinstaller, py2exeuv bundle
, uv build --release
or similar to create a contained executable a la pyinstaller, py2exe
Some relevant links that I'm adding to keep track of them for myself as much as anyone else:
|
To add… despite its popularity, |
Python to Rust transpilation would be pretty cool and there’s at least one project out there working on this: Imagine writing idiomatic Python, transpiling it to Rust and compiling a native executable. My mind would be blown. I don’t know how one could gracefully handle dependencies though. A lot of Python libs incorporate C extensions. Dealing with those would be extremely difficult, but there’s a DARPA program called TRACTOR working on that. |
An equivalent of (somewhat related: #5653) |
I want to give a mention to Nuitka which is serving me well. It's as straightforward as running
which spits out an executable. It's not really the right tool to be including with uv, it is essentially an alternate Python interpreter which compiles Python to C. But it's very easy to add and has worked well for me. And my experience with the developers has been very good. They were quick to add support for Rye when I encountered bugs - Nuitka/Nuitka#2933 |
@my1e5 why do you say that Nuitka would be unsuitable for inclusion with uv? |
@matterhorn103, I guess what I mean is that Nuitka is perhaps quite an opinionated way of packaging your Python code into an executable - as it is essentially an alternate Python interpreter which compiles Python to C. Whereas tools like Pyinstaller are more like a bundler - taking the Python interpreter, Python files and dependencies and packaging them into an executable. This is definitely more straightforward than the Nuitka approach, but it does make the Pyinstaller executable very easy to un-package and see the underlying source code (see https://github.com/extremecoders-re/pyinstxtractor). Which might be a caveat needed when including certain 'executable creators' within uv - you need to make users aware that their exe can easily be un-packaged. In terms of licensing, Nuitka is MIT licensed. But it does also have a commercial tier - which may or may not complicate matters if Astral were to want to bundle it with uv, I don't know. |
I think this is a duplicate of #2799, though there's more discussion here. |
Also want to call out pex, a tool for generating .pex files (Python EXecutable) which are self-contained zipped executable Python environments containing sources, requirements, and dependencies. |
I regularly use pyinstaller for a project, and the frequency of questions about it - or the task more generally of "compiling" an executable for distribution - around the web indicates to me that it's widely popular.
It would be incredibly cool if uv offered a
uv bundle
command (or whatever name) that essentially did what pyinstaller does and bundles together everything to afford an executable that contains the dependencies and interpreter and can be distributed to users as-is. And I think this falls into the realm of what things a "Cargo for Python" might be expected to be able to do.I assume that pyinstaller, py2exe etc. are complex projects and implementing such functionality would be not trivial in the slightest, so I would have thought it would be a case of using
pyinstaller
itself in the background like the way that build backends are used.Presumably there will one day be a
uv build
command but I assume that will be similar torye build
in that it will create an sdist or wheel. Maybe there could be auv build --executable
option, oruv build --release
(by analogy tocargo build --release
)?The text was updated successfully, but these errors were encountered: