本文介绍了来自一个 setup.py 的多个项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前的 setup.py(使用 setuptools)安装两件事,一个是tvdb_api(一个API包装器),另一个是tvnamer(一个命令行脚本)

My current setup.py (using setuptools) installs two things, one is tvdb_api (an API wrapper), the other is tvnamer (a command line script)

我希望将两者分开使用,以便用户可以...

I wish to make the two available separately, so a user can do..

easy_install tvdb_api

.. 只获取 API 包装器,或者..

..to only get the API wrapper, or..

easy_install tvnamer

..安装 tvnamer(和 tvdb_api,作为要求)

..to install tvnamer (and tvdb_api, as a requirement)

如果没有两个单独的 setup.py 脚本,这可能吗?你能有来自同一个 python setup.py upload 命令的两个单独的 PyPi 包吗?

Is this possible without having two separate setup.py scripts? Can you have two separate PyPi packages that come from the same python setup.py upload command..?

推荐答案

setup.py 只是一个常规的 Python 文件,按照惯例,它用于设置包.按照惯例,setup.py 包含对 setuptools 或 distutils setup() 函数的调用.如果你想对两个包使用一个 setup.py,你可以根据命令行参数调用不同的 setup() 函数:

setup.py is just a regular Python file, which by convention sets up packages. By convention, setup.py contains a call to the setuptools or distutils setup() function. If you want to use one setup.py for two packages, you can call a different setup() function based on a command-line argument:

import sys
if len(sys.argv) > 1 and sys.argv[1] == 'script':
    sys.argv = [sys.argv[0]] + sys.argv[2:]
    setup(name='tvnamer', ...)
else:
    setup(name='tvdb_api', ...)

不过,实际上,我建议您只编写两个脚本.

Practically, though, I'd recommend just writing two scripts.

这篇关于来自一个 setup.py 的多个项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 13:58