且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 setup.cfg 中正确使用 PEP 508 环境标记

更新时间:2022-05-24 22:35:52

一个字符.这就是你所缺少的.您使用的是 platform_system="Darwin" 而不是 platform_system=="Darwin"(install_requires 的最后一行).这样就可以正常工作:

One character. That's all you were missing. You had platform_system="Darwin" instead of platform_system=="Darwin" (the very last line of your install_requires). It works fine this way:

[metadata]
name = foobar
version = 1.6.5+0.1.0

[options]
packages = find:

install_requires =
    ham >= 0.1.0
    eggs >= 8.1.2
    spam >= 1.2.3; platform_system=="Darwin"
    i-love-spam >= 1.2.0; platform_system=="Darwin"

这不是必需的,但您的 setup.py 也可以简化.

It's not necessary but your setup.py could be simplified too.

import setuptools

setup(setup_requires=['setuptools>=36.0'])

与之前的评论不同,我喜欢使用 setup.cfg.它干净而简单.如果你想在运行时使用 setup.cfg 中的信息,很容易解析:

Unlike those commenting before, I like using setup.cfg. It's clean and easy. If you want to use the information from setup.cfg at runtime, it's easy to parse:

from setuptools.config import read_configuration

conf_dict = read_configuration('/home/user/dev/package/setup.cfg')

更多 setup.cfg 信息