Issue2552

classification
Title: installing scandir via pip fails (breaks e.g. installing pathlib2 via pip)
Type: behaviour Severity: normal
Components: Versions: Jython 2.7
Milestone: Jython 2.7.1
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: stefan.richthofer Nosy List: stefan.richthofer, zyasoft
Priority: normal Keywords:

Created on 2017-02-22.03:33:56 by stefan.richthofer, last changed 2017-06-09.04:53:53 by zyasoft.

Messages
msg11108 (view) Author: Stefan Richthofer (stefan.richthofer) Date: 2017-02-22.03:33:56
bin/pip install scandir
Collecting scandir
  Using cached scandir-1.5.tar.gz
Installing collected packages: scandir
  Running setup.py install for scandir ... error
    Complete output from command /data/workspace/linux/Jython/installer_test/linux_2.7.1/bin/jython -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-88durY/scandir/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-wqw0MV-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.java1.8.0_121-2.7
    copying scandir.py -> build/lib.java1.8.0_121-2.7
    running build_ext
    building '_scandir' extension
    error: Compiling extensions is not supported on Jython
    
    ----------------------------------------
Command "/data/workspace/linux/Jython/installer_test/linux_2.7.1/bin/jython -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-88durY/scandir/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-wqw0MV-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-88durY/scandir/


The sad thing here is that scandir is actually workable with Jython, only the setup fails. What needs to be done to let setup process pass over the failed extension build and end up fine?
Currently this breaks the whole process if scandir is just installed as dependency, e.g. when installing pathlib2.

I observed this issue equally on Linux and Windows using Java 8 + current Jython trunk version.
msg11124 (view) Author: Stefan Richthofer (stefan.richthofer) Date: 2017-02-24.13:03:44
Changing in Lib/distutils/jythoncompiler.py

raise CCompilerError('Compiling extensions is not supported on Jython')

to

warnings.warn('Compiling extensions is not supported on Jython')

solves this. I'd suggest to apply this. It might move some setup-time issues to import-time, but that's IMO preferable over refusing to setup workable libraries due to a maybe optional C-extension.
For non-optional C-extensions, users should be aware that "setup works" not yet means "import works" anyway.
msg11125 (view) Author: Stefan Richthofer (stefan.richthofer) Date: 2017-02-24.13:05:35
Forgot to mention:
After
warnings.warn('Compiling extensions is not supported on Jython')
empty list must be returned (return []) rather than None
msg11126 (view) Author: Stefan Richthofer (stefan.richthofer) Date: 2017-02-24.13:36:30
Fixed this like described as of https://hg.python.org/jython/rev/24ef3218632f
msg11129 (view) Author: Stefan Richthofer (stefan.richthofer) Date: 2017-02-25.14:20:48
Note that this issue usually can be circumvented by using
setup.py build_py

However I don't know a proper way to do this if pip is in the way. I looked into pip options and found nothing to prevent pip from building c-extensions/let pip use build_py instead of build.

If someone can tell me such a way I would revert this fix and instead modify the error message to point to the appropriate flag.
msg11423 (view) Author: Jim Baker (zyasoft) Date: 2017-06-09.04:53:52
Confirmed the installation works on OS X 10.12 and Ubuntu 16.04, with the scandir function also working as expected.
History
Date User Action Args
2017-06-09 04:53:53zyasoftsetstatus: pending -> closed
nosy: + zyasoft
messages: + msg11423
2017-02-25 14:20:49stefan.richthofersetmessages: + msg11129
2017-02-24 13:36:30stefan.richthofersetstatus: open -> pending
resolution: fixed
messages: + msg11126
2017-02-24 13:05:36stefan.richthofersetmessages: + msg11125
2017-02-24 13:04:14stefan.richthofersetpriority: normal
assignee: stefan.richthofer
versions: + Jython 2.7
type: behaviour
milestone: Jython 2.7.1
2017-02-24 13:03:44stefan.richthofersetmessages: + msg11124
2017-02-22 03:33:56stefan.richthofercreate