PyOxidizer
PyOxidizer copied to clipboard
Add examples to documentation
First of all, congrats on your project, looks promising.
However, as some have pointed out, there are a TON of libraries for packaging python projects (none ideal as you point out).
I have used a bunch of them, and always, always, there is a lack of real example applications. Usually docs go like this:
Step 1: run packager create app
Step 2: here are all the crazy settings you can set!
That means its very hard for someone without in depth knowledge of packaging/binaries/links etcetera to even start using the packaging tools.
It would be awesome if you could create a repo with examples. Real examples like, i want to create an app that opens a gooey interface that loads a pandas dataframe and a pickle scikit learn model and creates predictions on arbitrary user submitted data
.
And I know, why dont i do it? because i have checked your docs and i honestly dont know how i would even start!
An example on how to load the print("hello world") from a local .py file instead of the eval code mode, including where it needs to be in the structure to be bundled properly would be extremely helpful.
Update: In case this help anyone else trying to do this, I managed to get this working.
Steps: 1: Create a "mypackage" folder in the "pyapp\src" folder to store your .py files.
2: Create an app.py file.
src\mypackage\app.py contents
print("Hello World")
3: Update pyoxidizer's configuration to load and execute this.
pyoxidizer.toml contents
[[packaging_rule]]
type = "package-root"
path = "src/mypackage"
packages = ["app"]
[[embedded_python_run]]
mode = "module"
module = "app"
(or alternatively you can use)
mode = "eval"
code = "import app;"
4: pyoxidizer run
Note 1: This method doesn't seem to automatically detect changes to the .py file when a recompile is needed for either pyoxidizer build or pyoxidizer run but you can force it by making a change to the pyoxidizer.toml file.
Note 2: I'm still trying to work out how paths and embedding for pip installed modules work since some are hit or miss. for me, so an example with something like Flask or Quart would be great.
thanks for that @McSpidey , something like your comment would be super helpful in the docs :)
@McSpidey Thanks for straightforward tutorial, but I try it on a PyQT5 application project,it successfully builds binary application, but no GUI pop up when running it , but enter REPL instead. Do you have any idea?
Sorry, I'm not sure yet how to get full apps building with complex imports yet. I have a feeling the trick is going to be in how all the libraries and their dependeicies are managed in combination with the [[packaging_rule]] configs that include them.
Agree - need an examples folder, or a description in the docs of how to use this for something non-trivial.
An example of how to to use a virtual environment would also be incredibly helpful.
I would really love an example of how to pull in a package like numpy or pandas. I have stared at the documentation and tried every method I can think of and absolutely can not get it to work. It appears as if I packaged it, but fails on every import
same here @QuantumChamploo , most packaging tools fail to document complex dependencies.
@McSpidey Thanks for straightforward tutorial, but I try it on a PyQT5 application project,it successfully builds binary application, but no GUI pop up when running it , but enter REPL instead. Do you have any idea?
did you change the '[[embedded_python_run]] mode = "module" module = "test"'
part to point at your main file?
Also could you post your pyoxidizer.toml file for your QT5 project to see what you had in the packaging rules? I also have a PyQT5 project that has 15 or so modules I have written plus 2 folders with ini type files and UI files plus a folder to receive files created by the project and I have yet to see a way to add folders.
I constructed a couple of small examples after playing with this tool a bit today. See these two commits: https://github.com/gnprice/hello-pyoxidizer/commit/66071d04435d03cdd1490c617d82c0e167d478c1 https://github.com/gnprice/hello-pyoxidizer/commit/26b8d3fed46e3207d3899211a7299d9ab5764a00 and a bit more description at https://github.com/indygreg/PyOxidizer/issues/78#issuecomment-511657412 .
The first one is a lot like @McSpidey's helpful instructions above. The second one adds a dependency via pip
.
I agree with everyone here that it'd be helpful to have examples like these in the docs! I'm wrapping up for the evening, and may not come back to this to turn this material into a docs PR. Please feel free (everyone) to borrow anything from my examples that's useful in sending PRs for the docs.
This method doesn't seem to automatically detect changes to the .py file when a recompile is needed for either pyoxidizer build or pyoxidizer run but you can force it by making a change to the pyoxidizer.toml file.
(BTW someone's now reported this one as #72 . More workaround info there, and hopefully also it'll get fixed before long.)
I would really love an example of how to pull in a package like numpy or pandas. I have stared at the documentation and tried every method I can think of and absolutely can not get it to work. It appears as if I packaged it, but fails on every import
@QuantumChamploo ~~I'd recommend you file an issue for that specifically~~ -- that'll give you room to paste details of exactly what you've tried and what the error looks like. There will be a lot of people who'd like to import numpy and pandas, so I think the issue thread will be quite useful. [EDIT: In fact there's an issue for numpy already: #65. So, take a look there.]
It's been a while! As a new prospective user, I think this issue should be on your radar, @indygreg.