1
votes

I am trying to install pact-python... That is all. I have tried with virtualenv and without, still getting the same error. I'm running: pip install pact-python.

I've also tried adding the flag to not use cache for the install, --no-cache-dir.

I am using python 2.7.14 on Windows 10.

Output:

pip install pact-python --no-cache-dir
Collecting pact-python
  Downloading pact-python-0.10.0.tar.gz
Requirement already satisfied: click>=2.0.0 in c:\rep\test_project\env\lib\site-packages (from pact-python)
Requirement already satisfied: psutil>=2.0.0 in c:\rep\test_project\env\lib\site-packages (from pact-python)
Requirement already satisfied: requests>=2.5.0 in c:\rep\test_project\env\lib\site-packages (from pact-python)
Requirement already satisfied: six>=1.9.0 in c:\rep\test_project\env\lib\site-packages (from pact-python)
Requirement already satisfied: subprocess32 in c:\rep\test_project\env\lib\site-packages (from pact-python)
Requirement already satisfied: chardet=3.0.2 in c:\rep\test_project\env\lib\site-packages (from requests>=2.5.0->pact-python)
Requirement already satisfied: certifi>=2017.4.17 in c:\rep\test_project\env\lib\site-packages (from requests>=2.5.0->pact-python)
Requirement already satisfied: urllib3=1.21.1 in c:\rep\test_project\env\lib\site-packages (from requests>=2.5.0->pact-python)
Requirement already satisfied: idna=2.5 in c:\rep\test_project\env\lib\site-packages (from requests>=2.5.0->pact-python)
Installing collected packages: pact-python
  Running setup.py install for pact-python ... error
    Complete output from command c:\rep\test_project\env\scripts\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\212683~1\\appdata\\local\\temp\\pip-build-b0yskn\\pact-python\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record c:\users\212683~1\appdata\local\temp\pip-tbudil-record\install-record.txt --single-version-externally-managed --compile --install-headers c:\rep\test_project\env\include\site\python2.7\pact-python:
    running install
    running build
    running build_py
    creating build
    creating build\lib
    creating build\lib\pact
    copying pact\constants.py -> build\lib\pact
    copying pact\consumer.py -> build\lib\pact
    copying pact\matchers.py -> build\lib\pact
    copying pact\pact.py -> build\lib\pact
    copying pact\provider.py -> build\lib\pact
    copying pact\verify.py -> build\lib\pact
    copying pact\__init__.py -> build\lib\pact
    copying pact\__version__.py -> build\lib\pact
    running install_lib
    creating c:\rep\test_project\env\Lib\site-packages\pact
    copying build\lib\pact\constants.py -> c:\rep\test_project\env\Lib\site-packages\pact
    copying build\lib\pact\consumer.py -> c:\rep\test_project\env\Lib\site-packages\pact
    copying build\lib\pact\matchers.py -> c:\rep\test_project\env\Lib\site-packages\pact
    copying build\lib\pact\pact.py -> c:\rep\test_project\env\Lib\site-packages\pact
    copying build\lib\pact\provider.py -> c:\rep\test_project\env\Lib\site-packages\pact
    copying build\lib\pact\verify.py -> c:\rep\test_project\env\Lib\site-packages\pact
    copying build\lib\pact\__init__.py -> c:\rep\test_project\env\Lib\site-packages\pact
    copying build\lib\pact\__version__.py -> c:\rep\test_project\env\Lib\site-packages\pact
    byte-compiling c:\rep\test_project\env\Lib\site-packages\pact\constants.py to constants.pyc
    byte-compiling c:\rep\test_project\env\Lib\site-packages\pact\consumer.py to consumer.pyc
    byte-compiling c:\rep\test_project\env\Lib\site-packages\pact\matchers.py to matchers.pyc
    byte-compiling c:\rep\test_project\env\Lib\site-packages\pact\pact.py to pact.pyc
    byte-compiling c:\rep\test_project\env\Lib\site-packages\pact\provider.py to provider.pyc
    byte-compiling c:\rep\test_project\env\Lib\site-packages\pact\verify.py to verify.pyc
    byte-compiling c:\rep\test_project\env\Lib\site-packages\pact\__init__.py to __init__.pyc
    byte-compiling c:\rep\test_project\env\Lib\site-packages\pact\__version__.py to __version__.pyc
    running install_egg_info
    running egg_info
    writing requirements to pact_python.egg-info\requires.txt
    writing pact_python.egg-info\PKG-INFO
    writing top-level names to pact_python.egg-info\top_level.txt
    writing dependency_links to pact_python.egg-info\dependency_links.txt
    writing entry points to pact_python.egg-info\entry_points.txt
    reading manifest file 'pact_python.egg-info\SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    no previously-included directories found matching 'pact\test'
    no previously-included directories found matching 'pact\bin'
    no previously-included directories found matching 'e2e'
    writing manifest file 'pact_python.egg-info\SOURCES.txt'
    Copying pact_python.egg-info to c:\rep\test_project\env\Lib\site-packages\pact_python-0.10.0-py2.7.egg-info
    running install_scripts
    Installing pact-verifier-script.py script to c:\rep\test_project\env\Scripts
    Installing pact-verifier.exe script to c:\rep\test_project\env\Scripts
    Installing pact-verifier.exe.manifest script to c:\rep\test_project\env\Scripts
    writing list of installed files to 'c:\users\212683~1\appdata\local\temp\pip-tbudil-record\install-record.txt'
    Traceback (most recent call last):
      File "", line 1, in 
      File "c:\users\212683~1\appdata\local\temp\pip-build-b0yskn\pact-python\setup.py", line 139, in 
        setup(**setup_args)
      File "c:\rep\test_project\env\lib\site-packages\setuptools\__init__.py", line 129, in setup
        return distutils.core.setup(**attrs)
      File "c:\python27\Lib\distutils\core.py", line 151, in setup
        dist.run_commands()
      File "c:\python27\Lib\distutils\dist.py", line 953, in run_commands
        self.run_command(cmd)
      File "c:\python27\Lib\distutils\dist.py", line 972, in run_command
        cmd_obj.run()
      File "c:\users\212683~1\appdata\local\temp\pip-build-b0yskn\pact-python\setup.py", line 54, in run
        install_ruby_app(bin_path)
      File "c:\users\212683~1\appdata\local\temp\pip-build-b0yskn\pact-python\setup.py", line 92, in install_ruby_app
        with ZipFile(path) as f:
      File "c:\python27\Lib\zipfile.py", line 770, in __init__
        self._RealGetContents()
      File "c:\python27\Lib\zipfile.py", line 811, in _RealGetContents
        raise BadZipfile, "File is not a zip file"
    zipfile.BadZipfile: File is not a zip file

    ----------------------------------------
