di / pip-api

An unofficial, importable pip API
https://pypi.org/p/pip-api
Apache License 2.0
110 stars 15 forks source link

TOML-based projects plus -e == exception #199

Closed mcdonc closed 8 months ago

mcdonc commented 8 months ago

Using pip-api 0.0.30, a minor issue.

Python 3.11.6 (main, Oct  2 2023, 13:45:54) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pip_api
>>> pip_api.parse_requirements("test.txt")
Traceback (most recent call last):
  File "/home/chrism/projects/apex/eao_dash/.devenv/state/venv/lib/python3.11/site-packages/pip_api/_parse_requirements.py", line 260, in _parse_local_package_name
    value = [kw.value for kw in setup_kwargs if kw.arg == "name"][0]
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/chrism/projects/apex/eao_dash/.devenv/state/venv/lib/python3.11/site-packages/pip_api/_parse_requirements.py", line 531, in parse_requirements
    name, url = _parse_editable(known.editable)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/chrism/projects/apex/eao_dash/.devenv/state/venv/lib/python3.11/site-packages/pip_api/_parse_requirements.py", line 285, in _parse_editable
    return _parse_local_package_name(url_no_extras[len("file://") :]), url_no_extras
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/chrism/projects/apex/eao_dash/.devenv/state/venv/lib/python3.11/site-packages/pip_api/_parse_requirements.py", line 263, in _parse_local_package_name
    raise PipError(
pip_api.exceptions.PipError: Directory '/home/chrism/projects/apex/eao_dash' is not installable. Could not parse package name from 'setup.py'.

Where test.txt is:

-r ./requirements.txt
-e ./.

That would be totally reasonable, but this project is of the new regime where the setup.py looks like:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""The setup script."""

from setuptools import setup

setup()

And it gets all its metadata from pyproject.toml:

[project]
name = "eao_dash"

It should likely fall back to trying to parse the name out of pyproject.toml.

di commented 8 months ago

Thanks, this will be fixed in the next release (0.0.31) once the release finishes.