plain-night-51324
01/05/2023, 12:13 AM./pants test <single-file>
to work:
Got errors that it can’t find 3rd party libraries like sqlalchemy, google.protobuf, factory (see inside)Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to <https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies>.
16:10:48.37 [WARN] Pants cannot infer owners for the following imports in the target common/application/models.py:
* sqlalchemy.Boolean (line: 8)
* sqlalchemy.Column (line: 8)
* sqlalchemy.DateTime (line: 8)
* sqlalchemy.String (line: 8)
* sqlalchemy.dialects.postgresql.JSON (line: 9)
* sqlalchemy.dialects.postgresql.UUID (line: 9)
* sqlalchemy.func (line: 8)
If you do not expect an import to be inferrable, add `# pants: no-infer-dep` to the import line. Otherwise, see <https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies> for common problems.
16:10:48.37 [WARN] Pants cannot infer owners for the following imports in the target <>/proto/tfdv_pb2.py:
* google.protobuf.descriptor (line: 6)
* google.protobuf.internal.enum_type_wrapper (line: 5)
* google.protobuf.message (line: 7)
* google.protobuf.reflection (line: 8)
* google.protobuf.symbol_database (line: 9)
ImportError while loading conftest '/private/var/folders/xz/gwhmgmz14510pl52tgmhdl740000gn/T/pants-sandbox-YH9TnA/common/conftest.py'.
common/conftest.py:8: in <module>
import factory
E ModuleNotFoundError: No module named 'factory'
./pants --filter-target-type=python_requirement list ::
but don’t see any 3rd party things. went through this doc, didn’t find anything. all my build files are up to datebroad-processor-92400
01/05/2023, 12:17 AMpython_requirement
or one of the generators, from a pyproject.toml
or requirements.txt
), and will then infer which files use them.
https://www.pantsbuild.org/docs/python-third-party-dependencies has more docsplain-night-51324
01/05/2023, 12:27 AMpython_sources()
python_requirements(
name="reqs",
source="base-requirements.txt",
)
python_requirements(
name="reqs0",
)
and the test is in common/foo/tests/test_foo.py
I also took out the first base-requirements.txt and to make sure and still have the same errorpants-sandbox-lm1s6E
, saw some first party files. not sure how to check if any 3rd party dependencies are installed therebroad-processor-92400
01/05/2023, 12:31 AMplain-night-51324
01/05/2023, 12:31 AM[python]
tailor_pex_binary_targets = false
enable_resolves = true
./pants dependencies common/foo/tests/test_foo.py
I get:
16:39:31.68 [INFO] Initializing scheduler...
16:39:31.95 [INFO] Scheduler initialized.
16:39:38.45 [WARN] The target common/foo/tests/test_foo.py:tests0 imports `grpc`, but Pants cannot safely infer a dependency because more than one target owns this module, so it is ambiguous which to use: ['…'].
Please explicitly include the dependency you want in the `dependencies` field of common/foo/tests/test_foo.py:tests0, or ignore the ones you do not want by prefixing with `!` or `!!` so that one or no targets are left.
Alternatively, you can remove the ambiguity by deleting/changing some of the targets so that only 1 target owns this module. Refer to <https://www.pantsbuild.org/v2.14/docs/troubleshooting#import-errors-and-missing-dependencies>.
so thats probably why..broad-processor-92400
01/05/2023, 12:44 AMgrpc
are being imported into pants multiple times? Are they listed in multiple requirements.txt files?plain-night-51324
01/05/2023, 12:44 AMbroad-processor-92400
01/05/2023, 12:50 AMbackend/requirements.txt
that specifies all dependencies, and then subprojects like backend/api
and backend/whatever
that don't have their own requirements.txt.
If you're migrating an existing codebase to pants, I think you can leave the individual-project requirements.txt
where they are without a python_requirements
(and use https://www.pantsbuild.org/docs/reference-python#tailor_requirements_targets to ensure ./pants tailor ::
doesn't add them), and have a single top-level requirements.txt that is imported via python_requirements
. (This is what we did for our migration.)
Alternatively, a path that seems to be harder would be to have a separate 'resolve' per sub-project (https://www.pantsbuild.org/docs/python-third-party-dependencies#multiple-lockfiles).plain-night-51324
01/05/2023, 12:51 AM