gentle-flower-25372
02/22/2024, 10:09 PMcontainer/package-a/bin/main.py
When creating pex_binary it's using the following import path container.package_a.bin.main instead of just package_a.bin.main. How can I fix this? ๐งตbroad-processor-92400
02/22/2024, 10:11 PMpants roots say for your repo?gentle-flower-25372
02/22/2024, 10:12 PM[source]
root_patterns = ["/"]
container/package-a/BUILD:
poetry_requirements(
name="poetry",
resolve="package-a",
)
container/package-a/BUILD
python_sources()
pex_binary(
name="pex_binary",
entry_point="main.py",
resolve="package-a",
)gentle-flower-25372
02/22/2024, 10:12 PM[source]
root_patterns = ["/"]
instead of :
[source]
marker_filenames = ["pyproject.toml"]
because the docs said they're the same.broad-processor-92400
02/22/2024, 10:14 PMgentle-flower-25372
02/22/2024, 10:14 PMmarker_filenames = ["pyproject.toml"] yields a different result. This time though the import path is too short, i.e. bin.main when it should be package_a.bin.maingentle-flower-25372
02/22/2024, 10:14 PMbroad-processor-92400
02/22/2024, 10:15 PMcontainer needs to be the source root, so root_patterns = ["container/", "...anything else..."] would be closergentle-flower-25372
02/22/2024, 10:15 PMbroad-processor-92400
02/22/2024, 10:15 PMpackage-a with a hyphen will behave as expected.gentle-flower-25372
02/22/2024, 10:15 PMbroad-processor-92400
02/22/2024, 10:17 PMat the very bottomOh, I think that's trying to say "for this specific example", but is definitely ambigious. Do you feel like contributing a fix to add an extra qualifier to that and the one above? (Not a problem if not!) https://github.com/pantsbuild/pants/blob/42ff1dd86a7c3b370a2802df272d27ff0bb42ce3/docs/docs/using-pants/key-concepts/source-roots.mdx#L354
gentle-flower-25372
02/22/2024, 10:19 PMgentle-flower-25372
02/22/2024, 10:19 PMgentle-flower-25372
02/22/2024, 10:22 PMModuleNotFoundError -- I have no idea where to even begin to debug ๐gentle-flower-25372
02/22/2024, 10:26 PMbroad-processor-92400
02/22/2024, 10:27 PMpyproject.toml as a marker file:
[source]
marker_filenames = ["pyproject.toml"]
For this example, this pattern is equivalent to using the build root / as the fully-qualified pattern:
[source]
root_patterns = ["/"]
And then similar for the earlier one, basically flip the code blocks to have the pattern version first, and then expand that to be the fully-qualified file paths second. Do you think that's clearer/would've avoided your confusion?broad-processor-92400
02/22/2024, 10:27 PMI'm guessing the pex_binary isn't correctly inferring dependencies and they need to be manually added.yeah. Do you hvae any warnings about dependencies that can't be inferred? Which module isn't found?
gentle-flower-25372
02/22/2024, 10:28 PMbroad-processor-92400
02/22/2024, 10:30 PMgentle-flower-25372
02/22/2024, 10:30 PMyeah. Do you hvae any warnings about dependencies that can't be inferred? Which module isn't found?No warnings. When I call this it returns 0 deps
pants dependencies container/package-a/bin:pex_binarybroad-processor-92400
02/22/2024, 10:32 PMmain.py ๐ค
The first thing I'd check is if the hyphen is causing issues; is it easy to mv package-a package_a as an experiment, and see if that works better?gentle-flower-25372
02/22/2024, 10:34 PMdiff --git i/utility/company-devops/company_devops/BUILD.pants w/utility/company-devops/company_devops/BUILD.pants
index db46e8d6c9..fcc078087a 100644
--- i/utility/company-devops/company_devops/BUILD.pants
+++ w/utility/company-devops/company_devops/BUILD.pants
@@ -1 +1 @@
-python_sources()
+python_sources(resolve="company-devops")
diff --git i/utility/company-devops/company_devops/azure_devops/BUILD.pants w/utility/company-devops/company_devops/azure_devops/BUILD.pants
index db46e8d6c9..fcc078087a 100644
--- i/utility/company-devops/company_devops/azure_devops/BUILD.pants
+++ w/utility/company-devops/company_devops/azure_devops/BUILD.pants
@@ -1 +1 @@
-python_sources()
+python_sources(resolve="company-devops")
diff --git i/utility/company-devops/compdev/BUILD.pants w/utility/company-devops/compdev/BUILD.pants
index 0c23d586da..2db6047e1a 100644
--- i/utility/company-devops/compdev/BUILD.pants
+++ w/utility/company-devops/compdev/BUILD.pants
@@ -1,10 +1,11 @@
-python_sources()
+python_sources(resolve="company-devops")
pex_binary(
name="pex_binary",
entry_point="main.py",
+ dependencies=[
+ "utility/company-devops/company_devops",
+ "utility/company-devops/compdev",
+ ],
resolve="company-devops",
)
diff --git i/utility/company-devops/compdev/commands/BUILD.pants w/utility/company-devops/compdev/commands/BUILD.pants
index db46e8d6c9..fcc078087a 100644
--- i/utility/company-devops/compdev/commands/BUILD.pants
+++ w/utility/company-devops/compdev/commands/BUILD.pants
@@ -1 +1 @@
-python_sources()
+python_sources(resolve="company-devops")gentle-flower-25372
02/22/2024, 10:36 PMgentle-flower-25372
02/22/2024, 10:36 PMbroad-processor-92400
02/22/2024, 10:37 PMmain.py reference as an entry point. Can you file an issue that cross-resolve pex_binary entry_point s don't work.
As a minor fix-up, now that you've been guided to update the resolves, does removing the explicit dependencies work?gentle-flower-25372
02/22/2024, 10:38 PMbroad-processor-92400
02/22/2024, 10:38 PMIs it fair to say that pants hasn't been optimized to onboard repos that require 100's of custom resolves?Yeah, I think so
gentle-flower-25372
02/22/2024, 10:38 PMbroad-processor-92400
02/22/2024, 10:38 PMgentle-flower-25372
02/22/2024, 10:40 PMbroad-processor-92400
02/22/2024, 10:43 PMgentle-flower-25372
02/22/2024, 10:51 PMgentle-flower-25372
02/22/2024, 10:51 PMgentle-flower-25372
02/22/2024, 10:55 PM