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

TypeError: invalid file: PosixPath('...') with Python 3.5 #2931

Closed
3 tasks done
mikenerone opened this issue Sep 17, 2020 · 2 comments · Fixed by #2954
Closed
3 tasks done

TypeError: invalid file: PosixPath('...') with Python 3.5 #2931

mikenerone opened this issue Sep 17, 2020 · 2 comments · Fixed by #2954
Labels
kind/bug Something isn't working as expected

Comments

@mikenerone
Copy link

mikenerone commented Sep 17, 2020

  • 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: MacOS 10.15.6

  • Poetry version: 1.1.0b2

Issue

Poetry 1.1.x intends to maintain compatibility with Python 3.5, but there's currently a bug in 1.1.0b2 that causes the file download to fail for a URL dependency. I believe the only relevant line of my pyproject.toml is this dep:

beautifulsoup4 = {url = "https://files.pythonhosted.org/packages/66/25/ff030e2437265616a1e9b25ccc864e0371a0bc3adb7c5a404fd661c6f4f6/beautifulsoup4-4.9.1-py3-none-any.whl"}

To explain, this was discussed in chat, and is a workaround for the Python-version metadata being wrong in PyPI, leading to an unsolvable dep tree. Already fixed upstream, but not yet released, and I believe this bug is valid regardless.

Example stack trace - the command I ran here was simply poetry lock:

TypeError

invalid file: PosixPath('/tmp/tmplltfjswb/beautifulsoup4-4.9.1-py3-none-any.whl')

Traceback (most recent call last):
  File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/clikit/api/command/command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/cleo/commands/command.py", line 92, in wrap_handle
    return self.handle()
  File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/poetry/console/commands/lock.py", line 26, in handle
    return self._installer.run()
  File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/poetry/installation/installer.py", line 99, in run
    return self._do_install(local_repo)
  File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/poetry/installation/installer.py", line 205, in _do_install
    ops = solver.solve(use_latest=self._whitelist)
  File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/poetry/puzzle/solver.py", line 65, in solve
    packages, depths = self._solve(use_latest=use_latest)
  File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/poetry/puzzle/solver.py", line 215, in _solve
    self._package, self._provider, locked=locked, use_latest=use_latest
  File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/poetry/mixology/__init__.py", line 7, in resolve_version
    return solver.solve()
  File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/poetry/mixology/version_solver.py", line 84, in solve
    next = self._choose_package_version()
  File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/poetry/mixology/version_solver.py", line 392, in _choose_package_version
    version = self._provider.complete_package(version)
  File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/poetry/puzzle/provider.py", line 481, in complete_package
    self.search_for_url(r)
  File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/poetry/puzzle/provider.py", line 332, in search_for_url
    package = self.get_package_from_url(dependency.url)
  File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/poetry/puzzle/provider.py", line 361, in get_package_from_url
    download_file(url, temp_dir / file_name)
  File "/home/mike.nerone/myapp/.tox/.poetry/lib/python3.5/site-packages/poetry/utils/helpers.py", line 99, in download_file
    with open(dest, "wb") as f:

The problem is that in Python 3.5, open() is not yet pathlib-aware, so needs to be passed the file path as a string (or alternatively, use dest.open()).

@mikenerone mikenerone added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Sep 17, 2020
@mikenerone
Copy link
Author

Confirmed bug remains in Poetry 1.1.0b4.

abn added a commit to abn/poetry that referenced this issue Sep 23, 2020
@abn abn removed the status/triage This issue needs to be triaged label Sep 23, 2020
finswimmer pushed a commit to finswimmer/poetry that referenced this issue Sep 24, 2020
Copy link

github-actions bot commented Mar 3, 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 3, 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