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

pypi 400 error on hatch publish #1818

Closed
cornhundred opened this issue Nov 20, 2024 · 2 comments
Closed

pypi 400 error on hatch publish #1818

cornhundred opened this issue Nov 20, 2024 · 2 comments

Comments

@cornhundred
Copy link

cornhundred commented Nov 20, 2024

Hi I am unable to publish my Python library to PyPI using the latest version of hatch and I think the issue is related to the version of the package metadata (2.3 vs 2.4) - any help would be appreciated

Running hatch build works

(celldega_3.9) ➜  celldega git:(main) hatch build  

──────────────────────────────────────────────────────────────────────────────────────────────────────────────── sdist ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────
INFO:hatch_jupyter_builder.utils:Running jupyter-builder
INFO:hatch_jupyter_builder.utils:Skip-if-exists file(s) found
INFO:hatch_jupyter_builder.utils:Skipping build
INFO:hatch_jupyter_builder.utils:Ensured target(s) exist!
INFO:hatch_jupyter_builder.utils:Finished running jupyter-builder
dist/celldega-0.4.1.tar.gz
──────────────────────────────────────────────────────────────────────────────────────────────────────────────── wheel ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────
INFO:hatch_jupyter_builder.utils:Running jupyter-builder
INFO:hatch_jupyter_builder.utils:Skip-if-exists file(s) found
INFO:hatch_jupyter_builder.utils:Skipping build
INFO:hatch_jupyter_builder.utils:Ensured target(s) exist!
INFO:hatch_jupyter_builder.utils:Finished running jupyter-builder
dist/celldega-0.4.1-py2.py3-none-any.whl

but I am seeing this error when I try to publish to PyPI

$ hatch publish
dist/celldega-0.4.1-py2.py3-none-any.whl ... failed
Error uploading to repository: https://upload.pypi.org/legacy/ - Client error '400 license-file introduced in metadata version 2.4, not 2.3. See https://packaging.python.org/specifications/core-metadata for more information.' for url 'https://upload.pypi.org/legacy/'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/400

My project.toml looks like this

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "celldega"
version = "0.4.1"
dependencies = [
    "anywidget==0.9.6",
    "pandas~=2.2.2",
    "geopandas~=0.14.3",
    "pyarrow~=15.0.2",
    "matplotlib~=3.8.4",
    "geopandas~=0.14.3",
    "zarr~=2.17.2",
    "tifffile~=2024.4.18",
    "imagecodecs~=2024.1.1",
    "scanpy~=1.10.2",
    "squidpy~=1.5.0",
    "clustergrammer2==0.18.0",
    "shapely~=2.0.5",
    "polars~=1.10.0"
]
readme = "README.md"

[project.optional-dependencies]
dev = [
    "watchfiles",
    "jupyterlab",
    "pylint",
    "black"
]
pre = [
    "pyvips~=2.2.2"
] # optional dependencies for pre-processing

docs = [
    "mkdocs",
    "mkdocs-material",
    "mkdocstrings[python]",
    "mkdocstrings[javascript]"
] # optional dependencies for documentation

# automatically add the dev feature to the default env (e.g., hatch shell)
[tool.hatch.envs.default]
features = ["dev"]

[tool.hatch.build]
only-packages = true
artifacts = ["src/celldega/static/*"]

[tool.hatch.build.hooks.jupyter-builder]
build-function = "hatch_jupyter_builder.npm_builder"
ensured-targets = ["src/celldega/static/widget.js"]
skip-if-exists = ["src/celldega/static/widget.js"]
dependencies = ["hatch-jupyter-builder>=0.5.0"]

[tool.hatch.build.hooks.jupyter-builder.build-kwargs]
npm = "npm"
build_cmd = "build"

and the PKG-INFO looks like this

Metadata-Version: 2.3
Name: celldega
Version: 0.4.1
License-File: LICENSE.txt
Requires-Dist: anywidget==0.9.6
Requires-Dist: clustergrammer2==0.18.0
Requires-Dist: geopandas~=0.14.3
Requires-Dist: imagecodecs~=2024.1.1
Requires-Dist: matplotlib~=3.8.4
Requires-Dist: pandas~=2.2.2
Requires-Dist: polars~=1.10.0
Requires-Dist: pyarrow~=15.0.2
Requires-Dist: scanpy~=1.10.2
Requires-Dist: shapely~=2.0.5
Requires-Dist: squidpy~=1.5.0
Requires-Dist: tifffile~=2024.4.18
Requires-Dist: zarr~=2.17.2
Provides-Extra: dev
Requires-Dist: black; extra == 'dev'
Requires-Dist: jupyterlab; extra == 'dev'
Requires-Dist: pylint; extra == 'dev'
Requires-Dist: watchfiles; extra == 'dev'
Provides-Extra: docs
Requires-Dist: mkdocs; extra == 'docs'
Requires-Dist: mkdocs-material; extra == 'docs'
Requires-Dist: mkdocstrings[javascript]; extra == 'docs'
Requires-Dist: mkdocstrings[python]; extra == 'docs'
Provides-Extra: pre
Requires-Dist: pyvips~=2.2.2; extra == 'pre'
Description-Content-Type: text/markdown
@ofek
Copy link
Collaborator

ofek commented Nov 20, 2024

#1786 (comment)

@cornhundred
Copy link
Author

Thanks @ofek!!! Making this change

[build-system]
requires = ["hatchling>=1.26.1"]
build-backend = "hatchling.build"

running

pip cache purge

and finally rebuilding and publishing worked

hatch build
hatch publish

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

No branches or pull requests

2 participants