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] IndexError in match_license() #508

Closed
harry-xm opened this issue Nov 8, 2023 · 4 comments
Closed

[BUG] IndexError in match_license() #508

harry-xm opened this issue Nov 8, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@harry-xm
Copy link

harry-xm commented Nov 8, 2023

Describe the bug
IndexError: list index out of range

To Reproduce
Steps to reproduce the behavior:

  1. Run grayskull pypi fastbencode
  2. See error

Expected behavior
Grayskull does not throw IndexError.

Outputs

Recovering license info from spdx.org ...
Traceback (most recent call last):
  File "$HOME/micromamba/envs/cfstaging/bin/grayskull", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "$HOME/micromamba/envs/cfstaging/lib/python3.12/site-packages/grayskull/main.py", line 277, in main
    generate_recipes_from_list(args.pypi_packages, args)
  File "$HOME/micromamba/envs/cfstaging/lib/python3.12/site-packages/grayskull/main.py", line 300, in generate_recipes_from_list
    recipe, config = create_python_recipe(
                     ^^^^^^^^^^^^^^^^^^^^^
  File "$HOME/micromamba/envs/cfstaging/lib/python3.12/site-packages/grayskull/main.py", line 335, in create_python_recipe
    GrayskullFactory.create_recipe(
  File "$HOME/micromamba/envs/cfstaging/lib/python3.12/site-packages/grayskull/base/factory.py", line 46, in create_recipe
    GrayskullFactory.REGISTERED_STRATEGY[repo_type.lower()].fetch_data(
  File "$HOME/micromamba/envs/cfstaging/lib/python3.12/site-packages/grayskull/strategy/pypi.py", line 62, in fetch_data
    update_recipe(recipe, config, sections or ALL_SECTIONS)
  File "$HOME/micromamba/envs/cfstaging/lib/python3.12/site-packages/grayskull/strategy/pypi.py", line 499, in update_recipe
    metadata = get_metadata(recipe, config)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "$HOME/micromamba/envs/cfstaging/lib/python3.12/site-packages/grayskull/strategy/pypi.py", line 357, in get_metadata
    all_license_metadata = discover_license(metadata)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "$HOME/micromamba/envs/cfstaging/lib/python3.12/site-packages/grayskull/strategy/py_base.py", line 571, in discover_license
    return search_license_file(
           ^^^^^^^^^^^^^^^^^^^^
  File "$HOME/micromamba/envs/cfstaging/lib/python3.12/site-packages/grayskull/license/discovery.py", line 225, in search_license_file
    license_name_metadata = get_short_license_id(license_name_metadata)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "$HOME/micromamba/envs/cfstaging/lib/python3.12/site-packages/grayskull/license/discovery.py", line 129, in get_short_license_id
    recipe_license = match_license(name)
                     ^^^^^^^^^^^^^^^^^^^
  File "$HOME/micromamba/envs/cfstaging/lib/python3.12/site-packages/grayskull/license/discovery.py", line 105, in match_license
    if original_matches[0][1] < 0.55:
       ~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

Environment:

  • conda list
# packages in environment at $HOME/micromamba/envs/cfstaging:
#
# Name                    Version                   Build  Channel
beautifulsoup4            4.12.2             pyha770c72_0    conda-forge
brotli-python             1.1.0           py312heafc425_1    conda-forge
bzip2                     1.0.8                h10d778d_5    conda-forge
ca-certificates           2023.7.22            h8857fd0_0    conda-forge
certifi                   2023.7.22          pyhd8ed1ab_0    conda-forge
charset-normalizer        3.3.2              pyhd8ed1ab_0    conda-forge
colorama                  0.4.6              pyhd8ed1ab_0    conda-forge
conda-souschef            2.2.3              pyhd8ed1ab_0    conda-forge
grayskull                 2.5.1              pyhd8ed1ab_0    conda-forge
idna                      3.4                pyhd8ed1ab_0    conda-forge
libblas                   3.9.0           19_osx64_openblas    conda-forge
libcblas                  3.9.0           19_osx64_openblas    conda-forge
libcxx                    16.0.6               hd57cbcb_0    conda-forge
libexpat                  2.5.0                hf0c8a7f_1    conda-forge
libffi                    3.4.2                h0d85af4_5    conda-forge
libgfortran               5.0.0           13_2_0_h97931a8_1    conda-forge
libgfortran5              13.2.0               h2873a65_1    conda-forge
liblapack                 3.9.0           19_osx64_openblas    conda-forge
libopenblas               0.3.24          openmp_h48a4ad5_0    conda-forge
libsqlite                 3.44.0               h92b6c6a_0    conda-forge
libzlib                   1.2.13               h8a1eda9_5    conda-forge
llvm-openmp               17.0.4               hb6ac08f_0    conda-forge
ncurses                   6.4                  h93d8f39_2    conda-forge
numpy                     1.26.0          py312h5df92dc_0    conda-forge
openssl                   3.1.4                hd75f5a5_0    conda-forge
packaging                 23.2               pyhd8ed1ab_0    conda-forge
pip                       23.3.1             pyhd8ed1ab_0    conda-forge
pkginfo                   1.9.6              pyhd8ed1ab_0    conda-forge
progressbar2              4.2.0              pyhd8ed1ab_0    conda-forge
pysocks                   1.7.1              pyha2e5f31_6    conda-forge
python                    3.12.0          h30d4d87_0_cpython    conda-forge
python-utils              3.8.1              pyhd8ed1ab_0    conda-forge
python_abi                3.12                    4_cp312    conda-forge
rapidfuzz                 3.5.2           py312h444b7ae_0    conda-forge
readline                  8.2                  h9e318b2_1    conda-forge
requests                  2.31.0             pyhd8ed1ab_0    conda-forge
ruamel.yaml               0.18.5          py312h41838bb_0    conda-forge
ruamel.yaml.clib          0.2.7           py312h104f124_2    conda-forge
ruamel.yaml.jinja2        0.2.4                      py_1    conda-forge
semver                    3.0.2              pyhd8ed1ab_0    conda-forge
setuptools                68.2.2             pyhd8ed1ab_0    conda-forge
soupsieve                 2.5                pyhd8ed1ab_1    conda-forge
stdlib-list               0.8.0              pyhd8ed1ab_0    conda-forge
tk                        8.6.13               h1abcd95_1    conda-forge
tomli                     2.0.1              pyhd8ed1ab_0    conda-forge
tomli-w                   1.0.0              pyhd8ed1ab_0    conda-forge
typing_extensions         4.8.0              pyha770c72_0    conda-forge
tzdata                    2023c                h71feb2d_0    conda-forge
urllib3                   2.0.7              pyhd8ed1ab_0    conda-forge
wheel                     0.41.3             pyhd8ed1ab_0    conda-forge
xz                        5.2.6                h775f41a_0    conda-forge
  • pip list
Package            Version
------------------ ---------
beautifulsoup4     4.12.2
Brotli             1.1.0
certifi            2023.7.22
charset-normalizer 3.3.2
colorama           0.4.6
conda-souschef     2.2.3
grayskull          2.5.1
idna               3.4
numpy              1.26.0
packaging          23.2
pip                23.3.1
pkginfo            1.9.6
progressbar2       4.2.0
PySocks            1.7.1
python-utils       3.8.1
rapidfuzz          3.5.2
requests           2.31.0
ruamel.yaml        0.18.5
ruamel.yaml.clib   0.2.7
ruamel.yaml.jinja2 0.2.4
semver             3.0.2
setuptools         68.2.2
soupsieve          2.5
stdlib-list        0.8.0
tomli              2.0.1
tomli_w            1.0.0
typing_extensions  4.8.0
urllib3            2.0.7
wheel              0.41.3
  • grayskull --version
2.5.1

Additional context

@harry-xm harry-xm added the bug Something isn't working label Nov 8, 2023
@larsoner
Copy link

I have this same bug. With some inspection I find:

> /home/larsoner/python/virtualenvs/base/lib/python3.11/site-packages/grayskull/license/discovery.py(129)get_short_license_id()
-> recipe_license = match_license(name)
(Pdb) p name
'GPLv3'

So hopefully this makes it easier to replicate!

@marcelotrevisani
Copy link
Member

which version of fastbencode did you use to generate the recipe?
Because it seems to work fine for me, it generated fine for 0.2

I will try @larsoner suggestion, thanks! :)

@marcelotrevisani
Copy link
Member

can you try to update rapidfuzz to version 3.6.0 please?

@marcelotrevisani
Copy link
Member

ah ok, on main that is fixed, I believe I forgot to generate a new release with this fix, I am generating version 2.5.2 that fixes it.
Fixed with
#507

I am closing this issue, if you think that is not fixed with 2.5.2 please let me know and I will take another look, 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

No branches or pull requests

3 participants