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

[BUG] KeyError: 'version' for library that uses poetry #467

Closed
jacobtomlinson opened this issue May 10, 2023 · 1 comment · Fixed by #471
Closed

[BUG] KeyError: 'version' for library that uses poetry #467

jacobtomlinson opened this issue May 10, 2023 · 1 comment · Fixed by #471
Assignees
Labels
bug Something isn't working

Comments

@jacobtomlinson
Copy link

Describe the bug
I'm getting a KeyError: 'version' error when trying to run grayskull pypi kr8s.

It's very likely that I've done something wrong when packaging kr8s for PyPI, this is my first time using Poetry for publishing to PyPI. However the error I'm seeing in grayskull isn't very helpful.

To Reproduce

$ conda install -c conda-forge grayskull
$ grayskull pypi kr8s
#### Initializing recipe for kr8s (pypi) ####

Recovering metadata from pypi...
Starting the download of the sdist package kr8s
kr8s 100% Time:  0:00:00   9.2 MiB/s|#######################################################################################################################################################################################################|
Checking for pyproject.toml
pyproject.toml found in /tmp/grayskull-kr8s-iyvebryq/kr8s-0.4.0/pyproject.toml
Traceback (most recent call last):
  File "/home/jacob/miniconda3/envs/kr8s/bin/grayskull", line 10, in <module>
    sys.exit(main())
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/site-packages/grayskull/__main__.py", line 276, in main
    generate_recipes_from_list(args.pypi_packages, args)
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/site-packages/grayskull/__main__.py", line 299, in generate_recipes_from_list
    recipe, config = create_python_recipe(
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/site-packages/grayskull/__main__.py", line 334, in create_python_recipe
    GrayskullFactory.create_recipe(
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/site-packages/grayskull/base/factory.py", line 46, in create_recipe
    GrayskullFactory.REGISTERED_STRATEGY[repo_type.lower()].fetch_data(
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/site-packages/grayskull/strategy/pypi.py", line 60, in fetch_data
    update_recipe(recipe, config, sections or ALL_SECTIONS)
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/site-packages/grayskull/strategy/pypi.py", line 485, in update_recipe
    metadata = get_metadata(recipe, config)
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/site-packages/grayskull/strategy/pypi.py", line 347, in get_metadata
    sdist_metadata, pypi_metadata = get_origin_wise_metadata(config)
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/site-packages/grayskull/strategy/pypi.py", line 232, in get_origin_wise_metadata
    sdist_metadata = get_sdist_metadata(
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/site-packages/grayskull/strategy/py_base.py", line 771, in get_sdist_metadata
    pyproject_metadata = get_all_toml_info(pyproject_toml)
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/site-packages/grayskull/strategy/py_toml.py", line 263, in get_all_toml_info
    add_poetry_metadata(metadata, toml_metadata)
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/site-packages/grayskull/strategy/py_toml.py", line 215, in add_poetry_metadata
    test_reqs, _ = encode_poetry_deps(poetry_test_deps)
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/site-packages/grayskull/strategy/py_toml.py", line 180, in encode_poetry_deps
    constrained_dep = get_constrained_dep(dep_spec, dep_name)
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/functools.py", line 889, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
  File "/home/jacob/miniconda3/envs/kr8s/lib/python3.10/site-packages/grayskull/strategy/py_toml.py", line 166, in __get_constrained_dep_dict
    conda_version = encode_poetry_version(dep_spec["version"])
KeyError: 'version'

Expected behavior
It generates the recipe.

Environment:

  • grayskull 2.3.0
@jacobtomlinson jacobtomlinson added the bug Something isn't working label May 10, 2023
@marcelotrevisani
Copy link
Member

I will put this on my todo, It seems it needs a couple adjustments for poetry
Thanks for reporting it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants