没有项目描述
pypi-parker的Python项目详细描述
pypi-parker让您可以轻松地将包名称驻留在pypi上,以保护包的用户 从打字开始。
Typosquatting是一个问题:一般来说,在pypi上也是如此。我们正在努力 由pypa到protect core library names,但这不是(而且确实不能而且很可能 不应尝试)帮助单个包所有者。例如,reqeusts而不是 requests,或crytpography,而不是cryptography。因为自助服务 pypi的本质是,每个包的拥有者都被留给他们自己的设备来保护他们的用户。 这不是一个固有的问题:在我看来,这是一个合理的平衡,以保持障碍 发布pypi包low的入口。然而,工具应该存在,以使它容易。 包所有者以保护其用户。这就是pypi-parker要做的。
目标
- 自助服务是件好事。我们不要试着摆脱它。用它来代替。
- 包所有者应该能够轻松地保护其包的用户免受恶意的打字错误。 对于包所有者来说,将T{1} $引入到现有的包构建中应该是很容易的。
- 停放的包裹应:
- 快速失败而不是do anything else
- 在元数据和源代码中都可以自我记录
- 包含功能完整的setup.py文件,允许白名单外部验证器工作
- 生成之前,readme_renderer验证器在每个生成的包上运行。
它是做什么的?
pypi-parker提供自定义distutils命令park,该命令解释提供的配置 生成空的python包源可分发文件。这些包裹总是 当有人试图安装它们时,一种重要的恐惧。您可以自定义importorror消息 帮助引导用户找到正确的软件包。
使用配置文件
pypi-parker使用configparser配置文件来确定要生成的包和元数据 包括在每一个里面。
有两个特殊部分:names和DEFAULT。
- DEFAULT:如果在特定于包的节中不存在该键,则使用DEFAULT中的值。
- names:将names中的键解释为包名,这些包名应该只使用DEFAULT中的值。
除非另有说明,否则直接加载为每个包加载的所有键/值对 为生成的包调用setup。
特殊包装
如果要为特定包指定自定义值,可以添加其他节 对于那些包裹。对于除了DEFAULT和names之外的任何节,该节 名称用作包名称。
特殊部分键
description_keys:此行分隔值与str.format一起使用,以生成
最终description值。
classifiers:如果为此值提供了多行,则将处理每一行
作为单独的条目。
description:
- This value cannot contain multiple lines.
- This value is also used for the ^{tt27}$ message in the generated ^{tt8}$.
description_keys:此行分隔值与str.format一起使用,以生成 最终description值。
classifiers:如果为此值提供了多行,则将处理每一行 作为单独的条目。
description:
- This value cannot contain multiple lines.
- This value is also used for the ^{tt27}$ message in the generated ^{tt8}$.
默认值
config文件名:park.cfg
分类器:Development Status :: 7 - Inactive
说明:parked using pypi-parker
长描述:
This package has been parked either for future use or to protect against typo misdirection. If you believe that it has been parked in error, please contact the package owner.
示例
park.cfg
[DEFAULT]author: mattsb42[my-package-name]url: https://github.com/mattsb42/my-package-namedescription: This package is parked by {author}. See {url} for more information.description_keys:authorurlclassifiers:Development Status :: 7 - InactiveOperating System :: OS IndependentTopic :: Utilities
生成的setup.py
fromsetuptoolsimportsetupargs=' '.join(sys.argv).strip()ifnotany(args.endswith(suffix)forsuffixin['setup.py sdist','setup.py check -r -s']):raiseImportError('This package is parked by mattsb42. See https://github.com/mattsb42/my-package-name for more information.')setup(author='mattsb42',url='https://github.com/mattsb42/my-package-name',description='This package is parked by mattsb42. See https://github.com/mattsb42/my-package-name for more information.',classifiers=['Development Status :: 7 - Inactive','Operating System :: OS Independent','Topic :: Utilities'])
安装尝试
$ pip install my-package-name Processing my-package-name Complete output from command python setup.py egg_info: Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-oma2zoy6-build/setup.py", line 6, in <module> raise ImportError('This package is parked by mattsb42. See https://github.com/mattsb42/my-package-name for more information.',) ImportError: This package is parked by mattsb42. See https://github.com/mattsb42/my-package-name for more information. ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-oma2zoy6-build/
好的,我该怎么用?
- 在运行生成的任何位置安装pypi-parker。
pip install pypi-parker
- 在配置文件中定义要作为目标的包名称。
- 使用park命令调用setup.py。
python setup.py park
If you want to use a custom config file, specify it with the ^{tt35}$ argument.
python setup.py park --park-config={filename}
- 将dist的结果内容上载到您选择的包索引。
^{结构1}$example tox配置
[testenv:park]basepython=python3.6deps= setuptools pypi-parkercommands=python setup.py park