[Distutils] PATCH: sysconfig and NT

Amos Latteier amos@aracnet.com
Fri, 16 Apr 1999 14:19:22 -0700


At 07:18 PM 4/15/99 -0600, Andrew Dalke wrote:
>Amos Latteier <amos@aracnet.com> said:
>> I noticed that distutils installs itself under 'lib\site-packages'
>> which does not seem to be a convention under NT, at least the
>> directory does not exist by default, and is not in the Python path
>> by default.
>
>It directory is added by site.py, which is imported when you
>start python (unless you use 
>"python -S").  Quoting from it:
>| This will append site-specific paths to to the module search path.  On
>| Unix, it starts with sys.prefix and sys.exec_prefix (if different) and
>| appends lib/python<version>/site-packages as well as lib/site-python.
>| On other platforms (mainly Mac and Windows), it uses just sys.prefix
>| (and sys.exec_prefix, if different, but this is unlikely).  The
>| resulting directories, if they exist, are appended to sys.path, and
>| also inspected for path configuration files.

Exactly. On Windows, the site directory is just sys.exec_prefix, rather
than sys.exex_prefix/lib/python<version>/site-packages.

So now we need additional fixes to distutils to handle this platform
difference.

>Anyway, lib's "site-packages" is the official place for installing
>Python packages.

On Unix ;-)

>from your patch:
>>     g['LIBDEST']=os.path.join(sys.exec_prefix, "Lib")
>>     g['BINLIBDEST']=os.path.join(sys.exec_prefix, "Lib")
>
>Is that really "Lib" or just "lib"?  Granted, it is NT which means
>I know nearly diddly about it.

I guess it should be 'lib'. I don't know. I just used 'Lib' cause that's
what the some other Python path directories (set in the registry) call it...

OK, here's two patches, one to handle the site-package platform
differences, another repeat of my last one, only this time with 'lib', not
'Lib'

RCS file: /projects/cvsroot/distutils/distutils/sysconfig.py,v
retrieving revision 1.5
diff -r1.5 sysconfig.py
131,132c131,140
<
<
---
> def _init_nt():
>     """Initialize the module as appropriate for NT"""
>     g=globals()
>     # load config.h, though I don't know how useful this is
>     parse_config_h(open(
>             os.path.join(sys.exec_prefix, "include", "config.h")), g)
>     # set basic install directories
>     g['LIBDEST']=os.path.join(sys.exec_prefix, "lib")
>     g['BINLIBDEST']=os.path.join(sys.exec_prefix, "lib")
>
141a150
> del _init_nt


RCS file: /projects/cvsroot/distutils/distutils/command/install.py,v
retrieving revision 1.1
diff -r1.1 install.py
110d109
<
112,113c111,115
<             self.install_site_lib = \
<                 os.path.join (self.install_lib, 'site-packages')
---
>             if os.sep == '/':
>                 self.install_site_lib = \
>                     os.path.join (self.install_lib, 'site-packages')
>             else:
>                 self.install_site_lib = self.exec_prefix
118,120c120,124
<             self.install_site_platlib = \
<                 os.path.join (self.install_lib, 'site-packages')
<
---
>             if os.sep == '/':
>                 self.install_site_platlib = \
>                     os.path.join (self.install_lib, 'site-packages')
>             else:
>                 self.install_site_platlib = self.exec_prefix


With these patches distutils installs itself correctly on NT for me.

-Amos