high-yak-85899
02/09/2023, 8:48 PMsphinx.application.Sphinx
in a script (I know a bit different use than normal). I'd like to do this with Pants, but it can't find sphinxcontrib-serializinghtml
. This is a transitive dependency of sphinx
. Are there any options other than adding that transitive dependency to my requirements.txt
?fast-nail-55400
02/09/2023, 8:51 PMbitter-ability-32190
02/09/2023, 8:54 PMfast-nail-55400
02/09/2023, 8:55 PMsphinx
would not remove this dependency from their own dependency graph, they are free to do so. Your code should not rely on assumptions built into sphinx when your code could just declare the dependency it needs.high-yak-85899
02/09/2023, 9:00 PMsphinx.application.Sphinx
has a valid input with html
as the builder name which makes it seem like I shouldn't need to separately say "oh by the way I know internally you need this library to do the thing"fast-nail-55400
02/09/2023, 10:05 PMenough-analyst-54434
02/09/2023, 11:00 PMsphinxcontrib-serializinghtml
project is direct dependency of Sphinx main: https://github.com/sphinx-doc/sphinx/blob/master/pyproject.toml#L62 and so you'd only need a proper module-mapping for that i- if even that.high-yak-85899
02/09/2023, 11:03 PMenough-analyst-54434
02/09/2023, 11:05 PM$ pex sphinx -- -c 'import sphinxcontrib.serializinghtml; print(sphinxcontrib.serializinghtml.__file__)'
/tmp/tmpt_1zhtm0/.bootstrap/pex/environment.py:654: PEXWarning: The `pkg_resources` package was loaded from a pex vendored version when declaring namespace packages defined by:
1. sphinxcontrib-devhelp==1.0.2 namespace packages:
sphinxcontrib
2. sphinxcontrib-jsmath==1.0.1 namespace packages:
sphinxcontrib
3. sphinxcontrib-serializinghtml==1.1.5 namespace packages:
sphinxcontrib
4. sphinxcontrib-qthelp==1.0.3 namespace packages:
sphinxcontrib
These distributions should fix their `install_requires` to include `setuptools`
pex_warnings.warn(
/home/jsirois/.pex/installed_wheels/352a9a00ae864471d3a7ead8d7d79f5fc0b57e8b3f95e9867eb9eb28999b92fd/sphinxcontrib_serializinghtml-1.1.5-py2.py3-none-any.whl/sphinxcontrib/serializinghtml/__init__.py
high-yak-85899
02/09/2023, 11:07 PMenough-analyst-54434
02/09/2023, 11:07 PM$ pex sphinx==4.5 -- -c 'import sphinxcontrib.serializinghtml; print(sphinxcontrib.serializinghtml.__file__)'
/tmp/tmp361dpp9r/.bootstrap/pex/environment.py:654: PEXWarning: The `pkg_resources` package was loaded from a pex vendored version when declaring namespace packages defined by:
1. sphinxcontrib-devhelp==1.0.2 namespace packages:
sphinxcontrib
2. sphinxcontrib-jsmath==1.0.1 namespace packages:
sphinxcontrib
3. sphinxcontrib-serializinghtml==1.1.5 namespace packages:
sphinxcontrib
4. sphinxcontrib-qthelp==1.0.3 namespace packages:
sphinxcontrib
These distributions should fix their `install_requires` to include `setuptools`
pex_warnings.warn(
/home/jsirois/.pex/installed_wheels/352a9a00ae864471d3a7ead8d7d79f5fc0b57e8b3f95e9867eb9eb28999b92fd/sphinxcontrib_serializinghtml-1.1.5-py2.py3-none-any.whl/sphinxcontrib/serializinghtml/__init__.py
high-yak-85899
02/09/2023, 11:08 PMpython_source
? When I do dependencies --transitive
, it's only showing that sphinx
is a dependency//:reqs#click
//:reqs#jinja2
//:reqs#pyyaml
//:reqs#sortedcontainers
//:reqs#sphinx
//:reqs#sphinx-rtd-theme
//:reqs#types-PyYAML
//requirements.txt:reqs
enough-analyst-54434
02/09/2023, 11:09 PMdependencies
goal only does 1st party and direct 3rdparty.high-yak-85899
02/09/2023, 11:10 PMpex_binary
target? I was hoping just the python_source
would work now that running that is separated from a pex in newer pants versionsenough-analyst-54434
02/09/2023, 11:11 PMhigh-yak-85899
02/09/2023, 11:12 PMsphinx.application.Sphinx
with a builder set to "html"
and you get
Running Sphinx v4.5.0
Traceback (most recent call last):
File "/home/nathanael/.cache/pants/named_caches/pex_root/venvs/874a56f50430c8505af5832bda4ffa33c6fe9d8c/c4fe7bf08b2a1259d39d005551c5bf25de7c32ef/lib/python3.8/site-packages/sphinx/registry.py", line 425, in load_extension
mod = import_module(extname)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/nathanael/.cache/pants/named_caches/pex_root/venvs/874a56f50430c8505af5832bda4ffa33c6fe9d8c/c4fe7bf08b2a1259d39d005551c5bf25de7c32ef/lib/python3.8/site-packages/sphinx/builders/epub3.py", line 12, in <module>
from sphinx.builders import _epub_base
File "/home/nathanael/.cache/pants/named_caches/pex_root/venvs/874a56f50430c8505af5832bda4ffa33c6fe9d8c/c4fe7bf08b2a1259d39d005551c5bf25de7c32ef/lib/python3.8/site-packages/sphinx/builders/_epub_base.py", line 15, in <module>
from sphinx.builders.html import BuildInfo, StandaloneHTMLBuilder
File "/home/nathanael/.cache/pants/named_caches/pex_root/venvs/874a56f50430c8505af5832bda4ffa33c6fe9d8c/c4fe7bf08b2a1259d39d005551c5bf25de7c32ef/lib/python3.8/site-packages/sphinx/builders/html/__init__.py", line 1295, in <module>
import sphinxcontrib.serializinghtml # NOQA
ModuleNotFoundError: No module named 'sphinxcontrib.serializinghtml'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/nathanael/.cache/pants/named_caches/pex_root/venvs/874a56f50430c8505af5832bda4ffa33c6fe9d8c/c4fe7bf08b2a1259d39d005551c5bf25de7c32ef/pex", line 236, in <module>
runpy.run_module(module_name, run_name="__main__", alter_sys=True)
File "/usr/lib/python3.8/runpy.py", line 207, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/nathanael/devel/monorepo/astranis-python/astranis/service/action_triggers/documenter/config_documenter.py", line 77, in <module>
build()
File "/home/nathanael/.cache/pants/named_caches/pex_root/venvs/874a56f50430c8505af5832bda4ffa33c6fe9d8c/c4fe7bf08b2a1259d39d005551c5bf25de7c32ef/lib/python3.8/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/home/nathanael/.cache/pants/named_caches/pex_root/venvs/874a56f50430c8505af5832bda4ffa33c6fe9d8c/c4fe7bf08b2a1259d39d005551c5bf25de7c32ef/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/home/nathanael/.cache/pants/named_caches/pex_root/venvs/874a56f50430c8505af5832bda4ffa33c6fe9d8c/c4fe7bf08b2a1259d39d005551c5bf25de7c32ef/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/nathanael/.cache/pants/named_caches/pex_root/venvs/874a56f50430c8505af5832bda4ffa33c6fe9d8c/c4fe7bf08b2a1259d39d005551c5bf25de7c32ef/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/nathanael/devel/monorepo/astranis-python/astranis/service/action_triggers/documenter/config_documenter.py", line 70, in build
sphinx = application.Sphinx(
File "/home/nathanael/.cache/pants/named_caches/pex_root/venvs/874a56f50430c8505af5832bda4ffa33c6fe9d8c/c4fe7bf08b2a1259d39d005551c5bf25de7c32ef/lib/python3.8/site-packages/sphinx/application.py", line 219, in __init__
self.setup_extension(extension)
File "/home/nathanael/.cache/pants/named_caches/pex_root/venvs/874a56f50430c8505af5832bda4ffa33c6fe9d8c/c4fe7bf08b2a1259d39d005551c5bf25de7c32ef/lib/python3.8/site-packages/sphinx/application.py", line 380, in setup_extension
self.registry.load_extension(self, extname)
File "/home/nathanael/.cache/pants/named_caches/pex_root/venvs/874a56f50430c8505af5832bda4ffa33c6fe9d8c/c4fe7bf08b2a1259d39d005551c5bf25de7c32ef/lib/python3.8/site-packages/sphinx/registry.py", line 428, in load_extension
raise ExtensionError(__('Could not import extension %s') % extname,
sphinx.errors.ExtensionError: Could not import extension sphinx.builders.epub3 (exception: No module named 'sphinxcontrib.serializinghtml')
enough-analyst-54434
02/09/2023, 11:13 PMls -1 /home/nathanael/.cache/pants/named_caches/pex_root/venvs/874a56f50430c8505af5832bda4ffa33c6fe9d8c/c4fe7bf08b2a1259d39d005551c5bf25de7c32ef/lib/python3.8/site-packages/
and provide the output?high-yak-85899
02/09/2023, 11:14 PMenough-analyst-54434
02/09/2023, 11:15 PMPEX_EXTRA_SYS_PATH.pth
That's the problem. Some tools don't handle this - which supports building venvs from symlink farms. You can turn that off with pex_binary
pex_binary(
...
execution_mode="venv",
venv_site_packages_copies=True,
)
https://www.pantsbuild.org/v2.15/docs/reference-pex_binary#codevenv_site_packages_copiescodehigh-yak-85899
02/09/2023, 11:18 PM