← All tasks
pythonopencv/opencv-python #314Not a task: not reproduced

Building with `pip wheel` fails from repeated patch application

envgap__opencv__opencv-python-314

01 / FAILURE SIGNATURE

As reported upstream

subprocess.CalledProcessError: Command 'patch -p0 < patches/patchOpenEXR' returned non-zero exit status 1.
Not a benchmark task.
  • In a clean container the reported failure did not reproduce, or the known fix did not make the project run.

02 / ENVIRONMENT RECIPE

Base commit
35755449c6f233d877fac7594e5af82f8642fcac
Manifest
setup.py
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

opencv/opencv-python #314 · read the original issue
### 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`.

Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]