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

时间:2018-10-17 16:11:58

标签: python pip install setuptools setup.py

在浪费几天之后,我正在寻求帮助。 我正在尝试在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.*',
)

我的点子版本是9.0.1(在Python 27中)

我的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示例): enter image description here

这就是我所拥有的: enter image description here

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

1 个答案:

答案 0 :(得分:2)

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

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

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

$ 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

相关问题