testing-cabal / mock

The Python mock library
https://docs.python.org/dev/library/unittest.mock.html
BSD 2-Clause "Simplified" License
536 stars 107 forks source link

pip install mock failed using local filesystem #467

Closed sanket-rathi closed 5 years ago

sanket-rathi commented 5 years ago

I am trying to install one python module that needs mock in air gap environment (I can not create wheel). So I downloaded all the required python modules source and trying to install using pip but it is failing to install mock. Then I tried to install only mock and that is failing too. I tried on different platforms (CentOS, Mac) and same result. It is trying to download pbr but that is already present in the directory. If I install pbr and then install mock it works. If I try in non air gap environment (with local) then also works because it download the package from web. Not sure why it is not using local pbr source to build and install. I need this for my environment.

$ls -l mock-2.0.0.tar.gz six-1.12.0.tar.gz pbr-5.4.1.tar.gz -rw-r--r-- 1 sanket staff 73684 Jul 22 09:48 mock-2.0.0.tar.gz -rw-r--r-- 1 sanket staff 118704 Jul 22 09:49 pbr-5.4.1.tar.gz -rw-r--r-- 1 sanket staff 32725 Jul 22 09:49 six-1.12.0.tar.gz (python_venv) ~/test/gsutil $ (python_venv) ~/test/gsutil $python3 -m pip install mock --no-index --find-links file:///$PWD Looking in links: file:////Users/sanket/test/gsutil Collecting mock ERROR: Complete output from command python setup.py egg_info: ERROR: Download error on https://pypi.org/simple/pbr/: [Errno 8] nodename nor servname provided, or not known -- Some packages may not be found! Couldn't find index page for 'pbr' (maybe misspelled?) Download error on https://pypi.org/simple/: [Errno 8] nodename nor servname provided, or not known -- Some packages may not be found! No local packages or working download links found for pbr>=1.3 Traceback (most recent call last): File "", line 1, in File "/private/var/folders/7f/903rgbjj0492746b4rylp7bh0000gn/T/pip-install-wmeajk9x/mock/setup.py", line 6, in pbr=True) File "/Users/sanket/test/python_venv/lib/python3.7/site-packages/setuptools/init.py", line 144, in setup _install_setup_requires(attrs) File "/Users/sanket/test/python_venv/lib/python3.7/site-packages/setuptools/init.py", line 139, in _install_setup_requires dist.fetch_build_eggs(dist.setup_requires) File "/Users/sanket/test/python_venv/lib/python3.7/site-packages/setuptools/dist.py", line 717, in fetch_build_eggs replace_conflicting=True, File "/Users/sanket/test/python_venv/lib/python3.7/site-packages/pkg_resources/init.py", line 782, in resolve replace_conflicting=replace_conflicting File "/Users/sanket/test/python_venv/lib/python3.7/site-packages/pkg_resources/init.py", line 1065, in best_match return self.obtain(req, installer) File "/Users/sanket/test/python_venv/lib/python3.7/site-packages/pkg_resources/init.py", line 1077, in obtain return installer(requirement) File "/Users/sanket/test/python_venv/lib/python3.7/site-packages/setuptools/dist.py", line 784, in fetch_build_egg return cmd.easy_install(req) File "/Users/sanket/test/python_venv/lib/python3.7/site-packages/setuptools/command/easy_install.py", line 673, in easy_install raise DistutilsError(msg) distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('pbr>=1.3')

ERROR: Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/7f/903rgbjj0492746b4rylp7bh0000gn/T/pip-install-wmeajk9x/mock/ (python_venv) ~/test/gsutil $

If Install pbr first separately then it works.

(python_venv) ~/test/gsutil $python3 -m pip install pbr --no-index --find-links file:///$PWD Looking in links: file:////Users/sanket/test/gsutil Collecting pbr Installing collected packages: pbr Running setup.py install for pbr ... done Successfully installed pbr-5.4.1 (python_venv) ~/test/gsutil $ (python_venv) ~/test/gsutil $python3 -m pip install mock --no-index --find-links file:///$PWD Looking in links: file:////Users/sanket/test/gsutil Collecting mock Requirement already satisfied: pbr>=0.11 in /Users/sanket/test/python_venv/lib/python3.7/site-packages (from mock) (5.4.1) Collecting six>=1.9 (from mock) Installing collected packages: six, mock Running setup.py install for six ... done Running setup.py install for mock ... done Successfully installed mock-2.0.0 six-1.12.0 (python_venv) ~/test/gsutil $

cjw296 commented 5 years ago

Please can you use the latest version of mock.

sanket-rathi commented 5 years ago

Thank you that worked. But I tried to download all the files for gsutil and there mock-2.0 is getting downloaded not the latest one. I used the following command. Every time mock-2.0 gets downloaded using following not latest one.

python3 -m pip download --no-binary=:all: gsutil

or

pip-download gsutil

pipdeptre shows gsutil needs mock 2.0