jaraco / pip-run

pip-run - dynamic dependency loader for Python
MIT License
137 stars 19 forks source link

Remove inline whitespaces from particular requirements from `read-deps` #111

Closed bswck closed 4 months ago

bswck commented 4 months ago

Having requirements with markers,

# foo.py
__requires__ = [
    'importlib_resources; python_version < "3.12"',
    "tempora"
]

python -m pip_run.read-deps foo.py will output importlib_resources; python_version < "3.12" tempora, which is unparsable by tools like pip. Let's remove any spaces from particular output requirements to allow parsing markers and when installing via CLI from a listing coming from a subshell:

pip install $(python -m pip_run.read-deps foo.py) -> pip install importlib_resources;python_version<"3.12" tempora

bswck commented 4 months ago

A workaround is to just dump requirements to a file with -s newline and pip install -r from it, as long as https://github.com/pypa/pip/issues/7822 is open (which would allow echo $(python -m pip_run.read-deps ... -s newline) | pip install -r -).