purple-plastic-57801
06/08/2023, 12:25 AMpants tailor lib/ :: . Unfortunately, there is a pile of custom to support this.broad-processor-92400
06/08/2023, 12:31 AMrequirements.txt not include dependencies for pants to use?
There's some options like https://www.pantsbuild.org/docs/reference-python#tailor_requirements_targets that will stop tailor adding targets. Another option might be ensuring the file is owned by another target that's not python_requirements, e.g. file(sources=["requirements.txt"]) . The second one is likely to be useful if you need to use the file from within pants, as a normal file (e.g. putting it in an archive or something).purple-plastic-57801
06/08/2023, 12:33 AMpython_sources()
python_requirements(
name="reqs",
)
python_requirements(
name="reqs0",
source="test-requirements.txt",
)
Where lib/requirements.txt is generated as
certifi >= 14.05.14
frozendict >= 2.0.3
python_dateutil >= 2.5.3
setuptools >= 21.0.0
urllib3 >= 1.15.1purple-plastic-57801
06/08/2023, 12:33 AM___________ ERROR collecting observatory_api/test/test_motor_api.py ____________
ImportError while importing test module '/tmp/pants-sandbox-KkdP79/observatory_api/test/test_motor_api.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/home/geethree/.pyenv/versions/3.9.10/lib/python3.9/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
observatory_api/test/test_motor_api.py:15: in <module>
import observatory_api
observatory_api/observatory_api/__init__.py:18: in <module>
from observatory_api.api_client import ApiClient
observatory_api/observatory_api/api_client.py:24: in <module>
import urllib3
E ModuleNotFoundError: No module named 'urllib3'purple-plastic-57801
06/08/2023, 12:34 AMpurple-plastic-57801
06/08/2023, 12:36 AMtailor_requirements_targets .. I would need a negative lookahead to ignore lib/requirements.txt? hmmppurple-plastic-57801
06/08/2023, 12:37 AMpytest~=4.6.7 # needed for python 3.4
pytest-cov>=2.8.1
pytest-randomly==1.2.3 # needed for python 3.4broad-processor-92400
06/08/2023, 12:39 AMrequirements.txt?purple-plastic-57801
06/08/2023, 12:39 AMpurple-plastic-57801
06/08/2023, 12:40 AMrequirements_targets = (?!lib)/.*requirements.*
Might work.broad-processor-92400
06/08/2023, 12:40 AMtailor_requirements_targets = false and then running pants tailor :: should have the good behaviour (not adding the python_requirements target)?purple-plastic-57801
06/08/2023, 12:41 AMbroad-processor-92400
06/08/2023, 12:41 AM[python] section.purple-plastic-57801
06/08/2023, 12:41 AMbroad-processor-92400
06/08/2023, 12:42 AMpants.toml, but in the [python] sectionbroad-processor-92400
06/08/2023, 12:42 AMpython_requirements targets won't be automatically created, but you can always manually create them. The second option of using a manual files target doesn't have that particular failing.)purple-plastic-57801
06/08/2023, 12:44 AM[python]
tailor_requirements_targets = "(?!lib)/.*requirements.*"
?purple-plastic-57801
06/08/2023, 12:44 AMpurple-plastic-57801
06/08/2023, 12:45 AMbroad-processor-92400
06/08/2023, 12:46 AMpurple-plastic-57801
06/08/2023, 12:46 AMpurple-plastic-57801
06/08/2023, 12:46 AMpurple-plastic-57801
06/08/2023, 12:46 AMbroad-processor-92400
06/08/2023, 12:49 AMfiles targets for these particular requirements.txt's.