为什么不推荐使用setup.py中的依赖关系链接?

时间:2017-09-20 11:01:12

标签: python pip setuptools setup.py

有很多人想知道setup.py中的依赖关系链接的替代方法(使用pip标记--process-dependency-links激活):What is the alternative to using --process-dependency-links with pipDepend on git repository in setup.py。基本上,我被弃用警告所困扰:

"DEPRECATION: Dependency Links processing has been deprecated and will be removed in a future release."

有些人建议使用requirements.txt,但这不是替代方案,因为它旨在提供整个环境,通常与开发更相关。 install_requires应该提供一种最小的库集合,这些库是使用标准功能所必需的,因此当您执行pip install [LIBRARY]之类的操作时,会安装所需的所有内容,而不会进一步pip install -r requirements.txt pip install [LIBRARY] 1}}(我指的是git+http:\\github.com\username\repo.git的LIBRARY参数将以dependency_links等URL的形式出现的情况。

我对弃用的问题是我不能引用内部/私有包,但是如果需要在git中引用特定的提交或分支,我也可以看到这可能是一个问题(至少我知道我已经完成了这在过去)。

所有这一切,使用dependency_links是复杂的,例如语法并不总是很清楚,存在多种指定URL的方法,人们往往会忘记他们必须在install_requires# declares the files used gameslist = 'gameslist.txt' filenames = ['filename1','filename2' ,'filename3'] for filename in filenames: # imports the necessary libraries import os, time from stat import * # ST_SIZE etc # finds the time the file was last modified and prints it try: st = os.stat(filename) except IOError: print("failed to get information about", filename) else: print("At:", time.asctime(time.localtime(st[ST_MTIME]))) with open(filename, 'r') as f: file_content = f.read() # checks the file for the string 'Minecraft' if 'Minecraft' in file_content: print('{} was playing Minecraft'.format(filename)) # checks the file for the string 'LoL' if 'LoL' in file_content: print('{} was playing LoL'.format(filename)) 列表中放置库的名称版本。我想听到这种弃用有利于改进,但似乎并非如此

总而言之,弃用依赖关系链接的原因是什么?依赖关系链接的弃用是否有利于更好的选择?它似乎不是there is an alternative

1 个答案:

答案 0 :(得分:2)

  

弃用依赖关系链接的原因是什么?

安全。当启用依赖关系链接时,可以使用pip从互联网上获取任意URL并从中运行代码 - 这显然不是一个好主意。

您可以在原始帖子中详细了解它:https://mail.python.org/pipermail/distutils-sig/2013-October/022937.html

另外值得一提的是,现在已经实现了依赖链接的替代方案--PEP 508 URL依赖关系。它只需要更好地支持用于替换依赖链接的用例。 (关于它的更新是关于您链接到的问题)

相关问题