Hi again --
[cc'd to Paul Dubois: you said you weren't following the distutils sig
anymore, but this directly concerns NumPy and I'd like to get your
input!]
here's that sample setup.py for NumPy. See below for discussion (and
questions!).
------------------------------------------------------------------------
#!/usr/bin/env python
# Setup script example for building the Numeric extension to Python.
# This does sucessfully compile all the .dlls. Nothing happens
# with the .py files currently.
# Move this file to the Numerical directory of the LLNL numpy
# distribution and run as:
# python numpysetup.py --verbose build_ext
#
# created 1999/08 Perry Stoll
__rcsid__ = "$Id: numpysetup.py,v 1.1 1999/09/12 20:42:48 gward Exp $"
from distutils.core import setup
setup (name = "numerical",
version = "0.01",
description = "Numerical Extension to Python",
url = "http://www.python.org/sigs/matrix-sig/",
ext_modules = [ ( '_numpy', { 'sources' : [ 'Src/_numpymodule.c',
'Src/arrayobject.c',
'Src/ufuncobject.c'
],
'include_dirs' : ['./Include'],
'def_file' : 'Src/numpy.def' }
),
( 'multiarray', { 'sources' : ['Src/multiarraymodule.c'],
'include_dirs' : ['./Include'],
'def_file': 'Src/multiarray.def'
}
),
( 'umath', { 'sources': ['Src/umathmodule.c'],
'include_dirs' : ['./Include'],
'def_file' : 'Src/umath.def' }
),
( 'fftpack', { 'sources': ['Src/fftpackmodule.c', 'Src/fftpack.c'],
'include_dirs' : ['./Include'],
'def_file' : 'Src/fftpack.def' }
),
( 'lapack_lite', { 'sources' : [ 'Src/lapack_litemodule.c',
'Src/dlapack_lite.c',
'Src/zlapack_lite.c',
'Src/blas_lite.c',
'Src/f2c_lite.c'
],
'include_dirs' : ['./Include'],
'def_file' : 'Src/lapack_lite.def' }
),
( 'ranlib', { 'sources': ['Src/ranlibmodule.c',
'Src/ranlib.c',
'Src/com.c',
'Src/linpack.c',
],
'include_dirs' : ['./Include'],
'def_file' : 'Src/ranlib.def' }
),
]
)
------------------------------------------------------------------------
First, what d'you think? Too clunky and verbose? Too much information
for each extension? I kind of think so, but I'm not sure how to reduce
it elegantly. Right now, the internal data structures needed to compile
a module are pretty obviously exposed: is this a good thing? Or should
there be some more compact form for setup.py that will be expanded later
into the full glory we see above?
I've already made one small step towards reducing the amount of cruft by
factoring 'include_dirs' out and supplying it directly as a parameter to
'setup()'. (But that needs code not in the CVS archive yet, so I've
left the sample setup.py the same for now.)
The next thing I'd like to do is get that damn "def_file" out of there.
To support it in MSVCCompiler, there's already an ugly hack that
unnecessarily affects both the UnixCCompiler and CCompiler classes, and
I want to get rid of that. (I refer to passing the 'build_info'
dictionary into the compiler classes, if you're familiar with the code
-- that dictionary is part of the Distutils extension-building system,
and should not propagate into the more general compiler classes.)
But I don't want to give these weird "def file" things standing on the
order of source files, object files, libraries, etc., because they seem
to me to be a bizarre artifact of one particular compiler, rather than
something present in a wide range of C/C++ compilers.
Based on the NumPy model, it seems like there's a not-too-kludgy way to
handle this problem. Namely:
if building extension "foo":
if file "foo.def" found in same directory as "foo.c"
add "/def:foo.def" to MSVC command line
this will of course require some platform-specific code in the build_ext
command class, but I figured that was coming eventually, so why put it
off? ;-)
To make this hack work with NumPy, one change would be necessary: rename
Src/numpy.def to Src/_numpy.def to match Src/_numpy.c, which implements
the _numpy module. Would this be too much to ask of NumPy? (Paul?)
What about other module distributions that support MSVC++ and thus ship
with "def" files? Could they be made to accomodate this scheme?
Thanks for your feedback --
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 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
Hi All,
I finally got to delve into Distutils 0.1.2 over the long weekend, and I think
it is a very nice package. The architecture is very clean and extensible, and
the code is consistent, well commented, and well organized. Thanks, Greg!
I've enclosed a patch which addresses a particular concern of mine: package
meta-information. At the end of the install command, it creates a package
information file in <install_py.install_dir>/_pkginfo named after the package
(it also creates the "_pkginfo" directory, if necessary). The file contains
python variable definitions for the package name, version number, list of
files installed, dependencies, and compatible versions (although the latter
two are always empty at this time).
The module that is used to record and obtain package information can be
overriden on the command line (install_info --pkg-module <your-module>).
Also, if a global "pkginfo" module exists, it will be used instead of the
default distutils.pkginfo module (whose behavior is described above). I
envision the installer using whatever package information system is most
appropriate for the system (RPM's for Linux, Registry files for Windows[?]).
Meta-information facilitates uninstall, dependency checking, automatic
downloading of dependencies, and system cataloging. I'd be interested in
contributing some of these features to distutils, and welcome any discussion
on the subject, particularly since it is relevant to my day job.
=============================================================================
michaelMuller = mmuller(a)enduden.com | http://www.cloud9.net/~proteus
-----------------------------------------------------------------------------
There is no concept that is more demeaning to the human spirit than the
notion that our freedom must be limited in the interests of our own
protection.
=============================================================================
Hi,
Generally I'm looking at distutils to see if it can help me simplify
the installation of some of the JPython modules I have created.
A JPython modules could typically consists of:
- .py files
- .jar file or .class files
- .dll files
Lets first assume that all these files have been compiled and built
in some traditional way. In order to get started with distutils, I
will avoid any attempt to compile any of the C/C++ source at the
target machine. So this is windows only, at least to begin with.
My primary target user is a java/jpython developer.
Copying the .py files works like a dream.
For .jar files, the situation get more complicated. A jar file could:
a) be copied to an well-known directory f.ex. a subdir to sys.prefix.
The JPython startup script would then have to be changed. I.e.
inserting the new .jar in the -classpath or /cp option to the
java command.
b) If using Sun-JDK, the jar could be copied to the "$java.ext.dir"
directory in the JDK/JRE installation.
c) If using MS-jview, the jar could be extracted into
"$java.home\Lib" or "$java.home\TrustLib" directory.
java.home is narmmaly something like "c:\windows\Java"
d) Some other directory, leaving it entirely up to the user to fiddle
with startup scripts and CLASSPATH environment variables.
Other JVMs could possible have different default places where class
files are located. Even if distutils will support all methods, I think
the user must be queried which strategy she want to use.
For .dll files, the situation get similar. A dll file could:
a) be copied to one of the directories on the current PATH (only
easily available in Sun-JDK as $java.library.path)
b) be copied to JVM specific exe directory. $java.home/bin in the
JDK/JRE for Sun-JDK, $com.ms.sysdir in c:\windows\system32
for MS-jview.
c) Some other directory, leaving it up the user to change the $PATH /
$LD_LIBRARY_PATH(?) environment variables.
Again, I think the user must be queried before .dll files can be
copied.
These are normal installation issues. I am a bit unsure on how much I
can reasonably expect distutils to deal with this. From my very
limited experience with distutils, I think distutils is exactly the
right place to put some of the logic that deals with JVM and OS
dependencies as described above.
Any thoughs?
Buglets and suggestions:
a) Documentation buglet. In the USAGE file for "dist", -f is described
as an alias for --formats. -f does not work.
b) How about allowing for some alias names for the README file. Some
of us lazy double-clicking windows types prefer names like README.txt.
c) Why are "packages" and "py_module" mutually exclusive. One of my
products happens to have a toplevel module which contains "from
pck.Main import *". I think that I find the current behavior limiting.
regards,
finn
[Crossposted to xml-sig, distutils-sig]
I'm working on getting the XML-SIG's CVS tree to install using the
current version of the Distutils. Right now there are two C
extensions, sgmlop.so and pyexpat.so, and they're installed under
xml/parsers/ . It's hard to handle this case using the distutils code
as it stands, because it expects to put extensions into a
build/platlib/ directory, from which they'll be installed into
site-packages.
I can coerce setup.py into installing them into xml/parsers/, by
subclassing the BuildExt command and setting build_dir myself:
from distutils.command.build_ext import BuildExt
class XMLBuildExt(BuildExt):
def set_default_options (self):
BuildExt.set_default_options( self )
self.build_dir = 'lib/build/xml/parser'
setup (name = "PyXML", cmdclass = {'build_ext':XMLBuildExt}, ...)
You also have to subclass the Install command and set build_dir
there; I've trimmed that code. It's really clunky.\
Note that this scheme will break once there are C modules that need to
be installed anywhere other than xml/parsers/, because build_dir is
being hardwired without knowledge of what module is being compiled.
Questions:
1) A general Python question about packaging style: Is mixing
C extensions and Python modules in one package tree a bad
idea? It makes the whole tree platform-dependent, which is
probably annoying for sites maintaining Python installation
for different architectures.
2) Another general question, this time o: how should this be
handled? Should C extensions always be effectively
top-level, and therefore go into site-packages? Should
there be an xml package holding .py files, and an X package
holding all the C extensions? (X = 'plat_xml',
'xml_binary', or something like that)
3) XML-SIG question: should I go ahead and change it (since I
first changed it to use xml.parsers.sgmlop)?
4) Distutils question: is this a problem with the Distutils
code that needs fixing? I suspect not; if the tools make
it difficult to do stupid things like mix .py and .so
files, that's a good thing.
--
A.M. Kuchling http://starship.python.net/crew/amk/
The Kappamaki, a whaling research ship, was currently researching the
question: How many whales can you catch in one week?
-- Terry Pratchett & Neil Gaiman, _Good Omens_
Hi,
Being new to Distutils-SIG, I apologized if these topics are old
already. I have tried to run distutils 0.1.2 under JPython and windows
NT, this is what I came up with.
a) distutils attempt to install itself in sys.prefix. Unfortunately
JPython does not, as distributed, import site.py. So by default
installed modules can not be located. I guess this is a problem in
JPython and have reported it as:
http://www.python.org/jpython-bugs/incoming?id=229
b) sysconfig does not known about os.name == 'java'. Hacked below.
c) Wildcard import in the local name space does not work with JPython.
This is used in util.py. Even though this is a JPython bug
http://www.python.org/jpython-bugs/incoming?id=229
I think distutils could avoid the situation until JPython is fixed.
Hacked below.
d) JPython's 'os' modules does not contain utime or chmod. Hacked
below.
e) When building a "dist", the distutils.errors was missing in
dist.py. Hacked below.
f) The fields of IOError are different between JPython and CPython.
The field strerror exists, but it is None. This is a known difference.
Hacked below.
g) os.link is not defined. Neither is os.link when using CPython for
Windows NT. I exchanged os.link with util.copy_file, but that is
bogus. Unfortunately it is also included in the hack below.
h) spawn.py did not support os.name == 'java'. Hacked below.
i) The windows version of gzip that happened to be executed when
outputting gztar on my PC complains if the .tar.gz already exists.
Perhaps dist.py should remove any existing .tar.gz before trying to
make a new one. Not fixed.
Some general questions:
1) I am unsure, how os.name dependencies are best introduced. F.ex. in
the dist.make_zipfile(), I just added an if. It does not feel right.
2) Can (and should) distutil deal with the cr/lf issues of text files?
When building a distribution targeted to a specific platform, I think
distutils could help out with converting the obvious text-files.
In order to gain some momentum with my tests, I just hacked simple
solutions to my problems. The changes that I have made may break more
than they fixes, so beware.
The result can be seen here:
http://pip.dknet.dk/~bckfnn/Distutils-0.1.2-fbo.tar.gz
With this version, I could run the "dist" command and the "install"
command with normal module/*.py files.
regards,
finn
On Dec 20, 4:49pm, Guido van Rossum wrote:
>
> I claim that it *is* an issue of disk space. Having the installation
> of a particular package spread out over two places is inconvenient
> from a management point of view, and sharing one of those places
> between different installations (for different platforms) of the same
> package just makes it a lot worse.
>
What management are you talking about here ?? It seems to me that duplicate
copies of identical files (one copy per platform) is inconvenient (at least for
my perspective).
Moreover, why provide an prefix and an exec_prefix if we are going to put
everything into the same tree anyway ??
-Michel
--
-----------------------------------------------------------------------
>>>>>>>>>> AREA CODE CHANGE <<<<<<<<< we are now 858 !!!!!!!
Michel F. Sanner Ph.D. The Scripps Research Institute
Assistant Professor Department of Molecular Biology
10550 North Torrey Pines Road
Tel. (858) 784-2341 La Jolla, CA 92037
Fax. (858) 784-2860
sanner(a)scripps.edu http://www.scripps.edu/sanner
-----------------------------------------------------------------------