narrow-vegetable-37489
08/21/2021, 9:44 PMmongomock
) that requires setuptools
to work, but it isn't defined as a requirement and thus not added to the pex by Pants. Right now I work around it by explicitly adding setuptools
as a dependency to all the python_library()
with code that uses mongomock
, but it would be nice if I somehow could tell Pants to always pull in setuptools
when something wants mongomock
.fast-nail-55400
08/21/2021, 10:11 PMpython_requirement_library
for mongomock
and add a dependency on setuptools
fast-nail-55400
08/21/2021, 10:16 PMpython_requirements
macro and any python_requirement_library
it makes for mongomock
(python_requirements
creates python_requirement_library
targets in its implementation and does not appear to have a way to exclude a requirement from being turned into a target in favor of your manual creation of the `python_requirement_library`target)fast-nail-55400
08/21/2021, 10:17 PMpython_requirements
)narrow-vegetable-37489
08/21/2021, 10:30 PMpython_requirements
, so I imagine it clashing with python_requirement_library
one way or another. Worth giving it a shot though and see what happens :)fast-nail-55400
08/22/2021, 1:16 AMpython_requirements
to support excluding certain packageshappy-kitchen-89482
08/22/2021, 4:35 AMmongomock
from the requirements.txt
that python_requirements
references?happy-kitchen-89482
08/22/2021, 8:54 PMpython_requirement_library()
in the same BUILD file, so it's still available as mongomock
in that BUILD filehappy-kitchen-89482
08/22/2021, 8:54 PMrequirements.txt
for other reasons?enough-analyst-54434
08/22/2021, 9:44 PM^jsirois@gill ~/dev/pantsbuild/jsirois-pants (main *) $ cat 3rdparty/python/BUILD.mongomock
python_requirement_library(
name="mongomock-fixed",
requirements=["mongomock", "pymongo"],
dependencies=["3rdparty/python:setuptools"],
)
^jsirois@gill ~/dev/pantsbuild/jsirois-pants (main *) $ cat src/python/pants/mongomock/BUILD
python_tests(name='tests')
^jsirois@gill ~/dev/pantsbuild/jsirois-pants (main *) $ cat src/python/pants/mongomock/mongomock_test.py
import mongomock
@mongomock.patch(servers=(('<http://server.example.com|server.example.com>', 27017),))
def test_test():
pass
For ./pants test src/python/pants/mongomock/mongomock_test.py
.enough-analyst-54434
08/22/2021, 9:46 PMsetuptools
requirement defined anywhere else, you could just add it to the list of requirements
in the python_requirement_library
.happy-kitchen-89482
08/23/2021, 12:10 AMrequirements=[...]
bit.narrow-vegetable-37489
08/23/2021, 11:16 AMrequirements.txt
from a pyproject.toml
so Poetry's venv can still be used for the dependencies in PyCharm etc. - so we could simply remove mongomock
from the requirements.txt
and add it manually with python_requirement_library
as you suggest. We do however currently use the same requirements.txt
as the source for requirement_constraints
, and that would still require mongomock
in the file to work, correct? We could generate two files I suppose and remove mongomock
from one of them, but the plan was to migrate to the new poetry_requirements
macro, but I get the feeling that it would at this point cause more harm than good if I want to make my mongomock
life eaiser 🙂enough-analyst-54434
08/23/2021, 1:57 PMrequirement_constraints
? Do you use (loose) requirements straight from requirements.txt or do you use a script like the one suggested here to generate a pinned constraints file to simulate a lock file? I'm guessing the former. The latter though would work with part of your requirements being in requirements.txt and part being in python_requirement_library
targets.narrow-vegetable-37489
08/23/2021, 2:03 PMpoetry export --without-hashes
for the requirements.txt. If I export with hashes in a separate file for requirement_constraints
and then run for example ./pants fmt ::
, Pants (or rather pip) complains that hashes are required for all dependencies and docformatter
does not have any - but that's a separate issue 🙂enough-analyst-54434
08/23/2021, 2:14 PMhappy-kitchen-89482
08/23/2021, 7:27 PMrequirements.txt
in another one with -r
right? And I think Pants will ignore those lines? Maybe there's a workaround there somehow