indygreg / indygreg/PyOxidizer
[newbie] how to build single python file into exe
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 6.2k
- Forks
- 256
- PR merge metrics
- No merged PRs in 30d
Description
Hi, new user here. In any normal to larger project I'm involved in I'm a big fan of structured packages and using a `__main__.py` file to define entry etc, pyixidiser has been very easy for me to start using here, eg:
```
default_python_distribution(flavor="standalone_static")
...
exe.add_python_resources(exe.read_package_root(
path=".",
packages=["remove_old_drivers"],
))
```
However, far more regularly, I want to whip up a quick script -> exe to give to someone to fix a little parsing/ data analysis question, etc. These are typically a single file python script with a couple hundred lines of code at most.
Is there a way to use pyoxidizer to quickly build these single file scripts into a single file exe, without needing to write them into a folder/package instead? Ideally I'd like to have just the `pyoxidizer.bzl` file and python script sitting next to one another in a git repo with build script.
I've tried a few things like:
```
exe.add_python_resources([exe.make_python_module_source(
name="remove_old_drivers",
source="remove_old_drivers.py",
is_package=False
)])
```
But anything like this seems to not copy the python file itself into the build folder.
Is this usage documented somewhere I haven't found? Or can you suggest a easy to configure it?
Thanks, Andrew
PS. I've only just found your project and I absolutely love it, you've done an amazing job here. It looks like it definitely solves many python packaging/distributing problems I've had over the years, so thanks!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the pyoxidizer.bzl configuration and the existing default_python_distribution, add_python_resources, and make_python_module_source examples in the issue. Verify the result by building remove_old_drivers.py as a single executable while keeping the script and configuration side by side, without requiring a package directory.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100