python / cpython

The Python programming language
https://www.python.org
Other
63.62k stars 30.48k forks source link

cygwinccompiler.py fails for latest MinGW releases. #46487

Closed 19c7a0d4-c2a2-4073-a7b9-7659610829ab closed 16 years ago

19c7a0d4-c2a2-4073-a7b9-7659610829ab commented 16 years ago
BPO 2234
Nosy @amauryfa, @benjaminp
Files
  • cygwinccompiler.patch: unified patch for file cygwinccompiler.py
  • 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: ```python assignee = None closed_at = created_at = labels = ['easy', 'type-bug', 'library'] title = 'cygwinccompiler.py fails for latest MinGW releases.' updated_at = user = 'https://bugs.python.org/kermode' ``` bugs.python.org fields: ```python activity = actor = 'jlt63' assignee = 'jlt63' closed = True closed_date = closer = 'amaury.forgeotdarc' components = ['Distutils'] creation = creator = 'kermode' dependencies = [] files = ['9604'] hgrepos = [] issue_num = 2234 keywords = ['patch', 'easy'] message_count = 16.0 messages = ['63257', '64176', '64806', '64815', '67916', '67926', '67931', '67960', '67997', '68073', '68085', '68144', '69916', '71364', '71365', '71374'] nosy_count = 7.0 nosy_names = ['jlt63', 'jafo', 'amaury.forgeotdarc', 'kermode', 'benjamin.peterson', 'wmbrown', 'jamartinh'] pr_nums = [] priority = 'normal' resolution = 'fixed' stage = None status = 'closed' superseder = None type = 'behavior' url = 'https://bugs.python.org/issue2234' versions = ['Python 2.5'] ```

    19c7a0d4-c2a2-4073-a7b9-7659610829ab commented 16 years ago

    The cygwinccompiler.py module for distutils on Pythons 2.5 and 2.4 fails with an exception for the latest MinGW tools.

    running build_ext
    Traceback (most recent call last):
      File "setup.py", line 224, in <module>
        setup(**PACKAGEDATA)
      File "C:\PRG\PYTHON25\lib\distutils\core.py", line 151, in setup
        dist.run_commands()
      File "C:\PRG\PYTHON25\lib\distutils\dist.py", line 974, in run_commands
        self.run_command(cmd)
      File "C:\PRG\PYTHON25\lib\distutils\dist.py", line 994, in run_command
        cmd_obj.run()
      File "C:\PRG\PYTHON25\lib\distutils\command\build.py", line 112, in run
        self.run_command(cmd_name)
      File "C:\PRG\PYTHON25\lib\distutils\cmd.py", line 333, in run_command
        self.distribution.run_command(command)
      File "C:\PRG\PYTHON25\lib\distutils\dist.py", line 994, in run_command
        cmd_obj.run()
      File "setup.py", line 186, in run
        build_ext.run(self)
      File "C:\PRG\PYTHON25\lib\distutils\command\build_ext.py", line 264,
    in run
        force=self.force)
      File "C:\prg\pygame\trunk_\mingw32distutils.py", line 31, in new_compiler
        return Mingw32DefaultCCompiler (None, dry_run, force)
      File "C:\PRG\PYTHON25\lib\distutils\cygwinccompiler.py", line 292, in
    __init__
    CygwinCCompiler.\_\_init__ (self, verbose, dry_run, force)

    File "C:\PRG\PYTHON25\lib\distutils\cygwinccompiler.py", line 84, in __init get_versions() File "C:\PRG\PYTHON25\lib\distutils\cygwinccompiler.py", line 424, in get_vers ions ldversion = StrictVersion(result.group(1)) File "C:\PRG\PYTHON25\lib\distutils\version.py", line 40, in \_init self.parse(vstring) File "C:\PRG\PYTHON25\lib\distutils\version.py", line 107, in parse raise ValueError, "invalid version number '%s'" % vstring ValueError: invalid version number '2.18.50.20080109'

    For instance "ld -v" now returns "GNU ld (GNU Binutils) 2.18.50.20080109", not "GNU ld version 2.17.50 20060824". The extra period between the version number and date causes class StrictVersion to raise a ValueError. A fix is to alter the regular expressions in cygwinccompiler.get_versions().

    This enclosed patch to cygwinccompiler.py has been tested with the current and previous linker as well as gcc 4.2.1 and gcc 3.4.5.

    eacf80b2-9081-4882-a7f5-27e9644c3853 commented 16 years ago

    This patch looks ok to me, but I'd like jlt63 to review it since they were the last to touch these regexes.

    46b089dd-4dd4-4a01-bc73-573edfa28308 commented 16 years ago

    If the version is guaranteed to be x.y or x.y.z, then the patch seems correct. Note I am not set up to test this patch and it has been years since I have looked at this part of the code base. Sorry, that I can't be more helpful.

    19c7a0d4-c2a2-4073-a7b9-7659610829ab commented 16 years ago

    distutils.version.StrictVersion.parse does not handle x.y.z.n . That is why there is an exception. I have tested the patch both with binutils-2.18.50-20080109 (*), the latest version (a "Technology Preview"), and its predecessor binutils-2.18.50-20071123, which also works without the proposed patch. I use MinGW to build Pygame. Finally, there should be no reason to use earlier versions of binutils with Python 2.4 and up as msvcr71 support was introduced only a couple of years ago.

    (*) The MinGW binutils bundle contains both ld and dllwrap

    83a53fa5-4967-4463-a838-b7d6a6411dcb commented 16 years ago

    Same problem in version.py, line 100 (StrictVersion)

    benjaminp commented 16 years ago

    This seems to be the same as bpo-3013.

    83a53fa5-4967-4463-a838-b7d6a6411dcb commented 16 years ago

    Yes, same problem. Multiple files.

    I should have read the discussion more carefully. My note was redundant.

    Will

    ------------------ William Brown ------------------ ------ Boeing Networked Systems Technology ------ Kent:253.657.5586 Blvu:425.373.2738

    -----Original Message----- From: Benjamin Peterson [mailto:report@bugs.python.org] Sent: Tuesday, June 10, 2008 2:25 PM To: Brown, William J Subject: [bpo-2234] cygwinccompiler.py fails for latest MinGW releases.

    Benjamin Peterson \musiccomposition@gmail.com\ added the comment:

    This seems to be the same as bpo-3013.

    ---------- nosy: +benjamin.peterson


    Python tracker \report@bugs.python.org\ \http://bugs.python.org/issue2234\


    46b089dd-4dd4-4a01-bc73-573edfa28308 commented 16 years ago

    There have been three different regular expressions proposed to resolve this issue:

    1. http://bugs.python.org/issue2234
    2. http://bugs.python.org/issue3013
    3. http://cygwin.com/ml/cygwin/2008-05/msg00622.html

    Does anyone know which one is best?

    I would like to release a patched Cygwin Python 2.5.2 that resolves this issue, but I feel we should reach consensus on what regular expression to use before I do so.

    83a53fa5-4967-4463-a838-b7d6a6411dcb commented 16 years ago

    None of the above will work on both '2.18.50.20080523' & '1.2.3a'

    ------------------ William Brown ------------------ ------ Boeing Networked Systems Technology ------ Kent:253.657.5586 Blvu:425.373.2738

    46b089dd-4dd4-4a01-bc73-573edfa28308 commented 16 years ago

    I tested the regular expression in #3:

    (\d+\.\d+(\.(\d+))?(ab)?)

    and it worked for both '2.18.50.20080523' & '1.2.3a'.

    Additionally, it worked for the following test cases that I tried:

    2.18.50a.20080523 2.18.50a 20080523 2.18.50 20080523 1.2.3

    Unfortunately, I don't know what is the set of all possible version formats that "ld -v" can return. So, I don't know how to devise a regular expression guaranteed to work for all ld versions including future ones.

    AFAICT, we have only two options to resolve this issue:

    1. Improve the regular expression as best we can and continue to change it as necessary in the future.

    2. Remove the fragile version checking all together and make an explicit decision to only support modern binutils.

    Any opinions?

    83a53fa5-4967-4463-a838-b7d6a6411dcb commented 16 years ago

    Maybe I have a problem with my test code... --------------------

    import re
    
    def test_re(out_string):
        result = re.search('(\d+\.\d+(\.(\d+))?([ab](\d+))?)', out_string)
        print '--- msg00622 ---'
        print result.group(1)
        print result.group(2)
        print result.group(3)
        print result.group(4)
        print
    
    if __name__ == '__main__':    
        out_string = '2.18.50.20080523'
        test_re(out_string)
    
        out_string = '1.2.3a'
        test_re(out_string)
    
        out_string = '2.18.50a.20080523'
        test_re(out_string)

    Results... --- msg00622 --- 2.18.50 .50 50 None

    --- msg00622 --- 1.2.3 .3 3 None

    --- msg00622 --- 2.18.50 .50 50 None --------------------

    I would expect GNU to have a standard for version strings so this doesn't happen to EVERYONE when they deviate from the expected.

    A quick check in Google returned the following links for other packages...

    http://publib.boulder.ibm.com/tividd/td/ITCM/SC23-4712-01/en_US/HTML/cmm st19.htm http://java.sun.com/j2se/versioning_naming.html http://www.osgi.org/javadoc/r4/org/osgi/framework/Version.html

    Given that, I think I prefer 1 to 2.

    46b089dd-4dd4-4a01-bc73-573edfa28308 commented 16 years ago

    cygwinccompiler.py only uses the first group:

    $ fgrep group cygwinccompiler.py
                gcc_version = StrictVersion(result.group(1))
                ld_version = StrictVersion(result.group(1))
                dllwrap_version = StrictVersion(result.group(1))

    So, I would like to move forward with the regular expression from http://cygwin.com/ml/cygwin/2008-05/msg00622.html:

    (\d+\.\d+(\.(\d+))?([ab](\d+))?)

    Can we get a consensus?

    086a713c-82a6-4a5c-ba42-98dbd1426513 commented 16 years ago

    I have the same problem, i have patched the file and now it works ok.

    amauryfa commented 16 years ago

    Fixed by r65834, thanks to the patch provided in bpo-3496. Will backport.

    amauryfa commented 16 years ago

    committed r65835 in the release25-maint branch.

    46b089dd-4dd4-4a01-bc73-573edfa28308 commented 16 years ago

    Thanks!