This is the mail archive of the cygwin-apps@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Cygwin Python sys.platform and distutils.util.get_platform() patch


I would like to submit the attached patch (i.e., the first attachment)
to Python CVS for inclusion in 2.2.  IMO, this is the right solution for
many reasons.  I have included one example as the the second attachment.
If the patch is accepted, then I will back patch and re-release my Cygwin
Python 2.1 distribution.

Since these two simple changes have possibly far reaching ramifications,
I thought that it would be prudent to solicit feedback before submitting
the patch.  My goal is to eliminate (or at least minimize) the heartache
caused by these changes, if any.

Note that the two parts of the patch are actually independent but
related so I have decided to submit them as one patch instead of two.

The first part changes sys.platform, sys.path, and the platform specific
module directory name as follows:

    $ # before patch
    $ python -c 'import sys; print sys.platform'
    cygwin_nt-4.01
    $ python -c 'import sys; print sys.path'
    [..., '/usr/lib/python2.1/plat-cygwin_nt-4.01', ...]
    $ find /usr/lib/python2.1 -name '*cygwin*' -type d
    /usr/lib/python2.1/plat-cygwin_nt-4.01

    $ # after patch
    $ python -c 'import sys; print sys.platform'
    cygwin
    $ python -c 'import sys; print sys.path'
    [..., '/usr/lib/python2.1/plat-cygwin', ...]
    $ find /usr/lib/python2.1 -name '*cygwin*' -type d
    /usr/lib/python2.1/plat-cygwin

The second part changes sys.path (only when Python is run out of the
build tree) and the directory names used by distutils when building
extension modules:

    $ # before patch
    $ python -c 'import sys; print sys.path'
    [..., '/home/jt/src/Python-2.1/build/lib.cygwin_nt-4.0-1.3.2-i686-2.1']
    $ find . -name '*cygwin*'
    ./build/lib.cygwin_nt-4.0-1.3.0-i686-2.1
    ./build/temp.cygwin_nt-4.0-1.3.0-i686-2.1

    $ # after patch
    $ python -c 'import sys; print sys.path'
    [..., '/home/jt/src/Python-2.1/build/lib.cygwin-1.3.2-i686-2.1']
    $ find . -name '*cygwin*'
    ./build/lib.cygwin-1.3.2-i686-2.2
    ./build/temp.cygwin-1.3.2-i686-2.2

If I don't receive any negative responses to this patch proposal by
2001/6/1 9:00 EDT, then I will submit this patch to the SourceForge
Python Patch Manager.

Thanks,
Jason

-- 
Jason Tishler
Director, Software Engineering       Phone: 732.264.8770 x235
Dot Hill Systems Corp.               Fax:   732.264.8798
82 Bethany Road, Suite 7             Email: Jason.Tishler@dothill.com
Hazlet, NJ 07730 USA                 WWW:   http://www.dothill.com
Index: configure.in
===================================================================
RCS file: /cvsroot/python/python/dist/src/configure.in,v
retrieving revision 1.218
diff -c -r1.218 configure.in
*** configure.in	2001/05/11 16:10:56	1.218
--- configure.in	2001/05/28 01:10:03
***************
*** 66,71 ****
--- 66,72 ----
  	MACHDEP="$ac_md_system$ac_md_release"
  
  	case $MACHDEP in
+ 	cygwin*) MACHDEP="cygwin";;
  	'')	MACHDEP="unknown";;
  	esac
  fi
Index: Lib/distutils/util.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/distutils/util.py,v
retrieving revision 1.63
diff -c -r1.63 util.py
*** Lib/distutils/util.py	2001/03/23 17:30:26	1.63
--- Lib/distutils/util.py	2001/05/28 01:10:03
***************
*** 62,67 ****
--- 62,68 ----
      elif osname[:3] == "aix":              
          return "%s-%s.%s" % (osname, version, release)
      elif osname[:6] == "cygwin":
+         osname = "cygwin"
          rel_re = re.compile (r'[\d.]+')
          m = rel_re.match(release)
          if m:


Hello Jason

I would like your opinion on another minor Cygwin Python distutils buglet.

I recently installed Konrad Hinsen's Scientific Python package with the
Python package you built for Cygwin. This package creates one C-extension
DLL, which is supposed to be installed into

    /usr/lib/python2.1/site-packages/Scientific/cygwin_nt-4.01

..but it is actually put into...

    /usr/lib/python2.1/site-packages/Scientific/cygwin_nt-4/01

..where Python doesn't find it.

Scientific Python's setup.py includes the following line

       ext_package = 'Scientific.'+sys.platform,

I presume the '.' in sys.platform on the Cygwin system is being interpreted
as a delimiter in the package's directory hierarchy. Konrad confirmed this
interpretation, but also commented that he was not aware of any other
platform which has a '.' in sys.platform.

On the only other Unix platform I have easy access to, bash's MACHTYPE is
alphaev6-dec-osf5.1 and Python's sys.platform is 'osf1V5'.

So should Cygwin Python's sys.platform be calculated differently?

---
Mark Hadfield
m.hadfield@niwa.cri.nz  http://katipo.niwa.cri.nz/~hadfield
National Institute for Water and Atmospheric Research





Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]