Fields are missing when I `pip show` my Python package.

huangapple go评论59阅读模式
英文:

Fields are missing when I `pip show` my Python package

问题

I recently uploaded my first Python package to PyPI. The relevant parts of pyproject.toml are defined as follows:

[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "jutility"
version = "0.0.4"
license = {text = "MIT License"}
authors = [
    {name = "Jake Levi", email = "jakelevi@hotmail.co.uk"},
]

# ...

[project.urls]
homepage = "https://github.com/jakelevi1996/jutility"

After installing this package with the command python3 -m pip install -U jutility, I run the command python3 -m pip show jutility, and get the following output:

Name: jutility
Version: 0.0.4
Summary: Collection of Python utilities intended to be useful for machine learning research and experiments
Home-page: 
Author: 
Author-email: Jake Levi <jakelevi@hotmail.co.uk>
License: MIT License
Location: /usr/local/lib/python3.10/dist-packages
Requires: matplotlib, numpy, Pillow
Required-by: 

Notably, the Home-page and Author fields are empty in the output from pip show, although they seem to be defined in pyproject.toml.

How should I change pyproject.toml to make these fields display properly in the pip show output?

Version-wise, I built and uploaded these packages to PyPI on my Windows 10 PC with Python 3.7.6, but I also tried downloading and installing this package and displaying the pip show output from a Google Colab notebook with Python 3.10.11. The package works completely as expected in the Colab notebook, but I get the same pip show output with empty Home-page and Author fields. I'd just like to know what I need to change in order to get these fields to display properly.

英文:

I recently uploaded my first Python package to PyPI. The relevant parts of pyproject.toml are defined as follows (full file available here):

[build-system]
requires = [&quot;setuptools&gt;=61.0&quot;]
build-backend = &quot;setuptools.build_meta&quot;

[project]
name = &quot;jutility&quot;
version = &quot;0.0.4&quot;
license = {text = &quot;MIT License&quot;}
authors = [
    {name = &quot;Jake Levi&quot;, email = &quot;jakelevi@hotmail.co.uk&quot;},
]

# ...

[project.urls]
homepage = &quot;https://github.com/jakelevi1996/jutility&quot;

After installing this package with the command python3 -m pip install -U jutility, I run the command python3 -m pip show jutility, and get the following output:

Name: jutility
Version: 0.0.4
Summary: Collection of Python utilities intended to be useful for machine learning research and experiments
Home-page: 
Author: 
Author-email: Jake Levi &lt;jakelevi@hotmail.co.uk&gt;
License: MIT License
Location: /usr/local/lib/python3.10/dist-packages
Requires: matplotlib, numpy, Pillow
Required-by: 

Notably, the Home-page and Author fields are empty in the output from pip show, although they seem to be defined in pyproject.toml.

How should I change pyproject.toml to make these fields display properly in the pip show output?

Version-wise, I built and uploaded these packages to PyPI on my Windows 10 PC with Python 3.7.6, but I also tried downloading and installing this package and displaying the pip show output from a Google Colab notebook with Python 3.10.11. The package works completely as expected in the Colab notebook, but I get the same pip show output with empty Home-page and Author fields. I'd just like to know what I need to change in order to get these fields to display properly.

答案1

得分: 1

我通过删除pyproject.toml的前三行来解决了这个问题,使pyproject.toml看起来像这样:

[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

然后,我在setup.cfg中添加了以下配置(感谢@Ratul Hasan的建议):

[metadata]
name = jutility
version = 0.0.8
author = Jake Levi
author_email = jakelevi@hotmail.co.uk
description = Collection of Python utilities intended to be useful for machine learning research and experiments
long_description = file: README.md
long_description_content_type = text/markdown
license = MIT License
license_files = LICENSE
url = https://github.com/jakelevi1996/jutility
project_urls =
    Documentation   = https://github.com/jakelevi1996/jutility
    Source Code     = https://github.com/jakelevi1996/jutility
    Bug Tracker     = https://github.com/jakelevi1996/jutility/issues

[options]
python_requires = >=3.7
install_requires =
    matplotlib>=3.5.3
    numpy>=1.21.6
    Pillow>=9.5.0

现在,我通过python3 -m pip show jutility获得了以下输出,如期望:

Name: jutility
Version: 0.0.8
Summary: Collection of Python utilities intended to be useful for machine learning research and experiments
Home-page: https://github.com/jakelevi1996/jutility
Author: Jake Levi
Author-email: jakelevi@hotmail.co.uk
License: MIT License
Location: /usr/local/lib/python3.10/dist-packages
Requires: matplotlib, numpy, Pillow
Required-by: 

有关setup.cfg文件的更多信息,请参阅使用setup.cfg文件配置setuptools。至于为什么在Packaging Python Projects教程中没有提到setup.cfg文件,这是其他人的问题。

英文:

I fixed the issue by deleting all but the first 3 lines of pyproject.toml, so that pyproject.toml looks like this:

[build-system]
requires = [&quot;setuptools&gt;=61.0&quot;]
build-backend = &quot;setuptools.build_meta&quot;

I then added the following configuration to setup.cfg (thank you to @Ratul Hasan for the suggestion):

[metadata]
name = jutility
version = 0.0.8
author = Jake Levi
author_email = jakelevi@hotmail.co.uk
description = Collection of Python utilities intended to be useful for machine learning research and experiments
long_description = file: README.md
long_description_content_type = text/markdown
license = MIT License
license_files = LICENSE
url = https://github.com/jakelevi1996/jutility
project_urls =
    Documentation   = https://github.com/jakelevi1996/jutility
    Source Code     = https://github.com/jakelevi1996/jutility
    Bug Tracker     = https://github.com/jakelevi1996/jutility/issues

[options]
python_requires = &gt;=3.7
install_requires =
    matplotlib&gt;=3.5.3
    numpy&gt;=1.21.6
    Pillow&gt;=9.5.0

I now get the following output from python3 -m pip show jutility, as desired:

Name: jutility
Version: 0.0.8
Summary: Collection of Python utilities intended to be useful for machine learning research and experiments
Home-page: https://github.com/jakelevi1996/jutility
Author: Jake Levi
Author-email: jakelevi@hotmail.co.uk
License: MIT License
Location: /usr/local/lib/python3.10/dist-packages
Requires: matplotlib, numpy, Pillow
Required-by: 

More information on setup.cfg files is given on the page Configuring setuptools using setup.cfg files. It remains to be seen why setup.cfg files are not mentioned in the Packaging Python Projects tutorial, but this is a question for someone else.

huangapple
  • 本文由 发表于 2023年5月15日 00:47:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/76248637.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定