如何限制 python 模块安装在特定版本的 Python 中?

How to restrict python module to be installed in specific version of Python?

在浪费了几天时间之后,我正在寻求帮助。 我正在尝试在 setup.py:

中指定 Python 2.7
from setuptools import setup, find_packages

setup(
name = 'MyPackageName',
version = '1.0.0',
url = 'https://github.com/mypackage.git',
author = 'Author Name',
author_email = 'author@gmail.com',
description = 'Description of my package',
packages = find_packages(),    
python_requires='>=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*',
)

我的pip版本是9.0.1(在Python27)

我的 setuptools 版本是 38.4.0(在 Python 27 中)

我安装了 3 个 Python:2.5、2.7、3.6

我正在用 (Python 27):

构建一个 exe

python setup.py bdist_wininst

创建了很好的 MyPackageName-1.0.0.win32.exe

这就是我要实现的目标(Py 2.5 的 numpy 示例):

这是我拥有的:

如有任何提示,我将不胜感激。

使用--target-version限制解释器版本:

$ python setup.py bdist_wininst --target-version 2.7

将构建安装程序 MyPackageName-1.0.0.win32-py2.7.exe。安装时,它将限制找到的版本列表以匹配目标版本,或者在 none 中显示错误对话框。多次传递该选项将为每个版本生成多个安装程序,例如

$ python setup.py bdist_wininst --target-version 2.5 --target-version 2.7

将生成两个安装程序,MyPackageName-1.0.0.win32-py2.5.exeMyPackageName-1.0.0.win32-py2.7.exe