thoth-station / micropipenv

A lightweight wrapper for pip to support requirements.txt, Pipenv and Poetry lock files or converting them to pip-tools compatible output. Designed for containerized Python applications but not limited to them.
https://pypi.org/project/micropipenv/
GNU Lesser General Public License v3.0
231 stars 25 forks source link

Key error raised on requirements subcommand when VCS dependency is specified #256

Closed fridex closed 1 year ago

fridex commented 1 year ago

Describe the bug

Given the following Pipfile:

[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
selinon = {git = "https://github.com/selinon/selinon"}

[dev-packages]

Running the following command:

micropipenv --verbose req --only-direct

I get the following error:

Traceback (most recent call last):
  File "/Users/fridolin.pokorny/git/fridex/selinon/demo-worker/./micropipenv.py", line 1464, in <module>
    return_code = main()
  File "/Users/fridolin.pokorny/git/fridex/selinon/demo-worker/./micropipenv.py", line 1451, in main
    handler(**arguments)
  File "/Users/fridolin.pokorny/git/fridex/selinon/demo-worker/./micropipenv.py", line 1301, in requirements
    sections = sections or get_requirements_sections(
  File "/Users/fridolin.pokorny/git/fridex/selinon/demo-worker/./micropipenv.py", line 1097, in get_requirements_sections
    result["default"] = {
  File "/Users/fridolin.pokorny/git/fridex/selinon/demo-worker/./micropipenv.py", line 1098, in <dictcomp>
    dependency_name: _parse_pipfile_dependency_info(pipfile_entry)
  File "/Users/fridolin.pokorny/git/fridex/selinon/demo-worker/./micropipenv.py", line 1064, in _parse_pipfile_dependency_info
    result = {"version": pipfile_entry["version"]}
KeyError: 'version'

Expected behavior

Requirements should be generated respecting VCS dependency stated in the provided Pipfile.

goern commented 1 year ago

Heya @fridex thanks for opening the issue, sounds like a bug to me ...

/kind bug /priority critical-urgent /assign @VannTen

VannTen commented 1 year ago

If we accept the new scope proposed in #249 (point 1), this is out of scope. (because micropipenv should parse Pipfile.lock, not attempt to resolve Pipfile to Pipfile.lock)

fridex commented 1 year ago

If we accept the new scope proposed in #249 (point 1), this is out of scope. (because micropipenv should parse Pipfile.lock, not attempt to resolve Pipfile to Pipfile.lock)

This corresponds to the requirements feature. In some cases, users might want to convert Pipfile to requirements style output (see also pipenv requrements command).

The reported bug affects micropipenv requirements --only-direct in which case users want only direct dependencies converted to the requirements style file - hence Pipfile has to be parsed for that.

fridex commented 1 year ago

https://github.com/thoth-station/micropipenv/issues/249

Ah, sorry - opened another issue.

Ideally yes, if there is only one standard for defining requirements and lockfiles, this would not be needed. But I would expect it will take some time (years?) to have the lockfile standard accepted and used widely. In the meantime, micropipenv could be helpful.

frenzymadness commented 1 year ago

Does any of you plan to propose a fix for this bug?