Open hrist0stoichev opened 1 year ago
Can you solve this by using a custom slim pattern to remove the .py files?
No, it is a 2 step process
.py
files.pyc
files from __pycache__
to the parent directory.The 2nd step is currently not achievable.
Ah thanks @hrist0stoichev - perhaps there is a way to hook into the packaging, I may also try to provide a custom built artifact. I'm noticing ~3 seconds of START_INIT time on cold boot, and my only direct dependency is prefect
- if I managed to get this working, will it remove that time (which I assume was being used to compile?)
I doubt compiling takes that long in your case. You can try creating an import profile with https://github.com/nschloe/tuna and see where you spend the majority of time.
is there any way, currently, to intercept or hook into the requirements installation to do this in userland?
Only way I can think of doing this right now is to build + deploy the package in two separate steps, and before deploying unzip the package, modify as needed (generate .pyc
files, remove .py
files) and then zip up again
🤔
Is there an existing issue for this?
Use case description
Right now
slim: true
will remove all.pyc
and.pyo
files but those are actually more useful than.py
files for 2 main reasons:.py
files.Going even deeper, the
-OO
flag can be used so that.pyo
files are even smaller.Proposed solution (optional)
On this flow chart you can see how the python lookup-mechanism works.
So, the easiest solution would be to just replace all
.py
files with their.py[c|o]
counterparts coming from__pycache__
.