conda / grayskull

Grayskull :skull: - Recipe generator for Conda
https://conda.github.io/grayskull/
Apache License 2.0
322 stars 69 forks source link

[BUG] utils.format_dependencies returns error for single value dependencies list #455

Closed CatChenal closed 1 year ago

CatChenal commented 1 year ago

I am creating a new build for my conda-forge package to reflect the change in setup files: from setup.py + requirements.txt to single pyproject.toml file.
I successfully used grayskull to produce the meta.yml on the 1st build (with the contents of requirements.txt being just conda), but now, the assertion made on line 165 of format_dependencies fails and I do not understand why.

Envir miniconda on Windows 10 python 3.10 grayskull version: 2.2.2

Steps I used this command to generate a meta.yml file for my repo:
grayskull pypi https://github.com/CatChenal/new_conda_env

This is my pyproject.toml file:

[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "new_conda_env"
description = "A Python package for generating a 'lean' environment yaml file (see README)."
version = "0.1.0"
license = "MIT license"
requires-python = ">=3.6"
keywords = ["conda", "env", "tool"]
dependencies = ["conda"]                      # fails 
authors = [{name = "Cat Chenal"}]

[project.scripts]
new-conda-env = "new_conda_env.cli:main"

classifiers = [
        "Development Status :: 2 - Pre-Alpha",
        "Intended Audience :: Developers",
        "License :: OSI Approved :: MIT License",
        "Natural Language :: English",
        "Programming Language :: Python :: 3.6",
        "Programming Language :: Python :: 3.7",
        "Programming Language :: Python :: 3.8",
        "Programming Language :: Python :: 3.9",
        "Programming Language :: Python :: 3.10",
    ]
[tool.setuptools.dynamic]
readme = {file = ["README.md"], content-type = "text/plain"}

Grayskull returns an error from format_dependencies with this Traceback:

  File "C:\Users\me\miniconda3\envs\for_pkg\Scripts\grayskull-script.py", line 9, in <module>
    sys.exit(main())
  File "C:\Users\me\miniconda3\envs\for_pkg\lib\site-packages\grayskull\__main__.py", line 271, in main
    generate_recipes_from_list(args.pypi_packages, args)
  File "C:\Users\me\miniconda3\envs\for_pkg\lib\site-packages\grayskull\__main__.py", line 294, in generate_recipes_from_list
    recipe, config = create_python_recipe(
  File "C:\Users\me\miniconda3\envs\for_pkg\lib\site-packages\grayskull\__main__.py", line 329, in create_python_recipe
    GrayskullFactory.create_recipe(
  File "C:\Users\me\miniconda3\envs\for_pkg\lib\site-packages\grayskull\base\factory.py", line 46, in create_recipe
    GrayskullFactory.REGISTERED_STRATEGY[repo_type.lower()].fetch_data(
  File "C:\Users\me\miniconda3\envs\for_pkg\lib\site-packages\grayskull\strategy\pypi.py", line 60, in fetch_data
    update_recipe(recipe, config, sections or ALL_SECTIONS)
  File "C:\Users\me\miniconda3\envs\for_pkg\lib\site-packages\grayskull\strategy\pypi.py", line 484, in update_recipe
    metadata = get_metadata(recipe, config)
  File "C:\Users\me\miniconda3\envs\for_pkg\lib\site-packages\grayskull\strategy\pypi.py", line 382, in get_metadata
    requirements_section = extract_requirements(metadata, config, recipe)
  File "C:\Users\me\miniconda3\envs\for_pkg\lib\site-packages\grayskull\strategy\pypi.py", line 520, in extract_requirements
    requires_dist = format_dependencies(metadata.get("requires_dist", []), name)
  File "C:\Users\me\miniconda3\envs\for_pkg\lib\site-packages\grayskull\utils.py", line 165, in format_dependencies
    if deps_name.replace("-", "_") == name.replace("-", "_"):
AttributeError: 'NoneType' object has no attribute 'replace'

Expected behavior No error?

What is the comparison on line 165 doing: deps_name.replace("-", "_") == name.replace("-", "_")? Why is it failing with my pyproject.toml, i.e. what is wrong with dependencies = ["conda"]?

Thanks for your help!

BastianZim commented 1 year ago

I'm seeing the same with https://github.com/DevAlvaroF/HYPSO-Reading

marcelotrevisani commented 1 year ago

latest version fixed this bug

Thanks for reporting it! :)