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

Poetry lock version 2 #253

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
repos:
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.1.13
rev: v1.3.1
hooks:
- id: remove-tabs

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: check-merge-conflict
Expand All @@ -21,12 +21,12 @@ repos:
- id: debug-statements

- repo: https://github.com/pycqa/pydocstyle.git
rev: 6.1.1
rev: 6.2.2
hooks:
- id: pydocstyle

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.3.0
rev: v4.4.0
hooks:
- id: check-toml
exclude: 'tests/data/install/invalid_*'
Expand All @@ -35,21 +35,21 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.790
rev: v0.991
hooks:
- id: mypy
exclude: '^(docs|tasks|tests)|setup\.py'
args: [--ignore-missing-imports]

- repo: https://github.com/psf/black
rev: 22.3.0
rev: 22.12.0
hooks:
- id: black

- repo: https://gitlab.com/PyCQA/flake8
rev: '3.8.4'
- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8
additional_dependencies: ['pep8-naming']
# Ignore all format-related checks as Black takes care of those.
args: ['--ignore', 'E2,W5', '--select', 'E,W,F,N', '--max-line-length=150']
args: ['--ignore', 'E2,W5,N818', '--select', 'E,W,F,N', '--max-line-length=150']
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog for Thoth's micropipenv

## [1.4.5] - 2023-Jan-05 - Lumír Balhar <[email protected]>

### Added

* Test with pip==22.3.1

### Fixed

* Compatibility with new poetry lock file format version 2.0

## [1.4.4] - 2022-Oct-31 - Lumír Balhar <[email protected]>

### Added
Expand Down
10 changes: 7 additions & 3 deletions micropipenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
issue `python3 -m venv venv/ && . venv/bin/activate` to create one.
"""

__version__ = "1.4.4"
__version__ = "1.4.5"
__author__ = "Fridolin Pokorny <[email protected]>"
__title__ = "micropipenv"

Expand All @@ -48,7 +48,7 @@
from urllib.parse import urlparse

_LOGGER = logging.getLogger(__title__)
_SUPPORTED_PIP_STR = ">=9,<=22.3" # Respects requirement in setup.py and latest pip to release date.
_SUPPORTED_PIP_STR = ">=9,<=22.3.1" # Respects requirement in setup.py and latest pip to release date.

try:
from pip import __version__ as pip_version
Expand Down Expand Up @@ -801,7 +801,11 @@ def _poetry2pipfile_lock(
raise PoetryError(message)

hashes = []
for file_entry in poetry_lock["metadata"]["files"][entry["name"]]:
# Older poetry.lock format contains files in [metadata].
# New version 2.0 has files in [[package]] section.
metadata_file_entries = poetry_lock["metadata"].get("files", {}).get(entry["name"], [])
package_file_entries = entry.get("files", [])
for file_entry in metadata_file_entries + package_file_entries:
hashes.append(file_entry["hash"])

requirement: Dict[str, Any] = {"version": "=={}".format(entry["version"])}
Expand Down
37 changes: 37 additions & 0 deletions tests/data/install/poetry_lock_format_2/_Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions tests/data/install/poetry_lock_format_2/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions tests/data/install/poetry_lock_format_2/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[tool.poetry]
name = "micropipenv-test"
version = "0.1.0"
description = ""
authors = ["Fridolin Pokorny <[email protected]>"]

[tool.poetry.dependencies]
python = "^3.7"
daiquiri = "2.0.0"

[tool.poetry.dev-dependencies]

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
Loading