Skip to content

Commit bebc19a

Browse files
Vendor pypa/packaging into micropip (#178)
1 parent 5ce6e1f commit bebc19a

21 files changed

Lines changed: 89 additions & 43 deletions

.github/workflows/main.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
fail-fast: false
2020
matrix:
2121
os: [ubuntu-latest]
22-
pyodide-version: ['0.27.0a2']
22+
pyodide-version: ["0.27.0a2"]
2323
test-config: [
2424
# FIXME: recent version of chrome gets timeout
2525
{runner: selenium, runtime: chrome, runtime-version: "125" },
@@ -28,6 +28,8 @@ jobs:
2828

2929
steps:
3030
- uses: actions/checkout@v4
31+
with:
32+
submodules: recursive
3133

3234
- uses: actions/setup-python@v5
3335
with:
@@ -88,6 +90,7 @@ jobs:
8890
- uses: actions/checkout@cbb722410c2e876e24abbe8de2cc27693e501dcb # v4.2.2
8991
with:
9092
ref: ${{ github.event.pull_request.head.sha }}
93+
submodules: recursive
9194

9295
- id: check-integration-test-trigger
9396
name: Check integration test trigger
@@ -110,15 +113,25 @@ jobs:
110113
environment: PyPi-deploy
111114
steps:
112115
- uses: actions/checkout@v4
116+
with:
117+
submodules: recursive
113118

114119
- uses: actions/setup-python@v5
115120
with:
116121
python-version: 3.12
122+
123+
# IMPORTANT: always build sdist, and then the wheel from
124+
# the sdist (like it is currently done here). This is
125+
# because we want to ensure that no extra files get
126+
# copied, which can be the case with building in-tree.
127+
# The MANIFEST.in file ensures that the sdist doesn't
128+
# contain any unnecessary files.
117129
- name: Install requirements and build wheel
118130
shell: bash -l {0}
119131
run: |
120132
python -m pip install build twine
121133
python -m build .
134+
122135
- name: Publish package
123136
uses: pypa/gh-action-pypi-publish@release/v1
124137
with:

.github/workflows/remote_package_index_test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ jobs:
2323

2424
steps:
2525
- uses: actions/checkout@v4
26+
with:
27+
submodules: recursive
2628

2729
- uses: actions/setup-python@v5
2830
with:

.gitmodules

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# d8e3b31b734926ebbcaff654279f6855a73e052f, for 24.2 release
2+
# https://github.com/pypa/packaging/releases/tag/24.2
3+
[submodule "micropip/_vendored/packaging"]
4+
path = micropip/_vendored/packaging
5+
url = https://github.com/pypa/packaging/

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
(the ones that starts with `../` or `./`)
1313
[#174](https://github.com/pyodide/micropip/pull/174)
1414

15+
### Added
16+
17+
- `micropip` now vendors `pypa/packaging` for better reliability.
18+
[#178](https://github.com/pyodide/micropip/pull/178)
19+
1520
## [0.8.0] - 2024/12/15
1621

1722
### Added

MANIFEST.in

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
exclude micropip/_vendored/packaging/.github/*
2+
exclude micropip/_vendored/packaging/docs/*
3+
exclude micropip/_vendored/packaging/tasks/*
4+
exclude micropip/_vendored/packaging/tests/*
5+
exclude micropip/_vendored/packaging/.pre-commit-config.yaml
6+
exclude micropip/_vendored/packaging/.readthedocs.yml
7+
exclude micropip/_vendored/packaging/CHANGELOG.rst
8+
exclude micropip/_vendored/packaging/CONTRIBUTING.rst
9+
exclude micropip/_vendored/packaging/noxfile.py
10+
exclude micropip/_vendored/packaging/pyproject.toml
11+
12+
include micropip/_vendored/packaging/LICENSE
13+
include micropip/_vendored/packaging/LICENSE.APACHE
14+
include micropip/_vendored/packaging/LICENSE.BSD
15+
16+
include micropip/_vendored/packaging/README.rst

micropip/_compat/_compat_not_in_pyodide.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
class CompatibilityNotInPyodide(CompatibilityLayer):
1515

1616
# Vendored from packaging
17+
# TODO: use packaging APIs here instead?
1718
_canonicalize_regex = re.compile(r"[-_.]+")
1819

1920
class HttpStatusError(Exception):

micropip/_utils.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,19 @@
44
from pathlib import Path
55
from sysconfig import get_config_var, get_platform
66

7-
from packaging.requirements import Requirement
8-
from packaging.tags import Tag
9-
from packaging.tags import sys_tags as sys_tags_orig
10-
from packaging.utils import BuildTag, InvalidWheelFilename, canonicalize_name
11-
from packaging.utils import parse_wheel_filename as parse_wheel_filename_orig
12-
from packaging.version import InvalidVersion, Version
13-
147
from ._compat import REPODATA_PACKAGES
8+
from ._vendored.packaging.src.packaging.requirements import Requirement
9+
from ._vendored.packaging.src.packaging.tags import Tag
10+
from ._vendored.packaging.src.packaging.tags import sys_tags as sys_tags_orig
11+
from ._vendored.packaging.src.packaging.utils import (
12+
BuildTag,
13+
InvalidWheelFilename,
14+
canonicalize_name,
15+
)
16+
from ._vendored.packaging.src.packaging.utils import (
17+
parse_wheel_filename as parse_wheel_filename_orig,
18+
)
19+
from ._vendored.packaging.src.packaging.version import InvalidVersion, Version
1520

1621

1722
def get_dist_info(dist: Distribution) -> Path:

micropip/_vendored/packaging

Submodule packaging added at d8e3b31

micropip/externals/mousebender/simple.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,12 @@
77
import warnings
88
from typing import Any, Dict, List, Optional, Union, Literal, TypeAlias, TypedDict
99

10-
import packaging.utils
10+
import micropip._vendored.packaging.src.packaging.utils as packaging_utils
1111

1212

1313
ACCEPT_JSON_V1 = "application/vnd.pypi.simple.v1+json"
1414

1515

16-
1716
class UnsupportedAPIVersion(Exception):
1817
"""The major version of an API response is not supported."""
1918

@@ -92,15 +91,15 @@ class ProjectDetails_1_0(TypedDict):
9291
"""A :class:`~typing.TypedDict` for a project details response (:pep:`691`)."""
9392

9493
meta: _Meta_1_0
95-
name: packaging.utils.NormalizedName
94+
name: packaging_utils.NormalizedName
9695
files: list[ProjectFileDetails_1_0]
9796

9897

9998
class ProjectDetails_1_1(TypedDict):
10099
"""A :class:`~typing.TypedDict` for a project details response (:pep:`700`)."""
101100

102101
meta: _Meta_1_1
103-
name: packaging.utils.NormalizedName
102+
name: packaging_utils.NormalizedName
104103
files: list[ProjectFileDetails_1_1]
105104
# PEP 700
106105
versions: List[str]
@@ -235,6 +234,6 @@ def from_project_details_html(html: str, name: str) -> ProjectDetails_1_0:
235234
files.append(details)
236235
return {
237236
"meta": {"api-version": "1.0"},
238-
"name": packaging.utils.canonicalize_name(name),
237+
"name": packaging_utils.canonicalize_name(name),
239238
"files": files,
240239
}

micropip/freeze.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
from copy import deepcopy
55
from typing import Any
66

7-
from packaging.utils import canonicalize_name
8-
97
from ._utils import fix_package_dependencies
8+
from ._vendored.packaging.src.packaging.utils import canonicalize_name
109

1110

1211
def freeze_lockfile(

0 commit comments

Comments
 (0)