Hi all --
at long last, I found the time to hack in the ability to compile
extension modules to the Distutils. Mainly, this meant adding a
'build_ext' command which uses a CCompiler instance for all its dirty
work. I also had to add a few methods to CCompiler (and, of course,
UnixCCompiler) to make this work.
And I added a new module, 'spawn', which takes care of running
sub-programs more efficiently and robustly (no shell involved) than
os.system. That's needed, obviously, so we can run the compiler!
If you're in the mood for grubbing over raw source code, then get the
latest from CVS or download a current snapshot. See
http://www.python.org/sigs/distutils-sig/implementation.html
for a link to the code snapshot.
I'm still waiting for more subclasses of CCompiler to appear. At the
very least, we're going to need MSVCCompiler to build extensions on
Windows. Any takers? Also, someone who knows the Mac, and how to run
compilers programmatically there, will have to figure out how to write a
Mac-specific concrete CCompiler subclass.
The spawn module also needs a bit of work to be portable. I suspect
that _win32_spawn() (the intended analog to my _posix_spawn()) will be
easy to implement, if it even needs to go in a separate function at all.
It looks from the Python Library documentation for 1.5.2 that the
os.spawnv() function is all we need, but it's a bit hard to figure out
just what's needed. Windows wizards, please take a look at the
'spawn()' function and see if you can make it work on Windows.
As for actually compiling extensions: well, if you can figure out the
build_ext command, go ahead and give it a whirl. It's a bit cryptic
right now, since there's no documentation and no example setup.py. (I
have a working example at home, but it's not available online.) If you
feel up to it, though, see if you can read the code and figure out
what's going on. I'm just hoping *I'll* be able to figure out what's
going on when I get back from the O'Reilly conference next week... ;-)
Enjoy --
Greg
--
Greg Ward - software developer gward(a)cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
Hi all --
at long last, I have fixed two problems that a couple people noticed a
while ago:
* I folded in Amos Latteier's NT patches almost verbatim -- just
changed an `os.path.sep == "/"' to `os.name == "posix"' and added
some comments bitching about the inadequacy of the current library
installation model (I think this is Python's fault, but for now
Distutils is slavishly aping the situation in Python 1.5.x)
* I fixed the problem whereby running "setup.py install" without
doing anything else caused a crash (because 'build' hadn't yet
been run). Now, the 'install' command automatically runs 'build'
before doing anything; to make this bearable, I added a 'have_run'
dictionary to the Distribution class to keep track of which commands
have been run. So now not only are command classes singletons,
but their 'run' method can only be invoked once -- both restrictions
enforced by Distribution.
The code is checked into CVS, or you can download a snapshot at
http://www.python.org/sigs/distutils-sig/distutils-19990607.tar.gz
Hope someone (Amos?) can try the new version under NT. Any takers for
Mac OS?
BTW, all parties involved in the Great "Where Do We Install Stuff?"
Debate should take a good, hard look at the 'set_final_options()' method
of the Install class in distutils/install.py; this is where all the
policy decisions about where to install files are made. Currently it
apes the Python 1.5 situation as closely as I could figure it out.
Obviously, this is subject to change -- I just don't know to *what* it
will change!
Greg
--
Greg Ward - software developer gward(a)cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive voice: +1-703-620-8990
Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
Hi all,
I've been aware that the distutils sig has been simmerring away, but
until recently it has not been directly relevant to what I do.
I like the look of the proposed api, but have one question. Will this
support an installed system that has multiple versions of the same
package installed simultaneously? If not, then this would seem to be a
significant limitation, especially when dependencies between packages
are considered.
Assuming it does, then how will this be achieved? I am presently
managing this with a messy arrangement of symlinks. A package is
installed with its version number in it's name, and a separate
directory is created for an application with links from the
unversioned package name to the versioned one. Then I just set the
pythonpath to this directory.
A sample of what the directory looks like is shown below.
I'm sure there is a better solution that this, and I'm not sure that
this would work under windows anyway (does windows have symlinks?).
So, has this SIG considered such versioning issues yet?
Cheers,
Tim
--------------------------------------------------------------
Tim Docker timd(a)macquarie.com.au
Quantative Applications Division
Macquarie Bank
--------------------------------------------------------------
qad16:qad $ ls -l lib/python/
total 110
drwxr-xr-x 2 mts mts 512 Nov 11 11:23 1.1
-r--r----- 1 root mts 45172 Sep 1 1998 cdrmodule_0_7_1.so
drwxr-xr-x 2 mts mts 512 Sep 1 1998 chart_1_1
drwxr-xr-x 3 mts mts 512 Sep 1 1998 Fnorb_0_7_1
dr-xr-x--- 3 mts mts 512 Nov 11 11:21 Fnorb_0_8
drwxr-xr-x 3 mts mts 1536 Mar 3 12:45 mts_1_1
dr-xr-x--- 7 mts mts 512 Nov 11 11:22 OpenGL_1_5_1
dr-xr-x--- 2 mts mts 1024 Nov 11 11:23 PIL_0_3
drwxr-xr-x 3 mts mts 512 Sep 1 1998 Pmw_0_7
dr-xr-x--- 2 mts mts 512 Nov 11 11:21 v3d_1_1
qad16:qad $ ls -l lib/python/1.1
total 30
lrwxrwxrwx 1 root other 29 Apr 10 10:43 _glumodule.so -> ../OpenGL_1_5_1/_glumodule.so
lrwxrwxrwx 1 root other 30 Apr 10 10:43 _glutmodule.so -> ../OpenGL_1_5_1/_glutmodule.so
lrwxrwxrwx 1 root other 22 Apr 10 10:43 _imaging.so -> ../PIL_0_3/_imaging.so
lrwxrwxrwx 1 root other 36 Apr 10 10:43 _opengl_nummodule.so -> ../OpenGL_1_5_1/_opengl_nummodule.so
lrwxrwxrwx 1 root other 27 Apr 10 10:43 _tkinter.so -> ../OpenGL_1_5_1/_tkinter.so
lrwxrwxrwx 1 mts mts 21 Apr 10 10:43 cdrmodule.so -> ../cdrmodule_0_7_1.so
lrwxrwxrwx 1 mts mts 12 Apr 10 10:43 chart -> ../chart_1_1
lrwxrwxrwx 1 root other 12 Apr 10 10:43 Fnorb -> ../Fnorb_0_8
lrwxrwxrwx 1 mts mts 12 Apr 10 10:43 mts -> ../mts_1_1
lrwxrwxrwx 1 root other 15 Apr 10 10:43 OpenGL -> ../OpenGL_1_5_1
lrwxrwxrwx 1 root other 33 Apr 10 10:43 opengltrmodule.so -> ../OpenGL_1_5_1/opengltrmodule.so
lrwxrwxrwx 1 root other 33 Apr 10 10:43 openglutil_num.so -> ../OpenGL_1_5_1/openglutil_num.so
lrwxrwxrwx 1 root other 10 Apr 10 10:43 PIL -> ../PIL_0_3
lrwxrwxrwx 1 mts mts 10 Apr 10 10:43 Pmw -> ../Pmw_0_7
lrwxrwxrwx 1 root other 10 Apr 10 10:43 v3d -> ../v3d_1_1
I just got confirmation that my original post to this sig was rejected, so
in case people have been wondering what David was talking about last week: I
sent a set of files to get distutils working on NT. I sent this message to
Greg, David, and the list. Unfortunately, it was rejected from the list
being too big (40K).
Greg suggested I resend the original pieces in smaller chunks: the patches
to the main distribution, MSVCCompiler.py, and a small sample setup.py
showing what I used to build NumPy on NT. Would anyone be interested in
taking a look at these before Greg gets back from the O'Reilly Open Source
conference next week? If so, drop me a note. I'll either email it or post it
to the list in smaller chunks if interest warrants. Otherwise I'll wait
until Greg takes a look and incorporates them into the main distribution as
he sees fit.
Here's the text that accompanied my first post:
Nice work, Greg! I thought I'd let David take a break on this one, so
attached is an MSVCCompiler, which works for me using MSVC 5.0. Not much has
changed on the command line usage for MSVC 6.0, so this should probably work
there also.
Also, I've attached a bunch of context diffs against the main distribution.
Some bug fixes, a couple other changes (like a working spawn for NT).
Oh, right. I also managed to use this to compile NumPy on Windows. I've
attached the setup script I used for that, too. This showed that we have a
few more issues to shake out, but it's looking good!
Comments on the changes (the attached diff file) and other things I noticed:
1 ) You'll notice that I added static attributes to both UnixCompiler and
MSVCCompiler to hold the normal extensions for object files, shared
libraries, static libraries, and executables (those _obj_ext, _exe_ext
things)
Also, added method object_name and shared_library_name, I needed this to
get some of the test scripts (like test_cc.py) to make sense and be more
portable. We might rethink how this info is actually accessed.
2) I needed to pass the build info to the link_shared_object methods of
ccompiler. In this case, I needed to specify the .def file for linking the
dynamic libraries. Is this ok? How else are we going to let platform
specific build info get passed? This worked for now, but it's not great.
3) Added .cpp as an allowable extension. This is almost mandatory for doing
any development on NT, since this is the default extension MSVC for a new
C++ file.
4) Modified test/test_cc.py to be a bit more readable (my preference, feel
free to ignore).
5) Had to do some awful mucking in sysconfig, as you probably know. Still
have a way to go until it really works.
6) build_py doesn't do the right thing if there are no py_modules in setup.
7) A couple bug fixes in install_py
If you have any questions about the patches, just ask.
-Perry
perry.stoll(a)mail.com
-----Original Message-----
From: David Ascher <da(a)ski.org>
To: Perry A. Stoll <pas(a)scansoft.com>
Cc: Greg Ward <gward(a)cnri.reston.va.us>; distutils-sig(a)python.org
<distutils-sig(a)python.org>
Date: Thursday, August 19, 1999 11:20 PM
Subject: Re: [Distutils] Can now compile simple extensions
>On Thu, 19 Aug 1999, Perry A. Stoll wrote:
>
>> Nice work, Greg! I thought I'd let David take a break on this one, so
>> attached is an MSVCCompiler, which works for me using MSVC 5.0. Not much
has
>> changed on the command line usage for MSVC 6.0, so this should probably
work
>> there also.
>
>Great! It's a very good thing for Greg given his talk on Monday! A very
>good thing for me (for obvious reasons), and, of course, a very good thing
>for Python users worldwide.
>
>Thanks, Perry!
>
>--david
>
>
(Doing my bi-monthly perusal of Distutils activity, I find...)
[Mark]
> .... Specifically, Greg Stien and Gordon McMillan (and plenty of
> people before them :-) seem to have what is considered "state of the
> art" in where this is heading.
[Jim Ahlstrom]
I don't know of techniques which aren't Windows specific.
Greg??Gordon??
Mark is referring to Greg's imputil.py
(http://www.lyra.org/greg/small/) and some of the places I've taken
it. My Win32-specific installer
(ftp://ftp.python.org/pub/python/contrib/System/Installer_r_01.exe)
makes use of this, but not all of it is Windows specific. (I
originally packaged it so the cross-platform stuff was available
separately, but there was no apparent interest from non-Windows
users.)
Greg's imputil.py basically makes it possible to create a chain of
importers, with the standard mechanism pushed to the end. Writing an
importer is easy. You set up the chain is site.py.
I created a way of building archives of .pyc's (or .pyo's, though
I've never worked with them). These are compressed with zlib. The
standard library fits in about 500K and (subjectively) it is no
slower and perhaps faster than the regular method. The mechanism
handles modules and packages, and the building of an archive can be
done in all kinds of ways (including using modulefinder from freeze).
I also created another kind of archive that can package up arbitrary
stuff, and is fairly easily unpacked from C code.
All of the above is cross-platform.
On Windows, this means you can have a complete Python installation
(independent of any other Python installation) in a single directory:
myPython/
python.exe (and/or pythonw.exe)
python15.dll (completely vanilla)
py_lib.pyz
exceptions.py (from the std distr)
site.py (hacked to load all the .pyz's)
[any other .pyd's or .dll's you want]
[more .pyz's if you want]
[more .py's if you want]
(The Window's installation / standalone stuff goes further than this).
These .pyz's do work on Linux, but the steps Python goes through to
determine where it lives is simpler on Windows. I'm not sure what it
would take to get a single directory Python installation
(independent of any other installed Pythons) working on *nix.
- Gordon
Warning, new comer at large.
I've been playing with Gordon's win32 installer and really
like the idea of the .pyz to wrap things up. I've been doing
the same thing with zlib to create .pyc files. I send them
too other people I work with. They execute the .pyc which
explodes on their disk. It runs a setup.py file and handles
platform details.
Archives are real handy and zip is a pretty standard one.
So wouldn't zip compatibility be good. It seems that
understanding the header format for zip along with zlib
might let you decode a zip.
There's a bunch of zip info at:
http://www.cdrom.com/pub/infozip/Info-ZIP.html
And an unzip.dll that could be used if decoding the header
was too much pain.
Has anyone tried to work with zips from python ?
--Darrell