Python package index requires optional `requires_python` field
Summary
Uploading a python package needs the requires_python field to be set in the upload metadata, even though that field is optional in the core metadata specification and not required by warehouse, the software behind pypi. This causes problems with tools that are not twine and do not set these fields (see https://github.com/PyO3/maturin/pull/438)
Steps to reproduce
- Install maturin (e.g.
pip install maturin) - Clone the maturin repo for a test project
- Run
maturin publish -m test-crates/pyo3-pure/Cargo.toml -r https://gitlab.com/api/v4/projects/<project_id>/packages/pypi -u __token__in the repository root
Example Project
What is the current bug behavior?
400 Bad Request: {"error":"requires_python is missing"}
What is the expected correct behavior?
Successful upload, as with warehouse/pypi
Relevant logs and/or screenshots
$ maturin publish -m test-crates/pyo3-pure/Cargo.toml-r https://gitlab.com/api/v4/projects/24588480/packages/pypi -u __token__
🔗 Found pyo3 bindings with abi3 support for Python ≥ 3.6
🐍 Not using a specific python interpreter (With abi3, an interpreter is only required on windows)
Finished release [optimized] target(s) in 0.01s
📦 Built wheel for abi3 Python ≥ 3.6 to /home/konsti/maturin/test-crates/pyo3-pure/target/wheels/pyo3_pure-2.1.2-cp36-abi3-manylinux2010_x86_64.whl
📦 Built source distribution to /home/konsti/maturin/test-crates/pyo3-pure/target/wheels/pyo3_pure-2.1.2.tar.gz
Please enter your password:
🚀 Uploading 2 packages
💥 maturin failed
Caused by: 💥 Failed to upload "pyo3_pure-2.1.2-cp36-abi3-manylinux2010_x86_64.whl" (172.5 KB)
Caused by: Failed to upload the wheel with status 400 Bad Request: {"error":"requires_python is missing"}
Output of checks
This bug happens on GitLab.com
Possible fixes
I have no experience with ruby, but https://gitlab.com/gitlab-org/gitlab/-/blob/2fa378ff8fe92b18e66766493d6bccfa9a4d756e/lib/api/pypi_packages.rb#L115 looks like it should say optional instead of requires