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

distutils does not show any error msg when can't build C module extensions due to a missing C compiler #49181

Closed
giampaolo opened this issue Jan 13, 2009 · 15 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@giampaolo
Copy link
Contributor

BPO 4931
Nosy @loewis, @amauryfa, @giampaolo, @tarekziade, @merwok, @takluyver
Files
  • distutils_ioerror.patch
  • 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/merwok'
    closed_at = <Date 2014-03-12.08:25:30.156>
    created_at = <Date 2009-01-13.17:31:04.888>
    labels = ['type-bug', 'library']
    title = "distutils does not show any error msg when can't build C module extensions due to a missing C compiler"
    updated_at = <Date 2014-03-12.08:25:30.154>
    user = 'https://github.com/giampaolo'

    bugs.python.org fields:

    activity = <Date 2014-03-12.08:25:30.154>
    actor = 'eric.araujo'
    assignee = 'eric.araujo'
    closed = True
    closed_date = <Date 2014-03-12.08:25:30.156>
    closer = 'eric.araujo'
    components = ['Distutils', 'Distutils2']
    creation = <Date 2009-01-13.17:31:04.888>
    creator = 'giampaolo.rodola'
    dependencies = []
    files = ['12739']
    hgrepos = []
    issue_num = 4931
    keywords = ['patch']
    message_count = 15.0
    messages = ['79751', '79767', '79769', '79845', '101389', '101390', '117690', '120588', '120611', '212907', '212909', '213207', '213208', '213213', '213219']
    nosy_count = 8.0
    nosy_names = ['loewis', 'jafo', 'amaury.forgeotdarc', 'giampaolo.rodola', 'tarek', 'eric.araujo', 'python-dev', 'takluyver']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue4931'
    versions = ['Python 2.7', 'Python 3.3', 'Python 3.4']

    @giampaolo
    Copy link
    Contributor Author

    Today I was trying to compile a module using an extension in C and
    noticed there are differences between compiling it on Python 2.5 and 2.6.
    I was trying to compile psutil (svn checkout
    http://psutil.googlecode.com/svn/trunk/ psutil) but I think that the
    problem may occur with any other package using C extensions.

    Python 2.5:

    D:\pyftpdlib\svn\psutil\trunk>C:\python25\python.exe setup.py install
    running install
    running build
    running build_ext
    error: Python was built with Visual Studio 2003;
    extensions must be built with a compiler than can generate compatible
    binaries.
    Visual Studio 2003 was not found on this system. If you have Cygwin
    installed,
    you can try compiling with MingW32, by passing "-c mingw32" to setup.py.

    Python 2.6:

    D:\pyftpdlib\svn\psutil\trunk>C:\python26\python.exe setup.py install
    running install
    running build
    running build_ext
    building 'psutil/_psutil_mswindows' extension
    error: None

    @giampaolo giampaolo added the stdlib Python modules in the Lib dir label Jan 13, 2009
    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Jan 13, 2009

    What is the specific error you are reporting?

    @giampaolo
    Copy link
    Contributor Author

    Currently I haven't any C compiler installed on my system so I expect
    distutils to report that every time I try to compile a C module extension.
    Python 2.5 did that while Python 2.6 does not.

    @amauryfa
    Copy link
    Member

    The problem has two causes:

    • IOError is raised when no compiler is found. DistutilsPlatformError
      should be used instead, this was fixed by bpo-4702.

    • the distutils.util.grok_environment_error function transforms a
      IOError("Unable to find vcvarsall.bat") into "error: None".

    This function should not be used IMO. Its docstring claims that it
    "Handles Python 1.5.1 and 1.5.2 styles", but str() does a better job...

    Patch attached.

    @tarekziade tarekziade mannequin self-assigned this Feb 6, 2009
    @jafo
    Copy link
    Mannequin

    jafo mannequin commented Mar 20, 2010

    Tarek: This patch seems reasonable to me, is this something that can be applied?

    @tarekziade
    Copy link
    Mannequin

    tarekziade mannequin commented Mar 20, 2010

    I guess i can be applied on distutils, and backported in distutils2. I'll do it in the coming days.

    Notice that I am now applying only bug fixes and regression fixes now for distutils.

    @merwok
    Copy link
    Member

    merwok commented Sep 30, 2010

    I will commit this if Tarek does not do it shortly.

    In distutils2, I’ll remove grok_environment_error wholly, since it exists for 1.5 compat only.

    @merwok merwok assigned merwok and unassigned tarekziade Sep 30, 2010
    @merwok merwok added the type-bug An unexpected behavior, bug, or error label Sep 30, 2010
    @merwok
    Copy link
    Member

    merwok commented Nov 6, 2010

    Giampaolo, can you test Amaury’s patch? I’d prefer some testing before committing.

    @giampaolo
    Copy link
    Contributor Author

    I don't have the same setup I had at the time when I submitted the first message so maybe something has changed in meantime.
    Below is what I get on Windows 2000 SP-3, no VS installed, python 2.7, before and after the patch.

    C:\Documents and Settings\foo\Desktop\psutil>setup.py build
    running build
    running build_py
    copying psutil\compat.py -> build\lib.win32-2.7\psutil
    copying psutil\error.py -> build\lib.win32-2.7\psutil
    copying psutil\_psbsd.py -> build\lib.win32-2.7\psutil
    copying psutil\_pslinux.py -> build\lib.win32-2.7\psutil
    copying psutil\_psmswindows.py -> build\lib.win32-2.7\psutil
    copying psutil\_psosx.py -> build\lib.win32-2.7\psutil
    copying psutil\_psposix.py -> build\lib.win32-2.7\psutil
    copying psutil\init.py -> build\lib.win32-2.7\psutil
    running build_ext
    building '_psutil_mswindows' extension
    error: Unable to find vcvarsall.bat

    Although the message is improved ("Unable to find vcvarsall.bat" vs "None") it seems the patch had no effect.

    @takluyver
    Copy link
    Mannequin

    takluyver mannequin commented Mar 7, 2014

    Any chance of getting this patch applied? It clearly makes the error message more useful, and we've run into another case where grok_environment_error gives the wrong result: when symlinking fails because the target exists, it now says "File exists: <source>", because e.filename is the source and e.filename2 the target.

    It's also rather embarassing that a function in Python 3.4 still says "Handles Python 1.5.1 and 1.5.2 styles..." in the docstring.

    @merwok
    Copy link
    Member

    merwok commented Mar 7, 2014

    I want to make time for Python bugs again, so I’ll try and finish this bug soon.

    See also msg200785 for a report from setuptools with an easy to reuse test case.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 12, 2014

    New changeset a865f6fb82b4 by Éric Araujo in branch '2.7':
    Avoid “error: None” messages from distutils (bpo-4931).
    http://hg.python.org/cpython/rev/a865f6fb82b4

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 12, 2014

    New changeset 0f1237b61f58 by Éric Araujo in branch '2.7':
    Restore missing part of error message (bpo-4931)
    http://hg.python.org/cpython/rev/0f1237b61f58

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Mar 12, 2014

    New changeset 504eb00998f2 by Éric Araujo in branch '3.3':
    Avoid “error: None” messages from distutils (bpo-4931).
    http://hg.python.org/cpython/rev/504eb00998f2

    New changeset c7bd0f953687 by Éric Araujo in branch 'default':
    Merge 3.3 (bpo-4931)
    http://hg.python.org/cpython/rev/c7bd0f953687

    @merwok
    Copy link
    Member

    merwok commented Mar 12, 2014

    Happy to close this as fixed.

    @merwok merwok closed this as completed Mar 12, 2014
    @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-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants