Hello :wave: I have a pexfile that works just fine...
# general
s
Hello 👋 I have a pexfile that works just fine when run from the
.pex
zip. When I try to compile the sources and dependencies as suggested here, I get collision errors. It's from a very old package that we should probably remove anyway (opencensus_proto, we've upgraded already but have some spillover) but I'd like to understand why it works from the pex and not when compiling. I see that the pex stores every installed wheel in a hash-named subdir, and the compilation builds the flatter site-packages hierarchy where the collision happens.
Copy code
/.kubetop/home/oscarutterback/.pex/unzipped_pexes/5c94fb6b53bf0ec0bafe16b0c0edfb7db9f8d3e8/.bootstrap/pex/venv/installer.py:242: 
\PEXWarning: Encountered collision populating /.kubetop/home/oscarutterback/dev/repo/_local_testing/pex/service_app 
from PEX at /.kubetop/home/oscarutterback/dev/repo/_local_testing/pex/./service_app.pex:

1. /.kubetop/home/oscarutterback/dev/repo/_local_testing/pex/service_app/lib/python3.9/site-packages/opencensus/__init__.py was provided by:
        sha1:ec78a390c93c5c48d752e66022b108cf1931be63 -> 
                /.kubetop/home/oscarutterback/.pex/installed_wheels/c3c8b8c5e6ecd143b1c21fba5e3150f2d5fbb656838a56a235ff245b4f905c5b/
                  opencensus_proto-0.1.0-py2.py3-none-any.whl/opencensus/__init__.py

        sha1:f295a836268415c05c405eba1421b35fd66336de -> 
        /.kubetop/home/oscarutterback/.pex/installed_wheels/35c8f739367175b4e4cc2ab1b92443ce0da0351bb8328167aad6647539753d1b/
          opencensus-0.11.3-py2.py3-none-any.whl/opencensus/__init__.py, 
        /.kubetop/home/oscarutterback/.pex/installed_wheels/7f57e74a19a8d1991236dae4169c5544958325d8c262a0e82089e2765f683c23/
          opencensus_context-0.1.3-py2.py3-none-any.whl/opencensus/__init__.py
This is the specific collision
We should probably just remove opencensus, but that's a bigger task I can't just start with.
I suppose this specific collision might just go unnoticed and that's why it appears to work, but that's more of a guess from my end
f
So
opencensus_proto
and
opencensus
are both providing a top-level
opencensus/__init__.py
file?
Is
opencensus
configured as a namespace package?
The modern Python way to do it is to just omit a top-level
__init__.py
like
opencensus/__init__.py
for namespace packages.
If upgrading or omitting
opencensus_proto
solves the issue, then seems easy to resolve.