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

try to build a C module, but don't worry if it doesn't work #48956

Closed
zooko mannequin opened this issue Dec 20, 2008 · 8 comments
Closed

try to build a C module, but don't worry if it doesn't work #48956

zooko mannequin opened this issue Dec 20, 2008 · 8 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@zooko
Copy link
Mannequin

zooko mannequin commented Dec 20, 2008

BPO 4706
Nosy @tarekziade
Superseder
  • bpo-5583: Optional extensions in setup.py
  • Files
  • build-with-no-Python.h.txt
  • build-with-no-gcc.txt
  • Twisted-build-with-no-gcc.txt
  • Twisted-build-no-Python.h.txt
  • 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 = <Date 2009-03-31.21:59:56.374>
    created_at = <Date 2008-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 = <Date 2009-03-31.21:59:56.372>
    user = 'https://bugs.python.org/zooko'

    bugs.python.org fields:

    activity = <Date 2009-03-31.21:59:56.372>
    actor = 'tarek'
    assignee = 'tarek'
    closed = True
    closed_date = <Date 2009-03-31.21:59:56.374>
    closer = 'tarek'
    components = ['Distutils']
    creation = <Date 2008-12-20.14:09:52.186>
    creator = 'zooko'
    dependencies = []
    files = ['12910', '12911', '12912', '12913']
    hgrepos = []
    issue_num = 4706
    keywords = []
    message_count = 8.0
    messages = ['78106', '79047', '80681', '80682', '80896', '80897', '80898', '80899']
    nosy_count = 3.0
    nosy_names = ['zooko', 'exarkun', 'tarek']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = None
    status = 'closed'
    superseder = '5583'
    type = 'enhancement'
    url = 'https://bugs.python.org/issue4706'
    versions = ['Python 3.1', 'Python 2.7']

    @zooko
    Copy link
    Mannequin Author

    zooko mannequin commented 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

    @zooko zooko mannequin added the stdlib Python modules in the Lib dir label Dec 20, 2008
    @tarekziade
    Copy link
    Mannequin

    tarekziade mannequin commented 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.

    @tarekziade tarekziade mannequin added the type-feature A feature request or enhancement label Jan 4, 2009
    @zooko
    Copy link
    Mannequin Author

    zooko mannequin commented 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
    Copy link
    Mannequin

    exarkun mannequin commented 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
    Copy link
    Mannequin Author

    zooko mannequin commented 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
    Copy link
    Mannequin Author

    zooko mannequin commented 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
    Copy link
    Mannequin Author

    zooko mannequin commented Feb 1, 2009

    Here's Twisted failing to build when gcc is not installed:

    @zooko
    Copy link
    Mannequin Author

    zooko mannequin commented Feb 1, 2009

    Here's Twisted failing to build because Python.h isn't found:

    @tarekziade tarekziade mannequin closed this as completed Mar 31, 2009
    @tarekziade tarekziade mannequin self-assigned this Mar 31, 2009
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    0 participants