[Distutils] Cygwin Python Distutils Build Problem
Jason Tishler
Jason.Tishler@dothill.com
Wed Feb 21 14:10:01 2001
--futHohkuO/V6j/1Y
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
On Wed, Feb 21, 2001 at 03:42:04PM +0100, M.-A. Lemburg wrote:
> I don't want distutils to go into the beta with this known
> problem. The patch that you posted seems to be the way to go,
> so I am very much for putting it into the core unless is breaks
> something else which doesn't seem to be the case.
>
> Anyway, please post the patch and a summary of the problem to
> distutils -- maybe Rene knows more about this.
Marc Lemburg recently committed a patch to facilitate the building of
his mx Extensions under Cygwin. I have attached his patch as the first
attachment for easy access. See the following for details, if interested:
http://sourceforge.net/patch/?func=detailpatch&patch_id=103868&group_id=5470
Unfortunately, this patch breaks the Cygwin Python build. Specifically,
the standard (shared extension) modules no longer build. See the second
attachment for details, if interested.
Being very inexperienced with distutils, I humbly offered the following
WAG patch which corrected the Cygwin Python build problem. The purpose of
this patch is to (re)enable distutils to use the Makefile variables such as
CCSHARED, LDSHARED, etc. when building shared extensions under Cygwin just
like on all other UNIXes. Please see the third attachment for details.
We have the following questions:
1. Is my patch the best way to resolve this issue?
2. The current cygwinccompiler.py (around line 97) has some hardcoded
gcc options (i.e., using -static instead -shared) that appear to
be out of date. Should these be revisited too?
Hopefully, more knowledgeable people can help us resolve these issues
before the first beta.
Thanks,
Jason
--
Jason Tishler
Director, Software Engineering Phone: +1 (732) 264-8770 x235
Dot Hill Systems Corp. Fax: +1 (732) 264-8798
82 Bethany Road, Suite 7 Email: Jason.Tishler@dothill.com
Hazlet, NJ 07730 USA WWW: http://www.dothill.com
--futHohkuO/V6j/1Y
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="ccompiler.py.patch"
Index: ccompiler.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/distutils/ccompiler.py,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- ccompiler.py 2001/01/16 03:10:43 1.37
+++ ccompiler.py 2001/02/19 09:20:04 1.38
@@ -5,9 +5,9 @@
# created 1999/07/05, Greg Ward
-__revision__ = "$Id: ccompiler.py,v 1.37 2001/01/16 03:10:43 akuchling Exp $"
+__revision__ = "$Id: ccompiler.py,v 1.38 2001/02/19 09:20:04 lemburg Exp $"
-import sys, os
+import sys, os, re
from types import *
from copy import copy
from distutils.errors import *
@@ -835,13 +835,45 @@
# class CCompiler
-# Map a platform ('posix', 'nt') to the default compiler type for
-# that platform.
-default_compiler = { 'posix': 'unix',
- 'nt': 'msvc',
- 'mac': 'mwerks',
- }
+# Map a sys.platform/os.name ('posix', 'nt') to the default compiler
+# type for that platform. Keys are interpreted as re match
+# patterns. Order is important; platform mappings are preferred over
+# OS names.
+_default_compilers = (
+ # Platform string mappings
+ ('cygwin.*', 'cygwin'),
+
+ # OS name mappings
+ ('posix', 'unix'),
+ ('nt', 'msvc'),
+ ('mac', 'mwerks'),
+
+ )
+
+def get_default_compiler(osname=None, platform=None):
+
+ """ Determine the default compiler to use for the given platform.
+
+ osname should be one of the standard Python OS names (i.e. the
+ ones returned by os.name) and platform the common value
+ returned by sys.platform for the platform in question.
+
+ The default values are os.name and sys.platform in case the
+ parameters are not given.
+
+ """
+ if osname is None:
+ osname = os.name
+ if platform is None:
+ platform = sys.platform
+ for pattern, compiler in _default_compilers:
+ if re.match(pattern, platform) is not None or \
+ re.match(pattern, osname) is not None:
+ return compiler
+ # Default to Unix compiler
+ return 'unix'
+
# Map compiler types to (module_name, class_name) pairs -- ie. where to
# find the code that implements an interface to this compiler. (The module
# is assumed to be in the 'distutils' package.)
@@ -896,7 +928,7 @@
try:
if compiler is None:
- compiler = default_compiler[plat]
+ compiler = get_default_compiler(plat)
(module_name, class_name, long_description) = compiler_class[compiler]
except KeyError:
--futHohkuO/V6j/1Y
Content-Type: message/rfc822
Content-Disposition: inline
Date: Mon, 19 Feb 2001 17:10:03 -0500
From: Jason Tishler <Jason.Tishler@dothill.com>
To: "M.-A. Lemburg" <mal@lemburg.com>
Cc: nhv@cape.com
Bcc: jt+misc.copy@ny.dothill.com
Subject: Re: [Distutils] Beta-release of installers for mx Extensions
Message-ID: <20010219171003.R211@dothill.com>
References: <000a01c09a18$a57d0360$a300a8c0@nhv> <3A914E98.8FA6FF51@lemburg.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.2.5i
In-Reply-To: <3A914E98.8FA6FF51@lemburg.com>; from mal@lemburg.com on Mon, Feb 19, 2001 at 05:49:28PM +0100
Organization: Dot Hill Systems Corp.
Marc,
On Mon, Feb 19, 2001 at 05:49:28PM +0100, M.-A. Lemburg wrote:
> Great :-) If you're the right person to ask, I have a question
> about sys.platform on cygwin: if not absolutely necessary, I'd
> suggest removing the version number and platform ID (nt, 98)
> in sys.platform.
>
> This information is normally not needed since cygwin tries
> to provide a posix subsystem. If it is needed, I'd suggest taking
> a look at platform.py (available on my Python Pages) and
> adding cygwin support to it.
I will respond to the above shortly, but please see below...
> > Jason has been monitoring the py-devel list and I try
> > to read it over the web on at least a semi-regular basis
> > for potential Cygwin related issues. I monitor the distutils list
> >
> > Feel free to continue to ask Cygwin related questions
> > and or request beta testing for Cygwin compatability
> > in the future.
>
> See above ;-)
>
> I have checked in the patch in a slightly different form.
> Could you check whether it now defaults to cygwin for cygwin
> compiler Pythons ?
Your patch broke the building of the standard (shared extension) modules
under Cygwin.
For example in 2.1a2, we had the following:
..
./python.exe ./setup.py build
running build
running build_ext
building 'struct' extension
creating build
creating build/temp.cygwin_nt-4.0-1.3.0-i686-2.1
gcc -g -O2 -Wall -Wstrict-prototypes -DUSE_DL_IMPORT -I. -I/home/jt/src/Python-2.1a2/./Include -IInclude/ -I/usr/local/include -c /home/jt/src/Python-2.1a2/Modules/structmodule.c -o build/temp.cygwin_nt-4.0-1.3.0-i686-2.1/structmodule.o
creating build/lib.cygwin_nt-4.0-1.3.0-i686-2.1
gcc -shared -Wl,--enable-auto-image-base build/temp.cygwin_nt-4.0-1.3.0-i686-2.1/structmodule.o -L. -L/usr/local/lib -lpython2.1 -o build/lib.cygwin_nt-4.0-1.3.0-i686-2.1/struct.dll
..
Now we have the following:
..
PYTHONPATH= ./python.exe ./setup.py build
running build
running build_ext
building 'struct' extension
creating build
creating build/temp.cygwin_nt-4.0-1.3.0-i686-2.1
gcc -mcygwin -mdll -O -Wall -I. -I/home/jt/src/PythonCvs/./Include -IInclude/ -I/usr/local/include -c /home/jt/src/PythonCvs/Modules/structmodule.c -o build/temp.cygwin_nt-4.0-1.3.0-i686-2.1/structmodule.o
writing build/temp.cygwin_nt-4.0-1.3.0-i686-2.1/struct.def
creating build/lib.cygwin_nt-4.0-1.3.0-i686-2.1
gcc -mcygwin -mdll -static -s build/temp.cygwin_nt-4.0-1.3.0-i686-2.1/structmodule.o build/temp.cygwin_nt-4.0-1.3.0-i686-2.1/struct.def -L. -L/usr/local/lib -lpython2.1 -o build/lib.cygwin_nt-4.0-1.3.0-i686-2.1/struct.dll
/usr/lib/gcc-lib/i686-pc-cygwin/2.95.2-7/../../../../i686-pc-cygwin/bin/ld: cannot find -lpython2.1
collect2: ld returned 1 exit status
WARNING: building of extension "struct" failed: command 'gcc' failed with exit status 1
..
During compilation, we now are/have:
missing -DUSE_DL_IMPORT option (i.e., CCSHARED variable)
extraneous -mcygwin -mdll options
During linking, we now are/have:
missing -shared -Wl,--enable-auto-image-base options
extraneous -mcygwin -mdll -static -s options
If I use the latest CVS but downgrade Lib/distutils/ccompiler.py to
1.37, then the build succeeds.
I'm willing to help you resolve this problem, please let me know how I
can help.
Thanks,
Jason
--
Jason Tishler
Director, Software Engineering Phone: +1 (732) 264-8770 x235
Dot Hill Systems Corp. Fax: +1 (732) 264-8798
82 Bethany Road, Suite 7 Email: Jason.Tishler@dothill.com
Hazlet, NJ 07730 USA WWW: http://www.dothill.com
--futHohkuO/V6j/1Y
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="sysconfig.py.patch"
Index: sysconfig.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/distutils/sysconfig.py,v
retrieving revision 1.33
diff -u -r1.33 sysconfig.py
--- sysconfig.py 2001/02/16 03:31:13 1.33
+++ sysconfig.py 2001/02/20 16:26:45
@@ -117,7 +117,7 @@
'compiler'. Mainly needed on Unix, so we can plug in the information
that varies across Unices and is stored in Python's Makefile.
"""
- if compiler.compiler_type == "unix":
+ if compiler.compiler_type in ["unix", "cygwin"]:
(cc, opt, ccshared, ldshared, so_ext) = \
get_config_vars('CC', 'OPT', 'CCSHARED', 'LDSHARED', 'SO')
--futHohkuO/V6j/1Y--