The Python packages of tensorrt are currently divided into [three libraries](htt…ps://github.com/NVIDIA/TensorRT/tree/release/8.6/python/packaging):
- `tensorrt_bindings`, which contains the actual Python bindings
- `tensorrt_libs`, which contains the tensorrt system libraries and depends on python cuda packages
- the `tensorrt` frontend
While `tensorrt_bindings` and `tensorrt_libs` are easily installable libraries, the `tensorrt` packages seems to have a weird installation mechanism that relies on internally installing the other two libraries in its `setup.py`. This makes it hard to use the frontend with package managers such as Poetry which rely on PEP 517 builds.
Couldn't `tensorrt` simply _require_ `tensorrt_bindings` and `tensorrt_libs`, just as for example `tensorrt_bindings` requires some cuda dependencies? This would make the installation mechanism much simpler, compliant to existing PEPs, and reproducible (as all packages would be nicely tracked in the `poetry.lock` file). Right now I'm resorting to installing `tensorrt_bindings` and `tensorrt_libs` as I didn't seem to find other ways.
Here you can find the error I'm getting through Poetry:
```bash
poetry add tensorrt
Using version ^8.6.1.post1 for tensorrt
Updating dependencies
Resolving dependencies... (5.0s)
Package operations: 1 install, 0 updates, 0 removals
• Installing tensorrt (8.6.1.post1): Failed
ChefBuildError
Backend subprocess exited when trying to invoke build_wheel
/tmp/tmpyem0v5d_/.venv/bin/python: No module named pip
running bdist_wheel
running build
running build_py
creating build
creating build/lib
creating build/lib/tensorrt
copying tensorrt/__init__.py -> build/lib/tensorrt
running egg_info
writing tensorrt.egg-info/PKG-INFO
writing dependency_links to tensorrt.egg-info/dependency_links.txt
writing requirements to tensorrt.egg-info/requires.txt
writing top-level names to tensorrt.egg-info/top_level.txt
reading manifest file 'tensorrt.egg-info/SOURCES.txt'
adding license file 'LICENSE.txt'
writing manifest file 'tensorrt.egg-info/SOURCES.txt'
installing to build/bdist.linux-x86_64/wheel
running install
/tmp/tmpyem0v5d_/.venv/bin/python: No module named pip
Traceback (most recent call last):
File "/usr/local/share/poetry/venv/lib/python3.9/site-packages/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/usr/local/share/poetry/venv/lib/python3.9/site-packages/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/usr/local/share/poetry/venv/lib/python3.9/site-packages/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel
return _build_backend().build_wheel(wheel_directory, config_settings,
File "/tmp/tmpyem0v5d_/.venv/lib/python3.9/site-packages/setuptools/build_meta.py", line 434, in build_wheel
return self._build_with_temp_dir(
File "/tmp/tmpyem0v5d_/.venv/lib/python3.9/site-packages/setuptools/build_meta.py", line 419, in _build_with_temp_dir
self.run_setup()
File "/tmp/tmpyem0v5d_/.venv/lib/python3.9/site-packages/setuptools/build_meta.py", line 507, in run_setup
super(_BuildMetaLegacyBackend, self).run_setup(setup_script=setup_script)
File "/tmp/tmpyem0v5d_/.venv/lib/python3.9/site-packages/setuptools/build_meta.py", line 341, in run_setup
exec(code, locals())
File "<string>", line 110, in <module>
File "/tmp/tmpyem0v5d_/.venv/lib/python3.9/site-packages/setuptools/__init__.py", line 103, in setup
return distutils.core.setup(**attrs)
File "/tmp/tmpyem0v5d_/.venv/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 185, in setup
return run_commands(dist)
File "/tmp/tmpyem0v5d_/.venv/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
dist.run_commands()
File "/tmp/tmpyem0v5d_/.venv/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
self.run_command(cmd)
File "/tmp/tmpyem0v5d_/.venv/lib/python3.9/site-packages/setuptools/dist.py", line 989, in run_command
super().run_command(command)
File "/tmp/tmpyem0v5d_/.venv/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
cmd_obj.run()
File "/tmp/tmpyem0v5d_/.venv/lib/python3.9/site-packages/wheel/bdist_wheel.py", line 399, in run
self.run_command("install")
File "/tmp/tmpyem0v5d_/.venv/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
self.distribution.run_command(command)
File "/tmp/tmpyem0v5d_/.venv/lib/python3.9/site-packages/setuptools/dist.py", line 989, in run_command
super().run_command(command)
File "/tmp/tmpyem0v5d_/.venv/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
cmd_obj.run()
File "<string>", line 62, in run
File "<string>", line 40, in run_pip_command
File "/home/wizard/mambaforge/envs/ra/lib/python3.9/subprocess.py", line 373, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/tmp/tmpyem0v5d_/.venv/bin/python', '-m', 'pip', 'install', '--extra-index-url', 'https://pypi.nvidia.com', 'tensorrt_libs==8.6.1', 'tensorrt_bindings==8.6.1']' returned non-zero exit status 1.
at /usr/local/share/poetry/venv/lib/python3.9/site-packages/poetry/installation/chef.py:147 in _prepare
143│
144│ error = ChefBuildError("\n\n".join(message_parts))
145│
146│ if error is not None:
→ 147│ raise error from None
148│
149│ return path
150│
151│ def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:
Note: This error originates from the build backend, and is likely not a problem with poetry but with tensorrt (8.6.1.post1) not supporting PEP 517 builds. You can verify this by running 'pip wheel --use-pep517 "tensorrt (==8.6.1.post1)"'.
```