rattler
rattler copied to clipboard
Either compile all `pyc` files or automatically remove them
I have a situation with pixi where the missing pyc compilation is a problem and finally debugged it.
When updating the lockfile for jupyterlab (with pixi) it installs isoduration. When reinstalling the old lockfile later it removes isoduration but leaves the pyc files as well as the folder structure (since the pyc files are not deleted).
Now, when starting jupyterlab the import isoduration still "works" (doesn't throw an ImportError) but when accessing any object in it it fails with an AttributeError, e.g.:
╭─ pixi ~/Programs/pixi/examples/jupyterlab ‹fix/print_run_arguments●›
╰─$ cargo r -- run start --help 2 ↵
Finished dev [unoptimized + debuginfo] target(s) in 0.18s
Running `/Users/wolfv/Programs/pixi/target/debug/pixi run start --help`
✨ Pixi task: jupyter lab --help
Traceback (most recent call last):
File "/Users/wolfv/Programs/pixi/examples/jupyterlab/.pixi/env/bin/jupyter-lab", line 6, in <module>
from jupyterlab.labapp import main
File "/Users/wolfv/Programs/pixi/examples/jupyterlab/.pixi/env/lib/python3.11/site-packages/jupyterlab/__init__.py", line 8, in <module>
from .handlers.announcements import (
File "/Users/wolfv/Programs/pixi/examples/jupyterlab/.pixi/env/lib/python3.11/site-packages/jupyterlab/handlers/announcements.py", line 14, in <module>
from jupyter_server.base.handlers import APIHandler
File "/Users/wolfv/Programs/pixi/examples/jupyterlab/.pixi/env/lib/python3.11/site-packages/jupyter_server/base/handlers.py", line 23, in <module>
from jupyter_events import EventLogger
File "/Users/wolfv/Programs/pixi/examples/jupyterlab/.pixi/env/lib/python3.11/site-packages/jupyter_events/__init__.py", line 3, in <module>
from .logger import EVENTS_METADATA_VERSION, EventLogger
File "/Users/wolfv/Programs/pixi/examples/jupyterlab/.pixi/env/lib/python3.11/site-packages/jupyter_events/logger.py", line 13, in <module>
from jsonschema import ValidationError
File "/Users/wolfv/Programs/pixi/examples/jupyterlab/.pixi/env/lib/python3.11/site-packages/jsonschema/__init__.py", line 13, in <module>
from jsonschema._format import FormatChecker
File "/Users/wolfv/Programs/pixi/examples/jupyterlab/.pixi/env/lib/python3.11/site-packages/jsonschema/_format.py", line 503, in <module>
raises=isoduration.DurationParsingException,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'isoduration' has no attribute 'DurationParsingException'
Then I usually do a rm -rf of the .pixi folder but it would be much nicer if we never run into this error.
With https://github.com/mamba-org/rattler/pull/437 we at least remove them.
I do think that it would be better to compile the pyc when installing because I do notice relatively slow startup times on macOS and I think in part it's because it still needs to compile the pyc files.
It is also nice to track the pyc files in the conda-meta folder.
Lastly, we do have the code to do this in rip so I think it should be relatively straightforward.