Question
Unable to upload PIP package to Google Artifact Registry using twine, err: KeyError: 'license'
I am building a Python PIP package to be stored on Google Artifact Registry.
The pyproject.toml
is as below:
[build-system]
requires = ["setuptools>=68.0.0,<69.0.0", "setuptools-scm>=8.0.1,<8.1.0"]
build-backend = "setuptools.build_meta"
[project]
name = "my-sdk"
version = "0.1.3"
license = {text = "Some Solution"}
readme = "README.md"
requires-python = ">=3.8,<3.11"
dependencies = [
"google-cloud-storage>=2.6.0"
]
[project.optional-dependencies]
ci = [
"flake8==6.0.0",
"Flake8-pyproject==1.2.3",
"pytest-cov==4.1.0",
"pytest==7.2.2"
]
[tool.setuptools.packages.find]
include = ["*"]
namespaces = false
[tool.pytest]
norecursedirs = [".git", ".tox"," venv*"]
addopts = "-rsxX -q -p no:warnings"
python_files = ["*_test.py", "test_*.py"]
log_cli = true
log_cli_level = "INFO"
[tool.flake8]
max-line-length = 100
select = ["E", "W", "F", "C", "B"]
ignore = ["E203", "W503", "E731"]
per-file-ignores = ["__init__.py: F401", "test_*.py: D103"]
Sequence of commands for the package:
python -m pip install \
keyring==24.3.0 \
keyrings.google-artifactregistry-auth==1.1.2 \
build==1.0.3 \
twine==4.0.2
python -m build
python -m twine upload \
--repository-url https://<hidden>.pkg.dev/my-project/my-artifacts \
dist/*
Only the last step fails, i.e. twine upload
, and the error message is below:
Traceback (most recent call last):
File "/miniconda/envs/pip_env/lib/python3.10/runpy.py", line 187, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/miniconda/envs/pip_env/lib/python3.10/runpy.py", line 146, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/miniconda/envs/pip_env/lib/python3.10/runpy.py", line 110, in _get_module_details
__import__(pkg_name)
File "/miniconda/envs/pip_env/lib/python3.10/site-packages/twine/__init__.py", line 43, in <module>
__license__ = metadata["license"]
File "/miniconda/envs/pip_env/lib/python3.10/site-packages/importlib_metadata/_adapters.py", line 54, in __getitem__
raise KeyError(item)
KeyError: 'license'
I have tried different types of license
in pyproject.toml, but getting the same error everytime.
Any one else faced this challenge?