Skip to content

Vendor pypa/packaging into micropip - #178

Merged
agriyakhetarpal merged 15 commits into
pyodide:mainfrom
agriyakhetarpal:vendor/packaging
Jan 29, 2025
Merged

Vendor pypa/packaging into micropip#178
agriyakhetarpal merged 15 commits into
pyodide:mainfrom
agriyakhetarpal:vendor/packaging

Conversation

@agriyakhetarpal

@agriyakhetarpal agriyakhetarpal commented Jan 25, 2025

Copy link
Copy Markdown
Member

Description

Closes #176, and stemmed off from pyodide/pyodide#5366.

This PR vendors the https://github.com/pypa/packaging project into micropip, as the issue above noted that it is difficult to install a newer version of packaging into the environment, as micropip depends on it and installs it. This means packaging can now be installed separately from micropip.

Changes

@ryanking13

Copy link
Copy Markdown
Member

Thanks for working on this @agriyakhetarpal! Please ping me when it is ready to be reviewed.

@agriyakhetarpal agriyakhetarpal changed the title [DRAFT]: Vendor pypa/packaging for micropip Vendor pypa/packaging into micropip Jan 25, 2025
Comment thread pyproject.toml
Comment on lines +74 to +76
[[tool.mypy.overrides]]
module = "micropip._vendored.*"
warn_unreachable = false

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've had to keep this as there is some unreachable code in src/packaging/, which is not of concern for us, and TIL that the warn_unreachable option is still raised for excluded files.

@agriyakhetarpal

Copy link
Copy Markdown
Member Author

Thanks for working on this @agriyakhetarpal! Please ping me when it is ready to be reviewed.

Thanks, @ryanking13! I think it is ready now.

from typing import Any, Dict, List, Optional, Union, Literal, TypeAlias, TypedDict

import packaging.utils
import micropip._vendored.packaging.utils as packaging_utils

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(No need to address in this PR)

both _vendored and externals directory vendors external packages, so I think we can merge them into a single directory

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Yes, I noticed that. I'll open a follow-up PR after this to merge them. I have no preference on the name of the folder, but it should be _externals or _vendored, so that it doesn't form a part of the public API.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I think _vendored is a better name. At the beginning, the external directory contained subset of pip, and it had a _vendor directory in it (ref).

Comment thread micropip/_vendored/__init__.py Outdated
Comment thread micropip/_vendored/packaging
Comment thread micropip/_vendored/packaging
Comment thread MANIFEST.in

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As packaging is a part of the private API for micropip, we don't need to graft it. However, there is no nice way to exclude specific files without explicitly naming them. This is because MANIFEST.in is processed from top to bottom, like an interpreted language, so we can't exclude the entire first and include only what we want.

The better way would be for us to switch to hatchling in a follow-up item, which supports this kind of use case much better.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Yes, I agree that in terms of managing file inclusion/exclusion, other build backends like hatchling are better than setuptools. It can be a follow up item.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've opened #182 for this. Thanks!

@agriyakhetarpal

Copy link
Copy Markdown
Member Author

Ready for another look!

@ryanking13 ryanking13 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @agriyakhetarpal! Could you please update the changelog and make a release?

Comment thread .github/workflows/main.yml Outdated
Comment thread MANIFEST.in

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Yes, I agree that in terms of managing file inclusion/exclusion, other build backends like hatchling are better than setuptools. It can be a follow up item.

from typing import Any, Dict, List, Optional, Union, Literal, TypeAlias, TypedDict

import packaging.utils
import micropip._vendored.packaging.utils as packaging_utils

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I think _vendored is a better name. At the beginning, the external directory contained subset of pip, and it had a _vendor directory in it (ref).

@agriyakhetarpal

Copy link
Copy Markdown
Member Author

Thanks for the review, Gyeongjae! I'll merge this and move the external folder to _vendored in a follow-up PR.

@agriyakhetarpal
agriyakhetarpal merged commit bebc19a into pyodide:main Jan 29, 2025
@agriyakhetarpal
agriyakhetarpal deleted the vendor/packaging branch January 29, 2025 00:20
@agriyakhetarpal agriyakhetarpal mentioned this pull request Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vendor packaging

2 participants