Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to pip output from one pip-run to another pip-run #36

Closed
jaraco opened this issue Nov 12, 2018 · 2 comments
Closed

Unable to pip output from one pip-run to another pip-run #36

jaraco opened this issue Nov 12, 2018 · 2 comments

Comments

@jaraco
Copy link
Owner

jaraco commented Nov 12, 2018

Consider the use-case where you want to test the encoding/decoding of some string against two versions of a library. You could do two invocations of pip-run:

$ pip-run -q itsdangerous==0.24 -- -c "import itsdangerous; print(itsdangerous.Signer(b'secret-key').sign(b'my string').decode('ascii'))"
my string.wh6tMHxLgJqB6oY1uT73iMlyrOA
$ echo 'my string.wh6tMHxLgJqB6oY1uT73iMlyrOA' | pip-run -q itsdangerous==1.1 -- -c "import itsdangerous, sys; print(itsdangerous.Signer('secret-key').unsign(sys.stdin.read()))"
...

And that works fine, but anyone who has spent more than 30 seconds in Unix would expect to be able to take the output of the first command and pipe it into the second command to avoid having to emit and then re-enter the intermediate result. However, if you do this with pip-run, it fails with a BrokenPipeError:

~ $ pip-run -q itsdangerous==0.24 -- -c "import itsdangerous; print(itsdangerous.Signer(b'secret-key').sign(b'my string').decode('ascii'))" | pip-run -q itsdangerous==1.1 -- -c "import itsdangerous, sys; print(itsdangerous.Signer('secret-key').unsign(sys.stdin.read()))"
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/bin/pip-run", line 11, in <module>
    sys.exit(run())
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip_run/__init__.py", line 18, in run
    with deps.load(*deps.not_installed(pip_args)) as home:
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip_run/deps.py", line 74, in load
    with _patch_prefix():
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip_run/deps.py", line 89, in _patch_prefix
    with _save_file(cfg_fn):
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/contextlib.py", line 112, in __enter__
    return next(self.gen)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip_run/deps.py", line 104, in _save_file
    raise NotImplementedError(tmpl.format(**locals()))
NotImplementedError: Unsupported with extant /Users/jaraco/.pydistutils.cfg
Exception ignored in: <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>
BrokenPipeError: [Errno 32] Broken pipe

This all would work except for the (undocumented) caveat that pip-run relies on ~/.pydistutils.cfg to inject certain functionality... and so two invocations of pip-run cannot run simultaneously for the same user.

Here is the code that invokes this behavior, which implicates #14 and pypa/pip#4106.

This issue only affects invocations where the pip install commands from pip-run overlap.

@jaraco
Copy link
Owner Author

jaraco commented Nov 12, 2018

pip-run 5.2 allows setting PIP_RUN_NO_PATCH_PREFIX to bypass this behavior for environments that are unaffected.

@jaraco jaraco closed this as completed in 6203b1a Nov 12, 2018
@jaraco
Copy link
Owner Author

jaraco commented Nov 12, 2018

Even better, pip-run 5.3 auto-detects the condition that will fail and applies the workaround there. This way, no environment variable is needed.

jaraco pushed a commit that referenced this issue Jun 25, 2021
This change adds `nitpicky=True` (which is an equivalent of `-n`) to
make Sphinx emit warnings for any references to non-existing targets.
Then, it adds `-W` to make it fail whenever a single warning is seen.
Finally, `--keep-going` allows Sphinx to print out all the warnings
before exiting instead of showing just one and bailing.

Resolves #29

Refs:
* https://www.sphinx-doc.org/en/master/man/sphinx-build.html#cmdoption-sphinx-build-n
* https://www.sphinx-doc.org/en/master/man/sphinx-build.html#cmdoption-sphinx-build-W
* https://www.sphinx-doc.org/en/master/man/sphinx-build.html#cmdoption-sphinx-build-keep-going
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant