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

Implement PEP 639: support for Metadata-Version: 2.4 #24

Merged
Merged
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
67 changes: 40 additions & 27 deletions make_wheels.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def writestr(self, zinfo_or_arcname, data, *args, **kwargs):

def make_message(headers, payload=None):
msg = EmailMessage()
for name, value in headers.items():
for name, value in headers:
if isinstance(value, list):
for value_part in value:
msg[name] = value_part
Expand All @@ -71,18 +71,18 @@ def write_wheel(out_dir, *, name, version, tag, metadata, description, contents)
dist_info = f'{name}-{version}.dist-info'
return write_wheel_file(os.path.join(out_dir, wheel_name), {
**contents,
f'{dist_info}/METADATA': make_message({
'Metadata-Version': '2.1',
'Name': name,
'Version': version,
**metadata,
}, description),
f'{dist_info}/WHEEL': make_message({
'Wheel-Version': '1.0',
'Generator': 'ziglang make_wheels.py',
'Root-Is-Purelib': 'false',
'Tag': tag,
}),
f'{dist_info}/METADATA': make_message([
('Metadata-Version', '2.4'),
('Name', name),
('Version', version),
*metadata,
], description),
f'{dist_info}/WHEEL': make_message([
('Wheel-Version', '1.0'),
('Generator', 'ziglang make_wheels.py'),
('Root-Is-Purelib', 'false'),
('Tag', tag),
]),
Comment on lines +74 to +85
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This metadata version bump is backwards compatible. Please see https://peps.python.org/pep-0639/#backwards-compatibility for more. I tested recent versions of pip and uv, and they installed a wheel I generated for my M-series device without hiccups. I'll need to see if compliance with PyPI uploads is working, though, that's more important to figure out.

})


Expand Down Expand Up @@ -134,20 +134,33 @@ def write_ziglang_wheel(out_dir, *, version, platform, archive):
name='ziglang',
version=version,
tag=f'py3-none-{platform}',
metadata={
'Summary': 'Zig is a general-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.',
'Description-Content-Type': 'text/markdown',
'License': 'MIT',
'Classifier': [
'License :: OSI Approved :: MIT License',
],
'Project-URL': [
'Homepage, https://ziglang.org',
'Source Code, https://github.com/ziglang/zig-pypi',
'Bug Tracker, https://github.com/ziglang/zig-pypi/issues',
],
'Requires-Python': '~=3.5',
},
metadata=[
('Summary', 'Zig is a general-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.'),
('Description-Content-Type', "'text/markdown'; charset=UTF-8; variant=GFM"),
agriyakhetarpal marked this conversation as resolved.
Show resolved Hide resolved
('License-Expression', 'MIT'),
('License-File', 'LICENSE'),
('License-File', 'ziglang/lib/libc/glibc/LICENSES'),
('License-File', 'ziglang/lib/libc/mingw/COPYING'),
('License-File', 'ziglang/lib/libc/musl/COPYRIGHT'),
('License-File', 'ziglang/lib/libc/wasi/LICENSE'),
('License-File', 'ziglang/lib/libc/wasi/LICENSE-APACHE'),
('License-File', 'ziglang/lib/libc/wasi/LICENSE-APACHE-LLVM'),
('License-File', 'ziglang/lib/libc/wasi/LICENSE-MIT'),
('License-File', 'ziglang/lib/libcxx/LICENSE.TXT'),
('License-File', 'ziglang/lib/libcxxabi/LICENSE.TXT'),
('License-File', 'ziglang/lib/libunwind/LICENSE.TXT'),
('Classifier', 'Development Status :: 4 - Beta'),
('Classifier', 'Intended Audience :: Developers'),
('Classifier', 'Topic :: Software Development :: Compilers'),
('Classifier', 'Topic :: Software Development :: Code Generators'),
('Classifier', 'Topic :: Software Development :: Build Tools'),
('Classifier', 'Programming Language :: Other'),
('Classifier', 'Programming Language :: Other Scripting Engines'),
agriyakhetarpal marked this conversation as resolved.
Show resolved Hide resolved
('Project-URL', 'Homepage, https://ziglang.org'),
('Project-URL', 'Source Code, https://github.com/ziglang/zig-pypi'),
('Project-URL', 'Bug Tracker, https://github.com/ziglang/zig-pypi/issues'),
('Requires-Python', '~=3.5'),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://endoflife.date/python states that security releases for Python 3.7 have ended. Now that 3.13 is just around the corner, maybe we should update to a minimum of 3.8 (either here or as a separate PR). Please let me know.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm aware of the EOL status of Python 3.5 (it was EOL when I wrote this package). I decided that this requirement should be bumped only if the package isn't installable/usable, since there isn't really a cost to keeping it low, and it could help someone using old Python versions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, makes sense!

Copy link
Collaborator

Choose a reason for hiding this comment

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

If we do change the launcher in such a way it stops working on earlier Python versions, we should support the last non-EOL version, of course.

zig-pypi/make_wheels.py

Lines 122 to 127 in f1cd7a9

import os, sys
argv = [os.path.join(os.path.dirname(__file__), "{entry_name}"), *sys.argv[1:]]
if os.name == 'posix':
os.execv(argv[0], argv)
else:
import subprocess; sys.exit(subprocess.call(argv))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't access a Python version that old unless I use actions/setup-python in a CI setup – and I remember that your previous mention in our earlier conversations of one to not become a maintenance burden. So we could leave it until someone asks; I doubt anyone will, though, since those Pythons are really old 😄

],
description=description,
contents=contents,
)
Expand Down