flat-zoo-31952
11/26/2022, 10:17 PMrich-kite-32423
11/27/2022, 1:30 AMrich-kite-32423
11/27/2022, 11:48 PM[python-setup]
interpreter_constraints = ["CPython>=3.5"]
[python-setup]
should be [python]
broad-processor-92400
11/28/2022, 1:47 AMpackage
-able Python targets: mostly python_awslambda
but some pex_binary
too. We run ./pants package ::
in CI to validate that they're all packageable, but this ends up spending a lot of time bundling up requirements (~10s per target, as a rule of thumb), and thus it'd be nice to make this faster. I've made two observations:
1. changing our code without changing the dependency structure seems to require repackaging the dependencies from scratch (I ran ./pants package ::
before modification locally, made the change, and then ./pants package ::
after, with the same pantsd process)
2. multiple targets that have the same set of requirements seem to build their requirements separately (more details in thread)
Is this expected behaviour? Any tips for improving it?ripe-scooter-10665
11/28/2022, 3:09 PM./pants test --debug-adapter <path to test file>
I get the following error:
15:06:23.64 [INFO] Completed: Building pytest_runner.pex
15:06:23.64 [ERROR] 1 Exception encountered:
ProcessExecutionFailure: Process 'Building pytest_runner.pex' failed with exit code 1.
stdout:
stderr:
A distribution for debugpy could not be resolved for ~/.pyenv/versions/3.9.15/bin/python3.9.
Found 1 distribution for debugpy that do not apply:
1.) The wheel tags for debugpy 1.6.0 are cp38-cp38-macosx_10_15_x86_64 which do not match the supported tags of ~/.pyenv/versions/3.9.15/bin/python3.9:
cp39-cp39-macosx_13_0_arm64
... 409 more ...
It seems that debugpy is a requirement of pants itself, pinned at 1.6.0 but there does seem to be py3.9 wheels available for it. I tried adding debugpy to my own 3rd party requirements but that didnāt seem to help. Any ideas on how to get around this. Not being able to debug in VSCode is a bit of a pain.white-pager-32496
11/28/2022, 3:46 PMrich-kite-32423
11/29/2022, 5:39 AM[python]
interpreter_constraints = ["==3.9.*"]
Which works successfully. But when I bump it to 3.10.*, I get the following:
bruce@groot:~/tmp/semaphore-demo-python-pants$ ./pants test ::
22:34:39.42 [INFO] Initializing scheduler...
22:34:40.15 [INFO] Scheduler initialized.
22:34:43.19 [INFO] Canceled: Building pytest.pex from pytest_default.lock
22:34:44.01 [INFO] Completed: Building requirements.pex
22:34:44.08 [INFO] Completed: Building requirements.pex with 1 requirement: ansicolors>=1.1.8
22:34:44.08 [ERROR] 1 Exception encountered:
Engine traceback:
in `test` goal
in Run Pytest - hello_world/test_main.py:tests
ProcessExecutionFailure: Process 'Building requirements.pex with 1 requirement: ansicolors>=1.1.8' failed with exit code 1.
stdout:
stderr:
[Errno 2] No such file or directory: '/tmp/pants-sandbox-zOYk5D/.tmp/pex-pip-log.lhpmsm3l/pip.log'
It's not obvious to me why this is happening and what the error messages mean.witty-house-77262
11/29/2022, 8:21 AM./pants
and not just pants
? Why canāt it be installed globally (like with pipx install pants
)` ?average-flag-94768
11/29/2022, 10:16 AMrefined-addition-53644
11/29/2022, 12:23 PM[ERROR] ResolveError: Failed to resolve requirements from PEX environment @ /tmp/tmpoa40lyqx/unzipped_pexes/4185e0a7af669dc757e04bdb6559435de125a6db.
Needed cp39-cp39-manylinux_2_26_x86_64 compatible dependencies for:
1: orjson<4.0.0,>=3.2.1; extra == "all"
Required by: fastapi 0.86.0
But this pex had no ProjectName(raw='orjson', normalized='orjson') distributions.
refined-addition-53644
11/29/2022, 3:48 PMpurple-umbrella-89891
11/29/2022, 4:23 PMwith suppress(...): import x
) in our codebase that are local/internal packages, which are not available in any repository. During pants test, we get warnings in the form Pants cannot infer owners for the following imports in the target a/b/c.py: x
. We have disabled the warnings using # pants: no-infer-dep
in the code but would like to do it centrally and are trying the !{bad_address}
syntax as shown here. However, since x
is not in the known dependencies, it does not work. Any ideas how to make it work globally instead of annotating every import?gentle-painting-24549
11/29/2022, 5:17 PMconda install gdcm
inside of tox to run our tests. Without having access to Conda an alternative Iāve found is to use python-gdcm
instead which is a Python wrapper for GDCM. Iāve tried to attach this dependency to the tests using a `python_requirement`:
python_requirement(
name="gdcm",
requirements=["python-gdcm"],
)
python_tests(
name="tests",
sources=[
"tests/**/test_*.py",
"tests/test_*.py",
],
dependencies=[
":conftest",
":test-resources",
":gdcm",
],
)
However this doesnāt work and python-gdcm
doesnāt get installed into the underlying testing PEXs unless I add this snippet to one of my test files:
try:
import gdcm # noqa
except ImportError:
pass
How can I have the tests depend on python-gdcm
without the attempted import? Or alternatively, how can I give Pants access to the underlying gdcm binary (for example, one that was installed by brew or conda on the host system)?polite-garden-50641
11/29/2022, 5:21 PMmodule_mapping
that will let pants know that python-gdcm
exposes the gdcm
module.
See: https://www.pantsbuild.org/docs/python-third-party-dependencies#use-modules-and-module_mapping-when-the-module-name-is-not-standardgentle-painting-24549
11/29/2022, 5:22 PMrefined-addition-53644
11/29/2022, 5:25 PMrefined-addition-53644
11/29/2022, 5:25 PMpex_binary(
name="service",
entry_point="awslambdaric",
dependencies=["3rdparty/python:resolve#awslambdaric", ":infra_sources"],
layout="packed",
execution_mode="venv",
)
refined-addition-53644
11/29/2022, 5:26 PMawslambdaric
explictlygentle-painting-24549
11/29/2022, 5:29 PM⯠./pants dependencies packages/example/tests/test_example.py | grep requirements
requirements:reqs#numpy
requirements:reqs#pytest
requirements:reqs#python-gdcm
And now hereās what happens when I comment it out:
⯠./pants dependencies packages/example/tests/test_example.py | grep requirements
requirements:reqs#numpy
requirements:reqs#pytest
Everything else is the same on the BUILD file for those two examples:
python_tests(
name="tests",
sources=[
"tests/**/test_*.py",
"tests/test_*.py",
],
dependencies=[
":conftest",
":test-resources",
"requirements:reqs#python-gdcm",
],
)
refined-addition-53644
11/29/2022, 5:33 PM./pants test directory-to-tests:tests
The fileās dependencies are only being shown for the imports you have.refined-addition-53644
11/29/2022, 5:34 PMrefined-addition-53644
11/29/2022, 5:36 PMpython_test
python_test(name="test_example", source="test_example.py", dependencies=["insert_explicit"]
Please verify the correct syntax
Then you can attach python_tests to have explicit dependency on this test target but you canāt use the glob then.gentle-painting-24549
11/29/2022, 5:38 PMtests
target directly. But they succeed when I uncomment the try/except block.refined-addition-53644
11/29/2022, 5:43 PMdependencies --transitive
gentle-painting-24549
11/29/2022, 5:48 PM--transitive
but the behavior is still the same: even though the requirements:reqs#python-gdcm
target is explicitly declared and attached to the tests
target via dependencies - it doesnāt actually get attached as a dependency unless the try/except ImportError block exists.refined-addition-53644
11/29/2022, 5:50 PMgentle-painting-24549
11/29/2022, 5:54 PMpackages/example/BUILD
looks like this:
python_sources(
name="lib",
sources=[
"example/**/*.py",
"example/*.py",
],
)
python_tests(
name="tests",
sources=[
"tests/**/test_*.py",
"tests/test_*.py",
],
dependencies=[
"requirements:reqs#python-gdcm",
],
)
python_distribution(
name="dist",
dependencies=[
":lib",
],
provides=setup_py(
name="example",
version="0.0.0",
),
generate_setup=True,
)
And my BUILD file @ requirements/BUILD
looks like this:
python_requirements(
name="reqs",
source="requirements.txt",
module_mapping={
"python-gdcm": ["gdcm"],
},
)
refined-addition-53644
11/29/2022, 6:19 PMgentle-painting-24549
11/29/2022, 6:37 PMgentle-painting-24549
11/29/2022, 7:09 PM