您可以通过 pip 将参数传递给 setup.py:
--安装选项
要提供给 setup.py install 命令的额外参数(如 –install-option=”–install-scripts=/usr/local/bin”)。使用多个 –install-option 选项将多个选项传递给 setup.py install。如果您使用带有目录路径的选项,请务必使用绝对路径。
pip install --install-option test
将发行
setup.py test
那么你需要 setup.cfg 与 setup.py 位于同一目录中:
# setup.cfg
[aliases]
test=pytest
示例设置.py:
# setup.py
"""Setuptools entry point."""
import codecs
import os
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
CLASSIFIERS = [
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Software Development :: Libraries :: Python Modules'
]
dirname = os.path.dirname(__file__)
long_description = (
codecs.open(os.path.join(dirname, 'README.rst'), encoding='utf-8').read() + '\n' +
codecs.open(os.path.join(dirname, 'CHANGES.rst'), encoding='utf-8').read()
)
setup(
name='your_package',
version='0.0.1',
description='some short description',
long_description=long_description,
long_description_content_type='text/x-rst',
author='Your Name',
author_email='[email protected] /cdn-cgi/l/email-protection',
url='https://github.com/your_account/your_package',
packages=['your_package'],
install_requires=['pytest',
'typing',
'your_package'],
classifiers=CLASSIFIERS,
setup_requires=['pytest-runner'],
tests_require=['pytest'])