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 parse "None" exception #2474

Closed
3 tasks done
dbalabka opened this issue May 29, 2020 · 4 comments
Closed
3 tasks done

Unable to parse "None" exception #2474

dbalabka opened this issue May 29, 2020 · 4 comments
Labels
kind/bug Something isn't working as expected status/duplicate Duplicate issues

Comments

@dbalabka
Copy link

dbalabka commented May 29, 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).
  • MacOS Catalina 10.15.4:
  • 1.0.5:

Issue

Trying to add a new package into a new project using add command and URL https://github.com/lyst/lightfm/archive/1.15.tar.gz
but getting following error:

➜  test-poetry poetry add https://github.com/lyst/lightfm/archive/1.15.tar.gz -vvv
Creating virtualenv test-poetry-ZlQuSTS_-py3.6 in /Users/torinaki/Library/Caches/pypoetry/virtualenvs
Using virtualenv: /Users/torinaki/Library/Caches/pypoetry/virtualenvs/test-poetry-ZlQuSTS_-py3.6

[ParseVersionError]
Unable to parse "None".

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

Steps to reproduce:

  1. poetry init
  2. poetry add https://github.com/lyst/lightfm/archive/1.15.tar.gz -vvv
@dbalabka dbalabka added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels May 29, 2020
@dbalabka
Copy link
Author

dbalabka commented May 29, 2020

So the problem is that poetry tries to parse setup.py file and get information from AST:
https://github.com/dbalabka/poetry/blob/d0a8aeda3ec68849b0a84ea5279b0642acbb31ff/poetry/utils/setup_reader.py#L68
while the version is set dynamically:
https://github.com/lyst/lightfm/blob/1.15/setup.py#L151

@finswimmer
Copy link
Member

Hello @dbalabka,

at the moment there is no way poetry can find out the version if it's set dynamically. However, there are some discussion how we can implement this. See #2296

fin swimmer

@finswimmer finswimmer added status/duplicate Duplicate issues and removed status/triage This issue needs to be triaged labels Jun 1, 2020
@dbalabka
Copy link
Author

dbalabka commented Jun 1, 2020

@finswimmer right now I don't have any possibility to install this package using Poetry, however I can fallback to pip. IMO if it is possible to install it using pip then it should be possible to install it using poetry.

As I understood from #2296 discussion there two main concerns about executing setup.py: security and performance.

I would suggest the following option to fix my issue. In my particular case, version metadata can not be determined from setup.py AST. So there should be a possibility to provide explicitly missing metadata in pyproject.toml.

For example, PHP's Composer gives the possibility to specify version using aliases:

{
    "require": {
        "monolog/monolog": "dev-bugfix as 1.0.x-dev"
    }
}

https://getcomposer.org/doc/articles/aliases.md#require-inline-alias
In this particular example dev-bugfix branch's version, will be overridden with 1.0.x-dev.

Also, IMO Poetry's error message Unable to parse "None" should be improved, because it does not provide enough information what exactly happened. Instead, it should report something like "Version metadata is missing."

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 status/duplicate Duplicate issues
Projects
None yet
Development

No branches or pull requests

2 participants