Force setuptools to use dependency_links to install mysqlclient

匿名 (未验证) 提交于 2019-12-03 01:05:01

问题:

I'm using Windows, and I need to install the WHL file from here. Here's what I have in setup.py:

install_requires=['mysqlclient==1.3.7', ... dependency_links=['https://pypi.python.org/packages/cp27/m/mysqlclient/mysqlclient-1.3.7-cp27-none-win32.whl#md5=e9e726fd6f1912af78e2bf6ab56c02f3',] 

However, setuptools is downloading the tar.gz file instead and attempting to build, which won't work on my system. I followed this solution and changed my install_requires to use mysqlclient<=1.3.7, but I still get the same problem. Here is the output:

Searching for mysqlclient<=1.3.7 Reading https://pypi.python.org/packages/cp27/P/Pillow/Pillow-2.7.0-cp27-none-win32.whl#md5=ebc4ef88a8dd39ed484206323a8d557a Reading https://pypi.python.org/packages/cp27/m/mysqlclient/mysqlclient-1.3.7-cp27-none-win32.whl#md5=e9e726fd6f1912af78e2bf6ab56c02f3 Reading http://pypi.python.org/simple/mysqlclient/ Best match: mysqlclient 1.3.7 Downloading https://pypi.python.org/packages/source/m/mysqlclient/mysqlclient-1.3.7.tar.gz#md5=2ec5a96cbd9fd6ef343fa9b581a67fc4 Processing mysqlclient-1.3.7.tar.gz Running mysqlclient-1.3.7\setup.py -q bdist_egg --dist-dir c:\users\uuu\appdata\local\temp\easy_install-wt7fkw\mysqlclient-1.3.7\egg-dist-tmp-ubrs4f error: Setup script exited with error: Unable to find vcvarsall.bat 

I don't have any issues with install Pillow using the link in the dependency_links. Is there a way to force setup.py to use the dependency link?

回答1:

I ended up manually installing the package as a part of the post install:

from setuptools.command.install import install as _install import pip  class install(_install):   def run(self):     _install.do_egg_install(self)      # Even when dependeny link to mysqlclient is specified, setuptools still installs     # from pypi, which does not work on Windows.  Therefore, manually install mysqlclient     if os.name == 'nt':       pip.main(['install', 'https://pypi.python.org/packages/cp27/m/mysqlclient/mysqlclient-1.3.7-cp27-none-win32.whl#md5=e9e726fd6f1912af78e2bf6ab56c02f3'])     else:       pip.main(['install', 'mysqlclient==1.3.7'])  setup(       cmdclass={'install': install}, ... ) 

There are other answers that call _install.run(), but that didn't work for me. I had to use do_egg_install().



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!