refined-cartoon-38951
03/25/2025, 12:50 PMrequirements.txt. I want each job to be able to declare its own dependencies, even if the versions differ between jobs.
I'm currently getting these warnings:
13:20:15.11 [WARN] Pants cannot infer owners for the following imports in the target jobs/some-job/file.py:app:
* boto3 (line: 10)
* botocore.exceptions.ClientError (line: 11)
My BUILD files look like this:
python_requirements(
name="req",
source='requirements.txt'
)
python_sources(
name="app",
dependencies=[":req"]
)
My pants.toml:
[GLOBAL]
pants_version = "2.25.0"
backend_packages = [
"pants.backend.docker",
"pants.backend.python"
]
build_file_prelude_globs = ["pants-plugins/macros.py"] # some docker macros that are not used yet
[source]
marker_filenames = [
"requirements.txt"
]
[python]
# enable_resolves = true
interpreter_constraints = ['>=3.11']
[python-repos]
indexes = [
"..."
]
[python-infer]
use_rust_parser = true
[dockerfile-parser]
use_rust_parser = true
Is it safe to ignore these warnings in my case?some-insurance-58590
03/25/2025, 2:40 PMkind-dusk-88649
03/25/2025, 4:14 PMrefined-cartoon-38951
03/25/2025, 9:20 PMelegant-florist-94385
03/25/2025, 9:20 PMresolve=<ABC>
◦ you can use paremeterize to put a requirement in multiple universes.
• each source file specifies what universe it runs in (ie. where it searches for dependencies)
◦ again, you can use parameterize if it needs to run in multiple universes (such as a common library used by multiple jobs)
• you can set a default resolve (in pants.toml), so that you can avoid needing to set resolve=... in whatever is your main set of targets
• There are decent tools/techniques to avoid duplication for things that belong in multiple resolves.elegant-florist-94385
03/25/2025, 9:23 PMpython_requirements(
name="req",
source="requirements.txt",
resolve="job_A_resolve",
)
python_sources(
name="app",
resolve="job_A_resolve",
)
And there is no need to specify the dependencies directly, since pants will read your source code, check your imports, and then find the related packages within job_A_resolve