Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backport optional extension building for python 2.7 #107

Merged
merged 2 commits into from
Aug 10, 2018

Conversation

RonnyPfannschmidt
Copy link
Contributor

this sorts out the issues i caused on python2.7 by backporting the approach of the python3 optional parameter to python2

this fixes regressions introduced in #106

setup.py Outdated
@@ -2,12 +2,15 @@

try:
from setuptools import setup, Extension
from setuptolls.command.build_ext import build_ext as base_build_ext

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be setuptools, no? (Not tolls...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yikes, yes, im going to put in a warning with the exception when it fails


warnings.warn("import of setuptools failed %r" % val)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this warning is necessary -- it falls back to distutils anyway. It seems to me this was added to debug a spelling mistake in an earlier commit. Now that we're importing it correctly, let's just leave this out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd like to leave it in so user see that setuptools is missing
from a packaging standpoint i'd like to completely remove the support for plain distutils if this was my project

@@ -25,8 +33,18 @@
long_description = f.read()


# the extension is optional since in case of lack of c the api
# there is a ctypes fallback and a slow python fallback
class BuildExt(base_build_ext):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this code copied from somewhere, the Python 3.x optional=true code or something? Just curious.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its a small reimplementation of the python3 mechanism, which has a context managers and a few more bits to sort it out

except Exception:
exception = sys.exc_info()[0]
logging.warn("building the %s failed with %s", ext.name, exception)

extension = Extension('_scandir', ['_scandir.c'], optional=True)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this still fail as we still always include the optional=True flag here? Or is it just a warning and so we're ignoring it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its just a warning on python2, i'm ignoring it here

the `build_ext command is what's interpreting those

@benhoyt benhoyt merged commit 5080836 into benhoyt:master Aug 10, 2018
@nicoddemus
Copy link

Thanks @benhoyt for merging this. 👍

Would you mind pinging this issue when a new release comes out? Thanks!

@benhoyt
Copy link
Owner

benhoyt commented Aug 10, 2018

Done! It's version 1.9.0.

@nicoddemus
Copy link

Awesome, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants