Fix extract_single_wheel for Windows#498
Conversation
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
|
@googlebot I signed it! |
| try: | ||
| os.unlink(requirement_file.name) | ||
| except OSError: | ||
| pass |
There was a problem hiding this comment.
Ignoring this exception seems unsafe.
There was a problem hiding this comment.
This is in case, for whatever reason, the file is not present. Seems very unlikely though, I can remove it if you prefer.
There was a problem hiding this comment.
It was inspired by: https://bugs.python.org/msg157925
There was a problem hiding this comment.
I doesn't seem too unsafe to me, as the pip subprocess would already have been run. As long as any errors from the subprocess aren't swallowed here it should be okay.
There was a problem hiding this comment.
| pass | |
| except OSError as e: | |
| if e.errno != errno.ENOENT: | |
| raise |
Is probably better than catching any error.
| pip_args += json.loads(args.extra_pip_args)["args"] | ||
|
|
||
| with NamedTemporaryFile(mode='wb') as requirement_file: | ||
| requirement_file = NamedTemporaryFile(mode='wb', delete=False) |
There was a problem hiding this comment.
This is due to Python holding a handle to the temporary file preventing pip, which is run as a sub-process, from reading it.
Interesting. This looks to contain elaboration of the issue https://bugs.python.org/issue14243
python/pip_install/parse_requirements_to_bzl/extract_single_wheel/__init__.py
Show resolved
Hide resolved
|
@easybe are you able to refresh against |
On Windows, when using pip_parse, pip would fail with following error:
Could not open requirements file: [Errno 13] Permission denied: ...
This is due to Python holding a handle to the temporary file preventing
pip, which is run as a sub-process, from reading it. For more
information, see: https://bugs.python.org/issue14243
Closing the requirements file before running pip solves the problem.
Done |
On Windows, when using pip_parse, pip would fail with following error:
This is due to Python holding a handle to the temporary file preventing
pip, which is run as a sub-process, from reading it. For more
information, see: https://bugs.python.org/issue14243
Closing the requirements file before running pip solves the problem.
PR Checklist
Please check if your PR fulfills the following requirements:
.parfiles. See CONTRIBUTING.md for infoPR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
pip_parseworks on Windows.Does this PR introduce a breaking change?
Other information