Command "c:\rep\test_project\env\scripts\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\212683~1\\appdata\\local\\temp\\pip-build-b0yskn\\pact-python\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record c:\users\212683~1\appdata\local\temp\pip-tbudil-record\install-record.txt --single-version-externally-managed --compile --install-headers c:\rep\test_project\env\include\site\python2.7\pact-python" failed with error code 1 in c:\users\212683~1\appdata\local\temp\pip-build-b0yskn\pact-python\

When I try and look at this file c:\users\212683~1\appdata\local\temp\pip-build-b0yskn\pact-python\setup.py to see what is going on, it doesn't exist. My assumption here was that this was maybe only be used during the install.

Expectation: The install succeeds.

Actual:

  File "c:\python27\Lib\zipfile.py", line 811, in _RealGetContents
        raise BadZipfile, "File is not a zip file"
    zipfile.BadZipfile: File is not a zip file

EDIT: I've been investigating and in the setup.py of pact-python is looks like it installs a ruby app.

I do have a C:\rep\test_project\env\Lib\site-packages\pact\bin\win32.zip but it appears to be empty.

EDIT 2: So what I've found is that in the setup.py, it is building a uri to download pact-ruby-standalone from. The uri that is build is https://github.com/pact-foundation/pact-ruby-standalone/releases/download/v1.1.1/pact-1.1.1-win32.zip.

My guess is that the download is failing and therefore the file has nothing written in it so when the code reaches Zipfile(path), the win32.zip has nothing written in it and is then not able to extract anything? Looking into this.

3

3 Answers

1
votes

We discovered that our internal proxy was unable to handle the request to download the file for some reason.

We are working internally for solutions to better manage things like this.

0
votes

Good luck with the proxy. If you're interested in what the Ruby code is, have a read of the Pact History (relevant quote below): https://docs.pact.io/about_pact/history.html

Soon it became obvious that Javascript UIs would benefit greatly from using Pact with their backend APIs. After tossing around the idea of implementing Pact yet again in another language, a decision was made to wrap the Ruby implementation (which was packaged as a standalone executable) to avoid the maintenance burden and potential of implementation mismatches. This became the pattern that was used for all the following Pact implementations. Each language implemented a Pact DSL and mock service/verifier client, and called out to the Ruby mock service process/verifier in the background.

0
votes

Sorry, forgot to post the resolution. What it turned out to be was that python-pact is setup to download the ruby-pact, as Beth Skurrie mentioned above pact implementations are wrapped around the ruby implementation.

What was happening was my proxy was setup in my session and not globally which allowed pip to start installing pact-python but when pact-python reaches out for the ruby implementation, I think it was an http download or something, the proxy from my session wasn't being used and therefore leaving the .zip empty.

This resulted in the error described originally.

Hope this helps someone working with proxies someday!