eager-dress-66405
01/31/2024, 12:21 PM$ python3 -m venv pextest
$ source ./pextest/bin/activate
(pextest) $ pip install pex
Successfully installed pex-2.1.161
(pextest) $ pex azure-core-tracing-opentelemetry
>>> from azure.core.tracing.ext.opentelemetry_span import OpenTelemetrySpan
Traceback (most recent call last):
File "<console>", line 1, in <module>
ModuleNotFoundError: No module named 'azure.core.tracing.ext.opentelemetry_span'
The same with just pip/venv:
$ python3 -m venv piptest
$ source ./piptest/bin/activate
(piptest) $ pip install azure-core-tracing-opentelemetry
Successfully installed azure-core-1.29.7 azure-core-tracing-opentelemetry-1.0.0b11 certifi-2023.11.17 charset-normalizer-3.3.2 deprecated-1.2.14 idna-3.6 importlib-metadata-6.11.0 opentelemetry-api-1.22.0 requests-2.31.0 six-1.16.0 typing-extensions-4.9.0 urllib3-2.2.0 wrapt-1.16.0 zipp-3.17.0
(piptest) $ python -c 'from azure.core.tracing.ext.opentelemetry_span import OpenTelemetrySpan'
(piptest) $ python
Python 3.9.7 (default, Nov 8 2021, 06:01:45)
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from azure.core.tracing.ext.opentelemetry_span import OpenTelemetrySpan
>>>
I think it might be something to do with a namespace conflict between the azure-core and azure-core-tracing-opentelemetry packages, but I don't see anything special about them. Any ideas or pointers?gorgeous-winter-99296
01/31/2024, 1:33 PM--venv --venv-site-packages-copies? Malformed namespace packages generally work better with those flags.gorgeous-winter-99296
01/31/2024, 1:36 PMpex will symlink together and make up a PYTHON_PATH to construct the full venv, but that might mean multiple PYTHON_PATH entries might contain azure. If that isn't a proper namespace package the interpreter will not search the later entries, so it becomes a bit random depending on path order etc. Those two args ensure that a full venv is constructed, and that the venv contains the full sources. That should merge the two source trees, which is what'd happen in a regular venveager-dress-66405
01/31/2024, 1:53 PMeager-dress-66405
01/31/2024, 1:55 PMpex_binary(
...
execution_mode="venv",
venv_site_packages_copies=True,
Is working as wellgorgeous-winter-99296
01/31/2024, 1:56 PMpython_test or python_source, which would also use pex. But they work slightly differently and are oftentimes more robust.eager-dress-66405
01/31/2024, 1:58 PMeager-dress-66405
01/31/2024, 2:00 PMgorgeous-winter-99296
01/31/2024, 2:05 PMazure.core.tracing in azure-core, and both core and tracing there contain an __init__.py. In general, you cannot nest a Python distribution inside another -- we're not even talking about namespace packages at this point. There should probably be an azure.ext.tracing with azure.ext being a namespace, that'd probably work.gorgeous-winter-99296
01/31/2024, 2:08 PMazure.core.tracing even refer to? And worse, who owns the files in azure.core.tracing? Etc.
I don't think with this setup where the assumption is to merge the filetrees that even a pkgutil-style source-tree would work, and I'm not sure if pex works with non-native namespaces either.
https://packaging.python.org/en/latest/guides/packaging-namespace-packages/ has a lot more info about the semantics of namespace packages.eager-dress-66405
01/31/2024, 2:20 PMvenv_site_packages_copies forevereager-dress-66405
01/31/2024, 2:20 PMflaky-artist-57016
05/17/2024, 3:50 AMfrom azure.eventhub.extensions.checkpointstoreblobaio import BlobCheckpointStore within a PEX. Using the execution_mode="venv" and venv_site_packages_copies=True arguments to pex_binary produces a working PEX. However, I am attempting to “zip-deploy” the PEX as an Azure Function and cannot get it to work (i.e., I must use execution_mode="zipapp" which means venv_site_packages_copies is ignored).
Any suggestions for how I might resolve this issue with the zipapp execution mode?