You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
try to build a C module, but don't worry if it doesn't work #48956
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/tarekziade'closed_at=<Date2009-03-31.21:59:56.374>created_at=<Date2008-12-20.14:09:52.186>labels= ['type-feature', 'library']
title="try to build a C module, but don't worry if it doesn't work"updated_at=<Date2009-03-31.21:59:56.372>user='https://bugs.python.org/zooko'
I was trying to install Twisted on my son's OLPC. Twisted comes with a
handful of C extensions which are all optional and most of which are not
expected to compile on this platform anyway (they are platform-specific
for Mac or Windows). If my son's OLPC had a C compiler installed, then
it would attempt to build those modules, fail, and proceed to install
Twisted. However, since it doesn't have a C compiler, then instead it
stops with an error.
It would be nice if Twisted could tell distutils to try to build a
module, and report whether the build succeeded, but don't stop the
entire setup().
1/ a compiler is not found, and build_ext can't proceed
2/ a compiler is found but it fails
For 2/, I don't think it's wise to fail silently if a compiler is found
and the build fails, because that can hide an unexpected problem.
For 1/ I would go for a binary distribution, or for a source
distribution that is specific to Linux in your case, if the extensions
are specific to other platforms. The latter could be done in the same
setup.py if needed by declaring the extensions only on matching platforms.
But I can see the benefit of a source distribution with optional
extensions in general. In that case, I think this option would have to
be declared optionally for each extension to be able to fail properly if
one extension is mandatory.
Yes, failure to build an extension module for any reason should
definitely cause "build" to fail by default. However, many Python
packages seem to come with optional extension modules, typically for a
performance speed-up. simplejson, zope.interface, and twisted all do
this (these are three packages that allmydata-tahoe depends on). My own
pyutil package used to do this, but I eventually just removed the
optional C extension module in order to avoid this problem. So, for
those it would be good if the package setup.py could specify that an
extension module is optional and that failure to build it for any reason
does not mean failure of the "build".
Note that twisted's setup.py already attempts to do this for certain of
its extension modules, and if I understand correctly it is able to
detect and handle failure to build if gcc fails, but not if gcc is absent.
exarkun commented on Jan 28, 2009
exarkunmannequin
Mannequin
More actions
As far as Twisted is concerned, the two cases Tarek mentioned aren't
really relevant. In order for Zooko's use case to be handled ("install
Twisted on an OLPC"), what would be ideal is if there were a way to tell
distutils about an extension which is optional. It doesn't matter if it
can be built or not. Any failure is irrelevant.
This doesn't necessarily have to mean that errors pass silently. The
build failure can still be reported. The build could even fail by
default and distutils could gain a new option for switching the behavior
to succeeding if only optional extensions fail to build. Or it could be
the other way around, with an option to make the build fail if any
optional extensions cannot be built (this approach favors people who
don't really know what a "build" is and just want something installed,
leaving the more advanced option to people who are able to figure out
that there are options that control build behavior).
zooko commented on Feb 1, 2009
zookomannequin
MannequinAuthor
More actions
Hey check it out -- simplejson can try to build its extension module,
and when it fails to compile (in this case because there is no
Python.h), then it prints out a warning message and finishes a
successful build:
zooko commented on Feb 1, 2009
zookomannequin
MannequinAuthor
More actions
Oh! And simplejson is able to cleanly fall back to pure Python when gcc
is not found, as well. Perhaps Twisted http://twistedmatrix.com/trac/ticket/3586 could use simplejson's approach.
zooko commented on Feb 1, 2009
zookomannequin
MannequinAuthor
More actions
Here's Twisted failing to build when gcc is not installed:
zooko commented on Feb 1, 2009
zookomannequin
MannequinAuthor
More actions
Here's Twisted failing to build because Python.h isn't found:
Activity
zooko commentedon Dec 20, 2008
I was trying to install Twisted on my son's OLPC. Twisted comes with a
handful of C extensions which are all optional and most of which are not
expected to compile on this platform anyway (they are platform-specific
for Mac or Windows). If my son's OLPC had a C compiler installed, then
it would attempt to build those modules, fail, and proceed to install
Twisted. However, since it doesn't have a C compiler, then instead it
stops with an error.
It would be nice if Twisted could tell distutils to try to build a
module, and report whether the build succeeded, but don't stop the
entire setup().
http://twistedmatrix.com/trac/ticket/3586
tarekziade commentedon Jan 4, 2009
I can see two cases here:
1/ a compiler is not found, and build_ext can't proceed
2/ a compiler is found but it fails
For 2/, I don't think it's wise to fail silently if a compiler is found
and the build fails, because that can hide an unexpected problem.
For 1/ I would go for a binary distribution, or for a source
distribution that is specific to Linux in your case, if the extensions
are specific to other platforms. The latter could be done in the same
setup.py if needed by declaring the extensions only on matching platforms.
But I can see the benefit of a source distribution with optional
extensions in general. In that case, I think this option would have to
be declared optionally for each extension to be able to fail properly if
one extension is mandatory.
zooko commentedon Jan 28, 2009
Tarek:
Yes, failure to build an extension module for any reason should
definitely cause "build" to fail by default. However, many Python
packages seem to come with optional extension modules, typically for a
performance speed-up. simplejson, zope.interface, and twisted all do
this (these are three packages that allmydata-tahoe depends on). My own
pyutil package used to do this, but I eventually just removed the
optional C extension module in order to avoid this problem. So, for
those it would be good if the package setup.py could specify that an
extension module is optional and that failure to build it for any reason
does not mean failure of the "build".
Note that twisted's setup.py already attempts to do this for certain of
its extension modules, and if I understand correctly it is able to
detect and handle failure to build if gcc fails, but not if gcc is absent.
exarkun commentedon Jan 28, 2009
As far as Twisted is concerned, the two cases Tarek mentioned aren't
really relevant. In order for Zooko's use case to be handled ("install
Twisted on an OLPC"), what would be ideal is if there were a way to tell
distutils about an extension which is optional. It doesn't matter if it
can be built or not. Any failure is irrelevant.
This doesn't necessarily have to mean that errors pass silently. The
build failure can still be reported. The build could even fail by
default and distutils could gain a new option for switching the behavior
to succeeding if only optional extensions fail to build. Or it could be
the other way around, with an option to make the build fail if any
optional extensions cannot be built (this approach favors people who
don't really know what a "build" is and just want something installed,
leaving the more advanced option to people who are able to figure out
that there are options that control build behavior).
zooko commentedon Feb 1, 2009
Hey check it out -- simplejson can try to build its extension module,
and when it fails to compile (in this case because there is no
Python.h), then it prints out a warning message and finishes a
successful build:
zooko commentedon Feb 1, 2009
Oh! And simplejson is able to cleanly fall back to pure Python when gcc
is not found, as well. Perhaps Twisted
http://twistedmatrix.com/trac/ticket/3586 could use simplejson's approach.
zooko commentedon Feb 1, 2009
Here's Twisted failing to build when gcc is not installed:
zooko commentedon Feb 1, 2009
Here's Twisted failing to build because Python.h isn't found: