Closed Bug 1696346 Opened 3 years ago Closed 3 years ago

Explicitly set `zip_safe` to `False` to prevent unpredictable behaviour when installing

Categories

(Conduit :: moz-phab, defect, P2)

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: glandium, Assigned: zeid)

References

Details

(Keywords: conduit-triaged)

Attachments

(1 file)

I'm not sure under what circumstances it happens, but at least on my M1 mac, installing via python3 setup.py install --user installs the MozPhab egg as a zip, and when that's the case, loading pings.yaml fails with:

Traceback (most recent call last):
  File "..//Library/Python/3.8/bin/moz-phab", line 11, in <module>
    load_entry_point('MozPhab==0.1.95', 'console_scripts', 'moz-phab')()
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2852, in load_entry_point
    return ep.load()
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2443, in load
    return self.resolve()
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2449, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 618, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "/Users/glandium/Library/Python/3.8/lib/python/site-packages/MozPhab-0.1.95-py3.8.egg/mozphab/mozphab.py", line 20, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 618, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "/Users/glandium/Library/Python/3.8/lib/python/site-packages/MozPhab-0.1.95-py3.8.egg/mozphab/args.py", line 14, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 618, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "/Users/glandium/Library/Python/3.8/lib/python/site-packages/MozPhab-0.1.95-py3.8.egg/mozphab/detect_repository.py", line 8, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 618, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "/Users/glandium/Library/Python/3.8/lib/python/site-packages/MozPhab-0.1.95-py3.8.egg/mozphab/git.py", line 24, in <module>
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 618, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "/Users/glandium/Library/Python/3.8/lib/python/site-packages/MozPhab-0.1.95-py3.8.egg/mozphab/telemetry.py", line 173, in <module>
  File "/Users/glandium/Library/Python/3.8/lib/python/site-packages/MozPhab-0.1.95-py3.8.egg/mozphab/telemetry.py", line 45, in __init__
  File "/Users/glandium/Library/Python/3.8/lib/python/site-packages/glean/_loader.py", line 202, in load_pings
    metrics = load_metrics(filepath, config)
  File "/Users/glandium/Library/Python/3.8/lib/python/site-packages/glean/_loader.py", line 162, in load_metrics
    raise ValueError("\n\n".join(errors))
ValueError: /Users/glandium/Library/Python/3.8/lib/python/site-packages/MozPhab-0.1.95-py3.8.egg/mozphab/pings.yaml:
    [Errno 20] Not a directory:
    '/Users/glandium/Library/Python/3.8/lib/python/site-
    packages/MozPhab-0.1.95-py3.8.egg/mozphab/pings.yaml'

(and since the .egg is a zip, the file doesn't exist. It exists inside the zip)

Assignee: nobody → zeid

Can you paste the complete output of python3 setup.py install --user? Specifically, bdist_egg should be able to analyze that the the package shouldn't be zip safe (as it contains data files), but perhaps this behaviour is different on your machine.

Can you manually add zip_safe=False to setup() and see if it works? I'm not able to reproduce this issue, as MozPhab-0.1.95-py3.8.egg is a directory that contains mozphab/pings.yaml on my machine.

Flags: needinfo?(mh+mozilla)

Yes, adding zip_safe=False fixes it.

Flags: needinfo?(mh+mozilla)
Keywords: conduit-triaged
Priority: -- → P2
Summary: moz-phab doesn't work when MozPhab egg is in a zip → Explicitly set `zip_safe` to `False` to prevent unpredictable behaviour when installing
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
See Also: → 1698922
Blocks: 1699704
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: