How to set import path of a zipapp in Python?

289 views Asked by At

I want to distribute a python app and let user start it with one-click. But even I add path included all depended packages in the app, it will not work unless I move the packages to the top level.

The structure works

app.zip
├── __main__.py
├── lib2
├── lib1
    ├── lib_file1
    │── lib_file2

The structure not works

app.zip
├── __main__.py
├──lib
    ├── lib_file
    ├── site-packages
        ├── lib1
        │── lib2

Even I add lib folder into sys.path.

sys.path.extend(
    [os.path.join(BASE_DIR, "../" + p) for p in lib_path],
)

I create the zip app following zipapp doc, and just want to include all libs so that the app will work even on a PC without python installed.

What should I do to make a all-in-one zip app?

0

There are 0 answers