GrahamDumpleton / wrapt

A Python module for decorators, wrappers and monkey patching.
BSD 2-Clause "Simplified" License
2.06k stars 231 forks source link

pip install does not fallback to python-only mode gracefully #95

Closed Jerhaad closed 7 years ago

Jerhaad commented 7 years ago

A simple pip install wrapt can fail because of missing complier. Installing from source setup.py works fine.

PIP log attached. wrapt_fail.txt

GrahamDumpleton commented 7 years ago

Can you download the zip file from:

and unpack it.

Edit the setup.py file and add an extra except clause at end saying:

    except Exception as e:
        print(e)
        raise

That will allow me to see what exception type is actually being raised instead of expected BuildExtFailed.

Then package back into zip file and do:

pip install file.zip

or instead simply try:

pip install .
Jerhaad commented 7 years ago

I tried it on another machine and it worked as expected. I'll try to reproduce the issue on the original machine.

Jerhaad commented 7 years ago

Here you go. I should have posted this information originally, but I figured it would all be in the pip log.

I think what we're seeing is an OSError for file not found. Perhaps wrapt/_wrappers.c? Installing via setup.py directly worked as expected again. That makes me think this is an sdist vs. bdist issue.

wrapt_fail2.txt

GrahamDumpleton commented 7 years ago

Perhaps. I should probably have asked you to also include:

print(type(e))

I already have IOError in list to look for, but not OSError.

if sys.platform == 'win32':
    build_ext_errors = (CCompilerError, DistutilsExecError,
            DistutilsPlatformError, IOError)
else:
    build_ext_errors = (CCompilerError, DistutilsExecError,
            DistutilsPlatformError)

class BuildExtFailed(Exception):
    pass

class optional_build_ext(build_ext):
    def run(self):
        try:
            build_ext.run(self)
        except DistutilsPlatformError:
            raise BuildExtFailed()

    def build_extension(self, ext):
        try:
            build_ext.build_extension(self, ext)
        except build_ext_errors:
            raise BuildExtFailed()
GrahamDumpleton commented 7 years ago

Closing this. A version was released that already checked for OSError. If still occurs, need to know the specific type.