little-fall-7103
10/13/2022, 3:11 PMinstall_requires
, extras_require
, etc.)
Does pants offer a way to generate python_requirement
targets for my third party dependencies from the existing setup.py file? Similar to the `python_requirements`/`poetry_requirements` generators?happy-kitchen-89482
10/13/2022, 3:55 PMhappy-kitchen-89482
10/13/2022, 3:56 PMhappy-kitchen-89482
10/13/2022, 3:56 PMlittle-fall-7103
10/13/2022, 4:10 PMfuture-oxygen-10553
10/13/2022, 4:20 PMinstall_requires
et al. which is set in the script before being passed into the setup
function, you can exec
the file and store the local variables into a dictionary. You could do that in a plugin, probably, or at least print them out without requiring deprecated distutilsfuture-oxygen-10553
10/13/2022, 4:22 PM__version__
out of __init__.py
without having to import the package in questionfuture-oxygen-10553
10/13/2022, 4:26 PMhigh-yak-85899
10/13/2022, 10:44 PMdef gather_install_requires() -> List[str]:
req_file = pathlib.Path(__file__).parent / 'requirements.txt'
return [
req for req in req_file.read_text().splitlines()
if not (req.startswith('#') or 'git+ssh' in req)
]
Then I just call that function inside setup.py
like install_requires=gather_install_requires()
. Hacky thing is removing some requirements for our internal repos that we list in that file.high-yak-85899
10/13/2022, 10:45 PMhappy-kitchen-89482
10/13/2022, 11:47 PMhappy-kitchen-89482
10/13/2022, 11:47 PMhappy-kitchen-89482
10/13/2022, 11:47 PM