red-jackal-13334
04/23/2020, 10:35 AMhappy-kitchen-89482
04/26/2020, 7:36 PMhappy-kitchen-89482
04/26/2020, 7:40 PMhappy-kitchen-89482
04/26/2020, 7:40 PMhappy-kitchen-89482
04/26/2020, 7:47 PMpex azure-common setuptools -o az
works (you can run ./az
and then import azure.common
. But even pex azure-cli azure-common setuptools -o az
) does not.happy-kitchen-89482
04/26/2020, 10:07 PMazure
packages.happy-kitchen-89482
04/26/2020, 10:11 PMazure
has subpackages in many distributions (azure.common
, azure.cli
, azure.mgmt
and so on).happy-kitchen-89482
04/26/2020, 10:12 PMhappy-kitchen-89482
04/26/2020, 10:13 PMazure/__init__.py
file, so I assume the intention is that azure
should be a native namespace package (as described at that link).happy-kitchen-89482
04/26/2020, 10:16 PMazure/__init__.py
(azure-cli-telemetry, azure-cli-core, azure-multiapi-storage, azure-cli, azure_cosmos) and unfortunately those __init__.py
files contain pkg_resources-style namespace package invocations, which are not compatible with native namespace packages.happy-kitchen-89482
04/26/2020, 10:16 PMazure
are fundamentally brokenhappy-kitchen-89482
04/26/2020, 10:19 PMpip
, but not via pex. maybe some bad luck around ordering of imports during bootstrapping or something.happy-kitchen-89482
04/26/2020, 10:21 PMhappy-kitchen-89482
04/26/2020, 10:21 PMazure
itself is broken, even if it somehow happens to work in practice in some cases.happy-kitchen-89482
04/26/2020, 10:22 PMhappy-kitchen-89482
04/26/2020, 10:23 PMhappy-kitchen-89482
04/26/2020, 10:24 PMenough-analyst-54434
05/04/2020, 4:22 PMazure/_init_.py
is layed down by one of these:
$ zipinfo -1 az | grep /azure/__init__.py | while read path; do echo -e "> In $path:\n===\n$(unzip -qc az $path | grep -E -v "^#")\n==="; done
> In .deps/azure_cli-2.5.1-py3-none-any.whl/azure/__init__.py:
===
import pkg_resources
pkg_resources.declare_namespace(__name__)
===
> In .deps/azure_cli_core-2.5.1-py3-none-any.whl/azure/__init__.py:
===
import pkg_resources
pkg_resources.declare_namespace(__name__)
===
> In .deps/azure_cli_telemetry-1.0.4-py2.py3-none-any.whl/azure/__init__.py:
===
import pkg_resources
pkg_resources.declare_namespace(__name__)
===
> In .deps/azure_cosmos-3.1.2-py3-none-any.whl/azure/__init__.py:
===
__import__('pkg_resources').declare_namespace(__name__)
===
> In .deps/azure_multiapi_storage-0.3.1-py2.py3-none-any.whl/azure/__init__.py:
===
__import__('pkg_resources').declare_namespace(__name__)
===
In a pex, each dependency is installed in its own isolated chroot. As such azure-common gets no help from any of the distributuions above and does not have an azure/_init_.py
file and so its azure/common
contents cannot be found by any load sequence that imports azure/*
via a pkg_resources namespace.
So, that's the reason for the difference. Pip does mask bad namespace package hygiene as @happy-kitchen-89482 suggested.
As for a fix for Pex for this sort of problem that does not break multiplatform PEXes (these are the reason for the isolated dependency chroots) ... it's not immediately clear to me what the best approach is.enough-analyst-54434
05/04/2020, 8:08 PM--unzip
option added recently and have PEXes execute as ~normal venv-style applications: https://github.com/pantsbuild/pex/issues/962