square-psychiatrist-19087
02/22/2024, 8:20 PMpex_binary
erases information about entry points, and this breaks sphinx. How can I make it work?square-psychiatrist-19087
02/22/2024, 8:20 PMpython_requirement(
name="sphinx",
requirements=["sphinx~=7.2"],
)
pex_binary(
name="sphinx-build",
script="sphinx-build",
dependencies=[":sphinx"],
)
run_shell_command(
name="build",
command="sphinx-build -M html source/ build/",
execution_dependencies=[":sphinx-build"],
runnable_dependencies=[":sphinx-build"],
)
square-psychiatrist-19087
02/22/2024, 8:21 PMhtml_theme = "sphinx_rtd_theme"
in my sphinx conf.py, and it throws an error
$ pants run docs:build
21:16:53.46 [INFO] Initialization options changed: reinitializing scheduler...
21:16:57.65 [INFO] Scheduler initialized.
21:17:01.29 [INFO] Completed: Building 1 requirement for docs/sphinx-build.pex from the lockfiles/sphinx.lock resolve: sphinx~=7.2
Running Sphinx v7.2.6
Theme error:
no theme named 'sphinx_rtd_theme' found (missing theme.conf?)
square-psychiatrist-19087
02/22/2024, 8:23 PMimportlib.metadata.entry_points
to discover plugins
https://github.com/sphinx-doc/sphinx/blob/faa33a53a389f6f8bc1f6ae97d6015fa92393c4a/sphinx/theming.py#L139
And I think this information gets erased by pex, how can I fix that?broad-processor-92400
02/22/2024, 8:34 PMsquare-psychiatrist-19087
02/22/2024, 8:35 PMbroad-processor-92400
02/22/2024, 8:36 PMadhoc_tool(runnable=“:sphinx-build”, args=[…])
may work better overall, once you’ve fixed the entry point issue. Pants will help find the right Python versions, etc)broad-processor-92400
02/22/2024, 8:37 PMsquare-psychiatrist-19087
02/22/2024, 8:38 PMsquare-psychiatrist-19087
02/22/2024, 8:42 PMcommand="sphinx-build -M html source/ build/",
square-psychiatrist-19087
02/22/2024, 8:42 PMsquare-psychiatrist-19087
02/22/2024, 8:44 PMcommand="{chroot}/docs/sphinx-build.pex -M html source/ build/",
square-psychiatrist-19087
02/22/2024, 8:46 PMsquare-psychiatrist-19087
02/22/2024, 8:47 PMdependencies=[*recursive_dependencies("my_module")]
broad-processor-92400
02/22/2024, 9:20 PMcommand="{chroot}/docs/sphinx-build.pexOh, if you're having to do that, I think the
adhoc_tool
version is better; it manages that for you.
I don't know of a good way to all source files; do you have a single file that imports ~everything?square-psychiatrist-19087
02/22/2024, 9:27 PMsquare-psychiatrist-19087
02/22/2024, 9:27 PMsquare-psychiatrist-19087
02/22/2024, 9:28 PMbroad-processor-92400
02/22/2024, 9:29 PMfoo/__init__.py
that has various import statements like from .bar import X
or import baz
etc. so that users can write import foo.X
and import foo; foo.baz
. If that's the case, then one might be able to use that entrypoint as the 'recursive' thing (with some trickery)square-psychiatrist-19087
02/22/2024, 9:32 PMbroad-processor-92400
02/22/2024, 9:32 PMbroad-processor-92400
02/22/2024, 9:32 PMsquare-psychiatrist-19087
02/22/2024, 9:33 PMbroad-processor-92400
02/22/2024, 9:35 PMpython_source(name="py-for-docs", sources=["**/*.py"])
square-psychiatrist-19087
02/23/2024, 10:25 AM@rule(desc="Recursively add all python sources as dependencies for unit target")
async def infer_unit_dependencies(
request: InferUnitDependenciesRequest,
all_targets: AllTargets,
) -> InferredDependencies:
spec_path = request.field_set.address.spec_path
return InferredDependencies(
t.address
for t in all_targets
if t.has_field(PythonSourceField)
and t.address.spec_path.startswith(spec_path)
and t.get(PythonResolveField).value == "default"
)
curved-manchester-66006
03/06/2024, 6:34 PMsquare-psychiatrist-19087
03/06/2024, 6:43 PMsquare-psychiatrist-19087
03/06/2024, 6:43 PMregister.py
filesquare-psychiatrist-19087
03/06/2024, 6:47 PMglob(
name="glob",
target_types={"python_source": {"resolve": "default"}},
)
Put it into the root of a directory and it will automatically add dependencies on all python_source targets with resolve=default recursivelycurved-manchester-66006
03/06/2024, 8:06 PMsquare-psychiatrist-19087
03/20/2024, 10:32 AMglob
target is one way to add all python sources to docker imagesquare-psychiatrist-19087
05/14/2024, 9:58 PMaloof-airline-74337
05/14/2024, 10:00 PMaloof-airline-74337
05/14/2024, 10:00 PM