Having issue with pip packages that share a namespace not being installed correctly when using pipapi as described here. For example, azure packages get installed into a azure namespace. If I install multiple packages, e.g. azure-storage-blob and azure-data-tables, only the first one gets installed.
Reproduction steps:
- add the following pip dependancies to extension.toml:
[python.pipapi]
use_online_index = true
requirements = [
"azure-storage-blob --ignore-installed",
"azure-data-tables --ignore-installed",
]
- start service on local machine:
kit app.kit
- start service in container:
docker compose up
What I expect:
- Packages installed successfully and service starts when running locally
- Packages installed successfully and service starts when running in container
What happens:
- Installation fails when running locally because one of the packages can not be found.
2023-03-31 21:08:13 [36,121ms] [Error] [omni.ext._impl.custom_importer] Failed to import python module poc.services.azure. Error: No module named 'azure.data'. Traceback:
Traceback (most recent call last):
File "c:/users/nycjyp/appdata/local/ov/pkg/kit-104.1.0/kernel/py\omni\ext\_impl\custom_importer.py", line 76, in import_module
return importlib.import_module(name)
File "c:\users\nycjyp\appdata\local\ov\pkg\kit-104.1.0\python\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "c:\users\nycjyp\code\sandbox\omniverse\poc.extensions\service-with-pip-deps\exts\poc.services.azure\poc\services\azure\__init__.py", line 1, in <module>
from .extension import *
File "c:\users\nycjyp\code\sandbox\omniverse\poc.extensions\service-with-pip-deps\exts\poc.services.azure\poc\services\azure\extension.py", line 4, in <module>
from azure.data.tables import TableServiceClient
ModuleNotFoundError: No module named 'azure.data'
2023-03-31 21:08:13 [36,122ms] [Error] [carb.scripting-python.plugin] Exception: Extension python module: 'poc.services.azure' in 'c:\users\nycjyp\code\sandbox\omniverse\poc.extensions\service-with-pip-deps\exts\poc.services.azure' failed to load.
At:
c:/users/nycjyp/appdata/local/ov/pkg/kit-104.1.0/kernel/py\omni\ext\_impl\_internal.py(188): startup
c:/users/nycjyp/appdata/local/ov/pkg/kit-104.1.0/kernel/py\omni\ext\_impl\_internal.py(280): startup_extension
PythonExtension.cpp::startup()(2): <module>
2023-03-31 21:08:13 [36,122ms] [Error] [omni.ext.plugin] [ext: poc.services.azure-1.0.0] Failed to startup python extension.
- Installation fails when running in container:
service-with-pip-deps-ov-farm-connector-1 | 2023-03-31 20:37:42 [11,648ms] [Error] [omni.ext.impl.custom_importer] Failed to import python module poc.services.azure. Error: cannot import name 'Self' from 'typing_extensions' (/opt/nvidia/omniverse/kit-sdk-launcher/extscore/omni.kit.pip_archive/pip_prebundle/typing_extensions.py). Traceback:
service-with-pip-deps-ov-farm-connector-1 | Traceback (most recent call last):
service-with-pip-deps-ov-farm-connector-1 | File "/opt/nvidia/omniverse/kit-sdk-launcher/plugins/bindings-python/omni/ext/impl/custom_importer.py", line 76, in import_module
service-with-pip-deps-ov-farm-connector-1 | return importlib.import_module(name)
service-with-pip-deps-ov-farm-connector-1 | File "/opt/nvidia/omniverse/kit-sdk-launcher/python/lib/python3.7/importlib/__init__.py", line 127, in import_module
service-with-pip-deps-ov-farm-connector-1 | return _bootstrap._gcd_import(name[level:], package, level)
service-with-pip-deps-ov-farm-connector-1 | File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
service-with-pip-deps-ov-farm-connector-1 | File "<frozen importlib._bootstrap>", line 983, in _find_and_load
service-with-pip-deps-ov-farm-connector-1 | File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
service-with-pip-deps-ov-farm-connector-1 | File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
service-with-pip-deps-ov-farm-connector-1 | File "<frozen importlib._bootstrap_external>", line 728, in exec_module
service-with-pip-deps-ov-farm-connector-1 | File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
service-with-pip-deps-ov-farm-connector-1 | File "/exts/poc.services.azure/poc/services/azure/__init__.py", line 1, in <module>
service-with-pip-deps-ov-farm-connector-1 | from .extension import *
service-with-pip-deps-ov-farm-connector-1 | File "/exts/poc.services.azure/poc/services/azure/extension.py", line 3, in <module>
service-with-pip-deps-ov-farm-connector-1 | from azure.storage.blob import BlobServiceClient
service-with-pip-deps-ov-farm-connector-1 | File "/root/.local/share/ov/data/Kit/kit/103.5/pip3-envs/default/azure/storage/blob/__init__.py", line 10, in <module>
service-with-pip-deps-ov-farm-connector-1 | from ._blob_client import BlobClient
service-with-pip-deps-ov-farm-connector-1 | File "/root/.local/share/ov/data/Kit/kit/103.5/pip3-envs/default/azure/storage/blob/_blob_client.py", line 17, in <module>
service-with-pip-deps-ov-farm-connector-1 | from typing_extensions import Self
service-with-pip-deps-ov-farm-connector-1 | ImportError: cannot import name 'Self' from 'typing_extensions' (/opt/nvidia/omniverse/kit-sdk-launcher/extscore/omni.kit.pip_archive/pip_prebundle/typing_extensions.py)
service-with-pip-deps-ov-farm-connector-1 |
service-with-pip-deps-ov-farm-connector-1 | 2023-03-31 20:37:42 [11,648ms] [Error] [carb.scripting-python.plugin] Exception: Extension python module: 'poc.services.azure' in '/exts/poc.services.azure' failed to load.
service-with-pip-deps-ov-farm-connector-1 |
service-with-pip-deps-ov-farm-connector-1 | At:
service-with-pip-deps-ov-farm-connector-1 | /opt/nvidia/omniverse/kit-sdk-launcher/plugins/bindings-python/omni/ext/impl/_internal.py(177): startup
service-with-pip-deps-ov-farm-connector-1 | /opt/nvidia/omniverse/kit-sdk-launcher/plugins/bindings-python/omni/ext/impl/_internal.py(268): startup_extension
service-with-pip-deps-ov-farm-connector-1 | PythonExtension.cpp::startup()(2): <module>
service-with-pip-deps-ov-farm-connector-1 |
service-with-pip-deps-ov-farm-connector-1 | 2023-03-31 20:37:42 [11,648ms] [Error] [omni.ext.plugin] [ext: poc.services.azure-1.0.0] Failed to startup python extension.
Notes:
- Able to successfully install either package by itself (just not both).
- Able to manually install both packages to install location, and run kit app.kit without clearing cache and everything works.
Step taken:
1. Tried adding --ignore-installed option. Has no effect.
requirements = [
"azure-storage-blob --ignore-installed",
"azure-data-tables --ignore-installed",
]
2. Tried installing dependancies during container init and adding location to sys.path
Removed [python.pipapi] from extension.toml and updated dockerfile to include steps to install azure dependancies to /usr/local/lib/python3.7/dist-packages:
RUN echo "deb http://ppa.launchpad.net/deadsnakes/ppa/ubuntu focal main" | tee /etc/apt/sources.list.d/deadsnakes-ppa.list
# install pip via python
RUN apt-get update \
&& apt-get install -y python3.7 python3-pip python3.7-distutils \
&& update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1
# Install azure dependancies
RUN pip3 install azure-storage-blob azure-data-tables
Able to log into container and verify that packages were installed to /usr/local/lib/python3.7/dist-packages
:
Then tried to add path to sys.path
from .kit
file:
[settings.app]
python.sysPaths.'++' = ["/usr/local/lib/python3.7/dist-packages"]
python.extraPaths.'++' = ["/usr/local/lib/python3.7/dist-packages"]
But sys.path is not getting updated. Finally resorted to updating sys.path from script using sys.path.append()
and that updated sys.path, but now getting strage ImportError: cannot import name 'Self' from 'typing_extensions'
error: