Skip to content
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

Can zippos solve these 2 issues #12

Closed
sdementen opened this issue Feb 12, 2022 · 6 comments
Closed

Can zippos solve these 2 issues #12

sdementen opened this issue Feb 12, 2022 · 6 comments

Comments

@sdementen
Copy link

I have two issues with shiv
linkedin/shiv#209
linkedin/shiv#208
Does zipapps support these functionalities?

@ClericPy
Copy link
Owner

ClericPy commented Feb 13, 2022

Allow shebang with %ENVIRONMENT VARIABLES% in it

  1. As we known, both shiv and zipapps support the usage like python3 app.pyz, you don't really need shebang.

Slow run when large pyz file

  1. One change of zipapps to shiv is to not unzip unless necessary

    1. The decompression behavior is only for the dynamic modules requirements (.pyd/.so, which written by C such as the scipy lib)
      1. Other requirements will not need to be decompressed because of the built-in zipimport feature.
  2. To reduce decompression time, you can remove -c arg so it only be a archive zip file without compression

    1. But its file size will increase

@ClericPy
Copy link
Owner

To reduce decompression time, my often ways:

  1. Use the layer mode on Serverless environment
  2. Use the venv which has installed all the requirements.txt
  3. Dump venv with zipapps
    1. python3 -m zipapps -r requirements.txt -o venv.pyz
    2. python3 -m zipapps -a your_code.py -m your_code.main -o app.pyz
    3. Run
      1. python3 venv.pyz app.pyz
    4. Then only upload the new app.pyz but keep the venv.pyz unchanged.

Separation of code and dependencies is a more feasible way, such as python3 -m venv venv, or pip install xxx -t ./requirements with export PYTHONPATH=./requirements

@sdementen
Copy link
Author

Thank you for your answers!
Within the lines, I understand zipapps core use case is easing the deployment on serverless environment. The use case for which I use shiv is for deployment of desktop applications on Windows machines.

1 similar comment
@sdementen
Copy link
Author

Thank you for your answers!
Within the lines, I understand zipapps core use case is easing the deployment on serverless environment. The use case for which I use shiv is for deployment of desktop applications on Windows machines.

@ClericPy
Copy link
Owner

zipapps and shiv has the same purpose, Serverless is only an example to tell the Separation of code and dependencies

My windows distribution choice is nuitka with pip install xxx -t app.dist and --nofollow-imports, or zipapps with delay install mode.

@sdementen
Copy link
Author

I have clarifier the use case for the shebang in the original issue

I am using the shebang to specify the specific version of the intepreter to be used (3.8, 3.9, ...) knowing that the user's laptop that will run the pyz have the different versions installed as "%USERPROFILE%\AppData\Local\Programs\Python\PythonNN".
Hence I would need the shebang line to accept the environment variable USERPROFILE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants