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

Windows PyPy3 wheel builds crash due to unclosed file #3545

Closed
3 tasks done
kurtmckee opened this issue Jan 6, 2021 · 1 comment · Fixed by python-poetry/poetry-core#122
Closed
3 tasks done

Windows PyPy3 wheel builds crash due to unclosed file #3545

kurtmckee opened this issue Jan 6, 2021 · 1 comment · Fixed by python-poetry/poetry-core#122
Labels
kind/bug Something isn't working as expected

Comments

@kurtmckee
Copy link

  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: Windows 10 Home Version 20H2 OS Build 19042.685
  • Python version: PyPy3.6 version 7.3.3, and PyPy3.7 version 7.3.3
  • Poetry version: 1.1.4
  • Link of a Gist with the contents of your pyproject.toml file: feedparser pyproject.toml @ 727ee7f

Issue

Poetry crashes when building wheels on Windows when using PyPy3.6 and PyPy3.7. The root cause is an unclosed file in poetry/core/masonry/builders/wheel.py, which causes shutil.move() to fail with a PermissionError. Here are the steps to reproduce. Note that I am using Powershell, so some commands may require syntax changes if you're reproducing in cmd.exe.

  1. Download either PyPy3.6 or PyPy3.7 from pypy.org. Extract somewhere. In my case, I extracted to C:\Program Files (x86)\pypy37\.
  2. Clone feedparser from git: git clone https://github.com/kurtmckee/feedparser.git
  3. Change directories: cd feedparser
  4. Checkout 727ee7f to ensure reproducibility: git checkout 727ee7f
  5. Prepare a virtual environment: & 'C:\Program Files (x86)\pypy37\pypy3.exe' -m venv venv-pypy37
  6. Activate the virtual environment: .\venv-pypy37\Scripts\Activate.ps1
  7. Update pip: pypy3 -m pip install --upgrade pip
  8. Install poetry: pypy3 -m pip install poetry
  9. Copy pypy3.exe to python.exe so Poetry can run "python": copy .\venv-pypy37\Scripts\pypy3.exe .\venv-pypy37\Scripts\python.exe
  10. Use poetry to install dependencies: poetry update
  11. Build feedparser: poetry build

The output that I get is a traceback:

(venv-pypy37) C:\Users\Kurt\Documents\dev\demo-poetry-issue\feedparser [(727ee7f...) +1 ~0 -0 !]> poetry build
Building feedparser (6.0.2)
  - Building sdist
  - Built feedparser-6.0.2.tar.gz
  - Building wheel

  PermissionError

  [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\Kurt\\AppData\\Local\\Temp\\tmpuv5ngrf4.whl'

  at C:\Program Files (x86)\pypy37\lib-python\3\shutil.py:581 in move
       577│                      symlinks=True)
       578│             rmtree(src)
       579│         else:
       580│             copy_function(src, real_dst)
Traceback (most recent call last):
  File "C:\Program Files (x86)\pypy37\lib-python\3\shutil.py", line 566, in move
    os.rename(src, real_dst)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\Kurt\\AppData\\Local\\Temp\\tmpuv5ngrf4.whl' -> 'C:\\Users\\Kurt\\Documents\\dev\\demo-poetry-issue\\feedparser\\dist\\feedparser-6.0.2-py3-none-any.whl'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\kurt\documents\dev\demo-poetry-issue\feedparser\venv-pypy37\site-packages\clikit\console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "c:\users\kurt\documents\dev\demo-poetry-issue\feedparser\venv-pypy37\site-packages\clikit\api\command\command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "c:\users\kurt\documents\dev\demo-poetry-issue\feedparser\venv-pypy37\site-packages\clikit\api\command\command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "c:\users\kurt\documents\dev\demo-poetry-issue\feedparser\venv-pypy37\site-packages\cleo\commands\command.py", line 92, in wrap_handle
    return self.handle()
  File "c:\users\kurt\documents\dev\demo-poetry-issue\feedparser\venv-pypy37\site-packages\poetry\console\commands\build.py", line 36, in handle
    builder.build(fmt, executable=self.env.python)
  File "c:\users\kurt\documents\dev\demo-poetry-issue\feedparser\venv-pypy37\site-packages\poetry\core\masonry\builder.py", line 30, in build
    builder(self._poetry, executable=executable).build()
  File "c:\users\kurt\documents\dev\demo-poetry-issue\feedparser\venv-pypy37\site-packages\poetry\core\masonry\builders\wheel.py", line 97, in build
    shutil.move(temp_path, str(wheel_path))
  File "C:\Program Files (x86)\pypy37\lib-python\3\shutil.py", line 581, in move
    os.unlink(src)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\Kurt\\AppData\\Local\\Temp\\tmpuv5ngrf4.whl'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\pypy37\lib-python\3\runpy.py", line 196, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Program Files (x86)\pypy37\lib-python\3\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\Kurt\Documents\dev\demo-poetry-issue\feedparser\venv-pypy37\Scripts\poetry.exe\__main__.py", line 7, in <module>
    sys.exit(main())
  File "c:\users\kurt\documents\dev\demo-poetry-issue\feedparser\venv-pypy37\site-packages\poetry\console\__init__.py", line 5, in main
    return Application().run()
  File "c:\users\kurt\documents\dev\demo-poetry-issue\feedparser\venv-pypy37\site-packages\clikit\console_application.py", line 142, in run
    trace.render(io, simple=isinstance(e, CliKitException))
  File "c:\users\kurt\documents\dev\demo-poetry-issue\feedparser\venv-pypy37\site-packages\clikit\ui\components\exception_trace.py", line 232, in render
    return self._render_exception(io, self._exception)
  File "c:\users\kurt\documents\dev\demo-poetry-issue\feedparser\venv-pypy37\site-packages\clikit\ui\components\exception_trace.py", line 269, in _render_exception
    self._render_snippet(io, current_frame)
  File "c:\users\kurt\documents\dev\demo-poetry-issue\feedparser\venv-pypy37\site-packages\clikit\ui\components\exception_trace.py", line 289, in _render_snippet
    self._render_line(io, code_line)
  File "c:\users\kurt\documents\dev\demo-poetry-issue\feedparser\venv-pypy37\site-packages\clikit\ui\components\exception_trace.py", line 402, in _render_line
    io.write_line("{}{}".format(indent * " ", line))
  File "c:\users\kurt\documents\dev\demo-poetry-issue\feedparser\venv-pypy37\site-packages\cleo\io\io_mixin.py", line 65, in write_line
    super(IOMixin, self).write_line(string, flags)
  File "c:\users\kurt\documents\dev\demo-poetry-issue\feedparser\venv-pypy37\site-packages\clikit\api\io\io.py", line 66, in write_line
    self._output.write_line(string, flags=flags)
  File "c:\users\kurt\documents\dev\demo-poetry-issue\feedparser\venv-pypy37\site-packages\clikit\api\io\output.py", line 69, in write_line
    self.write(string, flags=flags, new_line=True)
  File "c:\users\kurt\documents\dev\demo-poetry-issue\feedparser\venv-pypy37\site-packages\clikit\api\io\output.py", line 61, in write
    self._stream.write(to_str(formatted))
  File "c:\users\kurt\documents\dev\demo-poetry-issue\feedparser\venv-pypy37\site-packages\clikit\io\output_stream\stream_output_stream.py", line 24, in write
    self._stream.write(string)
  File "C:\Program Files (x86)\pypy37\lib-python\3\encodings\cp437.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2192' in position 11: character maps to <undefined>
