Skip to content

Building with pip wheel fails from repeated patch application #314

Closed
@uSpike

Description

@uSpike

Expected behaviour

pip wheel path/to/opencv-python should work the same as python setup.py bdist_wheel

Actual behaviour

pip wheel https://github.com/skvark/opencv-python@34#egg=opencv-python fails because patches are applied multiple times. The patch command is run each time setup.py main() is called, and pip wheel calls setup.py multiple times.

Steps to reproduce

On a system that applies patches (currently sys.platform == 'darwin' or sys.platform.startswith('linux') and not x64), run pip wheel https://github.com/skvark/opencv-python#egg=opencv-python. The resultant output:

  ERROR: Command errored out with exit status 1:
   command: /home/me/src/piwheels/venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-req-build-6he24q5u/setup.py'"'"'; __file__='"'"'
/tmp/pip-req-build-6he24q5u/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code,
 __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-oeddjr7s
       cwd: /tmp/pip-req-build-6he24q5u/
  Complete output (21 lines):
<snip>
    ['python/cv2[^/]*%(ext)s' % {'ext': re.escape(sysconfig.get_config_var('SO'))}],
  patching file opencv/3rdparty/openexr/IlmImf/ImfSystemSpecific.cpp
  Reversed (or previously applied) patch detected!  Assume -R? [n]
  Apply anyway? [n]
  Skipping patch.
  4 out of 4 hunks ignored -- saving rejects to file opencv/3rdparty/openexr/IlmImf/ImfSystemSpecific.cpp.rej
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-req-build-6he24q5u/setup.py", line 398, in <module>
      main()
    File "/tmp/pip-req-build-6he24q5u/setup.py", line 160, in main
      subprocess.check_call("patch -p0 < patches/patchOpenEXR", shell=True)
    File "/home/me/.pyenv/versions/3.8.2/lib/python3.8/subprocess.py", line 364, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command 'patch -p0 < patches/patchOpenEXR' returned non-zero exit status 1.

I would suggest updating setup.py to only patch when "bdist_wheel" in sys.argv.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions