Hey, friends! I’m having some issues with third-pa...
# general
b
Hey, friends! I’m having some issues with third-party submodules not being found on the import path. My current
pex_binary
has a few packages that share the same namespace: •
merlin
:
import merlin.core
merlin-models
:
import merlin.models
However, after building the PEX with these two packages, I’m unable to import
merlin.models
I have tested with pex directly and noticed that depending on the order, I’m able to import the submodule
Copy code
$ pex --lock default.lock merlin-models merlin 
>>> import merlin.models # works

$ pex --lock default.lock merlin merlin-models
>>> import merlin.models # doesn't work
By checking the sys.path during PEX execution, I notice that indeed when
merlin
seems to be coming before
merlin-models
, which might explain the issue. Has anyone faced this issue before?
1
b
Are they correctly labeled as "namespace packages"? https://packaging.python.org/en/latest/guides/packaging-namespace-packages/
b
That’s a great question. If my understanding is correct from the link you sent, they should be considered namespace packages “implicitly”, given that they don’t have init files under the main namespace folder: merlin-core and merlin-models
b
Merlin definitely has an `__init__.py`: Download the wheel: https://pypi.org/project/merlin/#files
b
hmmm, that’s true! Just noticed that merlin itself was a package beyond the merlin-core. Inspecting the sys.path of my PEX, they do appear there:
Copy code
merlin-1.11.0-py3-none-any.whl
merlin_models-23.8.0-py3-none-any.whl
merlin_core-23.8.0-py3-none-any.whl
merlin_dataloader-23.8.0-py3-none-any.whl
b
Might want to file an issue to
merlin
project?
In the meantime, try building a "venv" PEX. Then all the packages are installed in a single venv, which should side-step this issue
b
actually, I think I might have found a problem here. Apparently the merlin package available on pypi has nothing to do with the nvidia’s set of packages (merlin-core, merlin-models, merlin-dataloader). It might have been accidently added there. I’ll try to remove that and see if things work as expected
b
Guess he's a popular guy 🙂
b
that was indeed the issue this is fine fire
naming is hard hahahah
h
🤯