3 ms·
Zipapp doesn't support c extensions though? And that is a large chunk of libraries that I use.
by totalperspectiv 6y ago
Zipapp doesn't support c extensions though? And that is a large chunk of libraries that I use.
- BiteCode_dev 6y agoIt does, if your extensions are provided as wheels. In which case the resulting pyz file will be runnable on any machine using the OS those wheels are compiled for. Let's try an example with numpy: $ py -m venv foo $ foo\Scripts\activate $ pip install numpy $ code hello_numpy.py # import numpy as np # def main(): # print(np.arange(15).reshape(3, 5)) $ python hello_numpy.py [[ 0 1 2 3 4] [ 5 6 7 8 9] [10 11 12 13 14]] Now with shiv: $ copy hello_numpy.py foo\Lib\site-packages $ shiv -e hello_numpy.main --site-packages test\Lib\site-packages\ -o hello_numpy.pyz $ python hello_numpy.pyz [[ 0 1 2 3 4] [ 5 6 7 8 9] [10 11 12 13 14]] So it works fine, but remember: - it will only run on the system this particular numpy wheel has been designed to run on. In my case cp38-win_amd64. - it will comes bundle with numpy. Numpy is quite big, which means your hello world pyz will be 14.1 Mo. - it needs to unzip, so the first run will be slow
- potatochup 6y agoYeah, Shivs work ok. I've run into some stupid issues with the self-extracting directory being have too long path names on Windows and such, so it's not perfect.