Skip to content

Commit 484cefa

Browse files
hoodmanerth
andauthored
Handle urls with search params (#33)
Co-authored-by: Roman Yurchak <rth.yurchak@gmail.com>
1 parent 0ae8f84 commit 484cefa

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010

1111
- Support for adding mock packages, for use where something is a dependency and you don't need it, or you need only a limited subset of the package. This is done using `micropip.add_mock_package`, `micropip.remove_mock_package` and `micropip.list_mock_packages`. Packages installed like this will be skipped by dependency resolution when you later install real packages.
1212

13+
14+
1315
### Fixed
1416

1517
- When multiple compatible builds for a package exist, the best
@@ -18,6 +20,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1820
For example, if a package has two pure Python wheels, one tagged `py30` and
1921
another tagged `py35`, the `py35` wheel will now always get installed.
2022
[#34](https://github.com/pyodide/micropip/pull/34)
23+
- `micropip.install` now supports installing packages by URLs with query parameters
24+
[#33](https://github.com/pyodide/micropip/pull/33)
25+
2126

2227
## [0.1.0] - 2022/09/18
2328

micropip/_micropip.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ async def add_requirement(self, req: str | Requirement) -> None:
336336
if isinstance(req, Requirement):
337337
return await self.add_requirement_inner(req)
338338

339-
if not req.endswith(".whl"):
339+
if not urlparse(req).path.endswith(".whl"):
340340
return await self.add_requirement_inner(Requirement(req))
341341

342342
# custom download location

tests/test_micropip.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,23 @@ async def test_add_requirement_marker(mock_importlib, wheel_base):
420420
assert t not in wheel_files
421421

422422

423+
@pytest.mark.asyncio
424+
async def test_add_requirement_query_url(mock_importlib, wheel_base, monkeypatch):
425+
pytest.importorskip("packaging")
426+
from micropip._micropip import Transaction
427+
428+
async def mock_add_wheel(self, wheel, extras):
429+
self.mock_wheel = wheel
430+
431+
monkeypatch.setattr(Transaction, "add_wheel", mock_add_wheel)
432+
433+
transaction = create_transaction(Transaction)
434+
await transaction.add_requirement(f"{SNOWBALL_WHEEL}?b=1")
435+
wheel = transaction.mock_wheel
436+
assert wheel.name == "snowballstemmer"
437+
assert wheel.filename == SNOWBALL_WHEEL # without the query params
438+
439+
423440
@pytest.mark.asyncio
424441
async def test_package_with_extra(mock_fetch):
425442
mock_fetch.add_pkg_version("depa")

0 commit comments

Comments
 (0)