Repository: conda-incubator/grayskull (python)

Issue:
[BUG] Console scripts missed
**Describe the bug**

When adding https://github.com/conda-forge/staged-recipes/pull/12680 an entry point was missed due it being defined in a unusual way: https://github.com/kneufeld/consolemd/blob/3535f556f6f23f875ba8ddfdcf39f4915ce26889/setup.py#L56-L59

**To Reproduce**

```bash
$ grayskull pypi consolemd
#### Initializing recipe for consolemd (pypi) ####

Recovering metadata from pypi...
Starting the download of the sdist package consolemd-0.5.1.tar.gz
```

**Expected behavior**
The following YAML is generated:

```yaml
  entry_points:
    - consolemd = consolemd.cli:cli
```

**Outputs**

```bash
$ rg -C 5 'build:' consolemd/meta.yaml
8-
9-source:
10-  url: https://pypi.io/packages/source/{{ name[0] }}/{{ name }}/consolemd-{{ version }}.tar.gz
11-  sha256: 9bededcc256155ad52194c78a4fb9d9d8e93adc728e7bbdea0ab1eae7f590ebd
12-
13:build:
14-  number: 0
15-  noarch: python
16-  script: {{ PYTHON }} -m pip install . -vv
17-
18-requirements:
```

**Environment:**

```bash
$ grayskull --version
0.8.1


Pull request description:
Add support for toml format in entry_points
Closes #186 

Patch:
diff --git a/environment.yaml b/environment.yaml
index f92f312..3280c53 100644
--- a/environment.yaml
+++ b/environment.yaml
@@ -24,3 +24,5 @@ dependencies:
   - conda-souschef >=2.1.2
   - setuptools-scm
   - pkginfo
+  - tomli
+  - tomli-w
diff --git a/grayskull/strategy/py_base.py b/grayskull/strategy/py_base.py
index 404acba..31bdab4 100644
--- a/grayskull/strategy/py_base.py
+++ b/grayskull/strategy/py_base.py
@@ -13,6 +13,7 @@ from typing import Dict, List, Optional, Tuple, Union
 from urllib.parse import urlparse
 
 import requests
+import tomli
 from colorama import Fore, Style
 from pkginfo import UnpackedSDist
 
@@ -615,11 +616,36 @@ def get_entry_points_from_sdist(sdist_metadata: dict) -> List:
     :return: list with all entry points
     """
     all_entry_points = sdist_metadata.get("entry_points", {})
-    if isinstance(all_entry_points, str) or not all_entry_points:
+    if not all_entry_points:
         return []
+    if isinstance(all_entry_points, str):
+        all_lines = []
+        for line in all_entry_points.splitlines():
+            if "=" not in line:
+                all_lines.append(line)
+                continue
+            all_parts = [line_col.strip() for line_col in line.split("=")]
+            if not all_parts[-1].startswith(("'", '"')):
+                all_parts[-1] = f"'{all_parts[-1]}'"
+            all_lines.append("=".join(all_parts))
+        try:
+            all_entry_points = tomli.loads("\n".join(all_lines))
+        except tomli.TOMLDecoderError:
+            return []
+
     if all_entry_points.get("console_scripts") or all_entry_points.get("gui_scripts"):
         console_scripts = all_entry_points.get("console_scripts", [])
+        if isinstance(console_scripts, dict):
+            console_scripts = [
+                f"{k} = {v}" for k, v in all_entry_points["console_scripts"].items()
+            ]
+
         gui_scripts = all_entry_points.get("gui_scripts", [])
+        if isinstance(gui_scripts, dict):
+            gui_scripts = [
+                f"{k} = {v}" for k, v in all_entry_points["gui_scripts"].items()
+            ]
+
         entry_points_result = []
         if console_scripts:
             if isinstance(console_scripts, str):
diff --git a/setup.py b/setup.py
index bceed4b..fa196a7 100644
--- a/setup.py
+++ b/setup.py
@@ -44,6 +44,8 @@ setup(
         "colorama",
         "conda-souschef >=2.1.2",
         "pkginfo",
+        "tomli",
+        "tomli-w",
     ],
     extras_require={
         "testing": [


Test patch:
diff --git a/tests/test_pypi.py b/tests/test_pypi.py
index 54307ee..291b5ba 100644
--- a/tests/test_pypi.py
+++ b/tests/test_pypi.py
@@ -949,3 +949,8 @@ def test_notice_file_different_licence():
         )
     assert set(recipe["about"]["license_file"]) == {"NOTICE", "LICENSE"}
     assert recipe["about"]["license"] in ["MIT & Apache-2.0", "Apache-2.0 & MIT"]
+
+
+def test_console_script_toml_format():
+    recipe, _ = create_python_recipe("consolemd", version="0.5.1")
+    assert recipe["build"]["entry_points"] == ["consolemd = consolemd.cli:cli"]