(venv-pypy37) C:\Users\Kurt\Documents\dev\demo-poetry-issue\feedparser [(727ee7f...) +1 ~0 -0 !]>

The root cause is an unmanaged os.fdopen() call in poetry/core/masonry/builders/wheel.py that keeps the zip file open when shutil.move() is called.

I've already tested a fix and will submit a PR shortly.

@kurtmckee kurtmckee added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Jan 6, 2021
kurtmckee added a commit to kurtmckee/pr-poetry-core that referenced this issue Jan 7, 2021
kurtmckee added a commit to kurtmckee/pr-poetry-core that referenced this issue Jan 7, 2021
This resolves a crash that occurs on PyPy3 on Windows

Closes python-poetry/poetry#3545
kurtmckee added a commit to kurtmckee/pr-poetry-core that referenced this issue Jan 7, 2021
kurtmckee added a commit to kurtmckee/pr-poetry-core that referenced this issue Jan 7, 2021
This resolves a crash that occurs on PyPy3 on Windows

Closes python-poetry/poetry#3545
brechtm added a commit to brechtm/rinohtype that referenced this issue Jan 28, 2021
- always install tox & co using pip3.9
- additionally install the Python version to test against (if not 3.9)
- this setup allows testing against Python 3.10
- map python-version to a TOXENV manually (obsoletes tox-gh-actions)
- ignore failures of tests running against PyPy for now
  (python-poetry/poetry#3545)
brechtm added a commit to brechtm/rinohtype that referenced this issue Jan 28, 2021
- always install tox & co using pip3.9
- additionally install the Python version to test against (if not 3.9)
- this setup allows testing against Python 3.10
- map python-version to a TOXENV manually (obsoletes tox-gh-actions)
- ignore failures of tests running against PyPy for now
  (python-poetry/poetry#3545)
brechtm added a commit to brechtm/rinohtype that referenced this issue Jan 28, 2021
- always install tox & co using pip3.9
- additionally install the Python version to test against (if not 3.9)
- this setup allows testing against Python 3.10
- map python-version to a TOXENV manually (obsoletes tox-gh-actions)
- ignore failures of tests running against PyPy for now
  (python-poetry/poetry#3545)
brechtm added a commit to brechtm/rinohtype that referenced this issue Jan 28, 2021
- always install tox & co using pip3.9
- additionally install the Python version to test against (if not 3.9)
- this setup allows testing against Python 3.10
- map python-version to a TOXENV manually (obsoletes tox-gh-actions)
- ignore failures of tests running against PyPy for now
  (python-poetry/poetry#3545)
brechtm added a commit to brechtm/rinohtype that referenced this issue Jan 28, 2021
- always install tox & co using pip3.9
- additionally install the Python version to test against (if not 3.9)
- this setup allows testing against Python 3.10
- map python-version to a TOXENV manually (obsoletes tox-gh-actions)
- add a '-pyXY' factor to the TOXENV for the regression tests
- ignore failures of tests running against PyPy for now
  (python-poetry/poetry#3545)
brechtm added a commit to brechtm/rinohtype that referenced this issue Jan 28, 2021
- always install tox & co using pip3.9
- additionally install the Python version to test against (if not 3.9)
- this setup allows testing against Python 3.10
- map python-version to a TOXENV manually (obsoletes tox-gh-actions)
- add a '-pyXY' factor to the TOXENV for the regression tests
- ignore failures of tests running against PyPy for now
  (python-poetry/poetry#3545)
@abn abn removed the status/triage This issue needs to be triaged label Mar 3, 2022
Copy link

github-actions bot commented Mar 2, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants