Poetry: Poetry is not able to handle URLs correctly: ParseVersionError: Unable to parse None

Created on 25 Aug 2020  ·  7Comments  ·  Source: python-poetry/poetry

  • [X] I am on the latest Poetry version.
  • [X] I have searched the issues of this repo and believe that this is not a duplicate.
  • [X] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: Linux, Arch Linux
  • Poetry version: 1.0.10
  • contents of your pyproject.toml file:
[tool.poetry]
name = "avency-blockctl"
version = "0.1.0"
description = "blocklist management tool for Forcepoint NGFW"
authors = ["Christian Rebischke <[email protected]>"]

[tool.poetry.dependencies]
python = "^3.8"
pyyaml = "^5.3.1"
requests = "^2.24.0"
ipaddress = "^1.0.23"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

Issue


Hi,
I just switched from virtualenvwrapper or plain pyenv to poetry. So maybe I am just doing something wrong.
I try to add a dependency for my project, that consists out of an URL:

https://github.com/Forcepoint/fp-NGFW-SMC-python/archive/4c004e86b2bc2bd2870e57687e3ac8af9d42abbf.tar.gz#egg=fp-ngfw-smc-python

Looks like poetry cannot handle this?

Command + output:

❯ poetry add -vvv 'https://github.com/Forcepoint/fp-NGFW-SMC-python/archive/4c004e86b2bc2bd2870e57687e3ac8af9d42abbf.tar.gz#egg=fp-ngfw-smc-python'
Using virtualenv: /home/chris/.cache/pypoetry/virtualenvs/avency-blockctl-OZBv3Rqq-py3.8

[ParseVersionError]
Unable to parse "None".

Traceback:

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/usr/lib/python3.8/site-packages/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/usr/lib/python3.8/site-packages/clikit/api/command/command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "/usr/lib/python3.8/site-packages/cleo/commands/command.py", line 92, in wrap_handle
    return self.handle()
  File "/usr/lib/python3.8/site-packages/poetry/console/commands/add.py", line 95, in handle
    requirements = self._determine_requirements(
  File "/usr/lib/python3.8/site-packages/poetry/console/commands/init.py", line 293, in _determine_requirements
    requires = self._parse_requirements(requires)
  File "/usr/lib/python3.8/site-packages/poetry/console/commands/init.py", line 388, in _parse_requirements
    package = Provider.get_package_from_url(requirement)
  File "/usr/lib/python3.8/site-packages/poetry/puzzle/provider.py", line 503, in get_package_from_url
    package = cls.get_package_from_file(temp_dir / file_name)
  File "/usr/lib/python3.8/site-packages/poetry/puzzle/provider.py", line 271, in get_package_from_file
    package = Package(info["name"], info["version"])
  File "/usr/lib/python3.8/site-packages/poetry/packages/package.py", line 46, in __init__
    self._version = Version.parse(version)
  File "/usr/lib/python3.8/site-packages/poetry/semver/version.py", line 206, in parse
    raise ParseVersionError('Unable to parse "{}".'.format(text))
candidatfaq

All 7 comments

Is there any way to set this URL manually? Would be a shame if I cannot use poetry, just because it's not able to do basic tasks (pip install -r requirements.txt works fine).

Hello @shibumi,

the problem here is not the URL but that the version is dynamically read into the setup.py. poetry cannot handle this in the current stable release, but will in the next minor release.

Be aware that for this poetry needs to create a separate build environment, run the build process (to be more precious "run the prepare-metadata-for-build-wheel for setuptools"), parse the metadata and remove all data again. Lots of overhead. So I recommend to make version and requirements static and put it into the setup.py whenever possible.

fin swimmer

Hi @finswimmer
I don't maintain the upstream project so I can't modify the setup.py. Good to hear, that this will be supported, but is there really no way to at least add the URL manually to poetry for at least working with it? This is actually something I would have expected from a 1.x.x release :S I mean it does work with pip install -r requirements.txt

Hi @shibumi,

of course you can add the url manually to the pyproject.toml. See here.

But this will not help you, because poetry still needs to parse the metadata of this source and this will fail due to the point mentioned above. The problem ist not the url, it's how the metadata are provided by the source.

fin swimmer

To add to @finswimmer 's point, poetry specifically requires the dependencies from the associated metadata so that the resolver (as mentioned above) can work. You can install your package into your environment without adding it to your dependencies using poetry run pip install <url>. But this negates the purpose of using poetry to manage your package dependencies and any build artifacts will not contain this dependency.

@abn this is exactly I was looking for and it's fine by now. This way I can use poetry + wait for the release.

Closing this as this is a known limitation of poetry<=1.0.10. As mentioned above version 1.1.0 improves the situation, but we cannot truly get away from bad package metadata.

Was this page helpful?
0 / 5 - 0 ratings