As I've been going on about, I've got the changes made so that GNU automake supports Python. Because it is the FSF, I had to sign paperwork to disclaim copyright interest in our contributions before they would accept it. I mailed them in today. Thus, I've been touching up my changes before submitting them. I wanted to make sure I was using a sensible (or at least reasonable) set of names before I did that. Here are the names for which I am uncertain: o PYTHON_SITE This is the value sys.prefix + "/python" + sys.version[:3] + "/site-packages" It is the location where platform independent modules should be installed. It can be overridden on the configure line with the parameter --with-python-site=DIR o PYTHON_SITE_PACKAGE automake defines the variable PACKAGE, which I am taking also as the module name (nothing unusual about that, I hope). o PYTHON_SITE_EXEC This is the value sys.exec_prefix + "/python" + sys.version[:3] + "/site-packages" It can be overridded on the configure line with the parameter --with-python-site-exec=DIR. I played around with a few names. These seem to make sense to me (eg, PYTHON_SITE_EXEC is better than PYTHON_SITE_SHARED which I had). I cannot find if the standard Python libraries refer to these directories in some other fashion. The closest I can find is "site.py" which combines the first and last directory names directly into "sitedirs". *** question 1: Do these names make sense to others? o I added a new m4 macro for "aclocal" called "AM_CHECK_PYTHON". This is the command which goes in "configure.in" to tell autoconf that it needs to generate Python information. The macro takes one optional parameter. If the value is "classes" the Python files in the package are installed directly in PYTHON_SITE. If the value is "module" then they are installed into PYTHON_SITE_PACKAGE. The installation directory name is stored in the variable PYTHON_SITE_INSTALL. Eg: If you have the file "Vector.py" in the autoconf package "vecmath" with the PYTHON_SITE set to /usr/local/lib/python1.5/site-packages AM_CHECK_PYTHON(module) puts it in /usr/local/lib/python1.5/site-packages/vecmath/Vector.py AM_CHECK_PYTHON(classes) puts it in /usr/local/lib/python1.5/site-packages/Vector.py *** question 2: Should it be "classes" or something else? Since there's no existing python command-line program to compile a *single* python program (as compared to compileall which compiles, well, all :), I'm using the following in the Makefile (the value of PYTHON is the full location of the python executable and was found during the configure step): PYTHON_COMPILE_CMD = "-c 'import py_compile, sys; \ py_compile.compile(sys.argv[1])' PYTHON_OCOMPILE = $(PYTHON) $(PYTHON_COMPILE_CMD) PYTHON_OCOMPILE = $(PYTHON) -c $(PYTHON_COMPILE_CMD) .py.pyc: @echo "Compiling python file $< " @$(PYTHON_COMPILE) $< .py.pyo: @echo "Compiling python file $< (optimized)" @$(PYTHON_OCOMPILE) $< The idea is that I hope distutils will have a command-line way to do this, so I can replace all that with: .py.pyc: @$(PYTHON) $pythondir/distutils/compile.pr $< .py.pyo: @$(PYTHON) -O $pythondir/distutils/compile.py $< (I hide the actual compile with @ because otherwise you just see the full "import .... argv[1])" which is hard to read. By having a program to byte compile a file directly I can get rid of the noise.) *** question 3: Can distutils provide this sort of service? *** question 4: Anyone interested in getting the latest CVS distribution of automake (after I get the changes in) to play^U test things out? To help out, I'm also working on documentation so people can use it without reading the full automake documentation (which has a strong emphasis on building C programs). Not suprisingly, this email will be a hefty part of said documentation :) Andrew dalke@bioreason.com P.S. Here's the list of other definitions created by configure.in. I cannot see how there's any real problem with these names, but who knows .... PYTHON = full name of the python executable PYTHON_PREFIX = sys.prefix PYTHON_EXEC_PREFIX = sys.exec_prefix PYTHON_VERSION = sys.version PYTHON_PLATFORM = sys.platform pythondir = sys.prefix + "/python" + sys.version[:3]
Minor nit:
PYTHON_OCOMPILE = $(PYTHON) $(PYTHON_COMPILE_CMD) PYTHON_OCOMPILE = $(PYTHON) -c $(PYTHON_COMPILE_CMD)
should be
PYTHON_COMPILE = $(PYTHON) $(PYTHON_COMPILE_CMD) PYTHON_OCOMPILE = $(PYTHON) -c $(PYTHON_COMPILE_CMD)
The problem came from trying to reduce the number of deletions because the original text was escaped for use in perl double quotes; did a copy&paste w/o deleting everything. Andrew
Andrew Dalke wrote:
Minor nit:
PYTHON_OCOMPILE = $(PYTHON) $(PYTHON_COMPILE_CMD) PYTHON_OCOMPILE = $(PYTHON) -c $(PYTHON_COMPILE_CMD)
should be
PYTHON_COMPILE = $(PYTHON) $(PYTHON_COMPILE_CMD) PYTHON_OCOMPILE = $(PYTHON) -c $(PYTHON_COMPILE_CMD)
Shouldn't that be: PYTHON_OCOMPILE = $(PYTHON) -O $(PYTHON_COMPILE_CMD) ?? -g -- Greg Stein, http://www.lyra.org/
Shouldn't that be:
PYTHON_OCOMPILE = $(PYTHON) -O $(PYTHON_COMPILE_CMD)
An imprompt debugging hikau: Nits, nits, everywhere Infestation of my docs Time for some caffiene. (It really is the documentation. The code is: &define_variable('PYTHON_COMPILE', "\$(PYTHON) \$(PYTHON_COMPILE_CMD)"); &define_variable('PYTHON_OCOMPILE', "\$(PYTHON) -O \$(PYTHON_COMPILE_CMD)") ) Andrew dalke@bioreason.com
Quoth Andrew Dalke, on 07 April 1999:
Here are the names for which I am uncertain:
o PYTHON_SITE
This is the value sys.prefix + "/python" + sys.version[:3] + "/site-packages" [...] o PYTHON_SITE_EXEC
This is the value sys.exec_prefix + "/python" + sys.version[:3] + "/site-packages"
In the Distutils 'install' command (probably the part that's most analogous to what you're doing), I called these install_site_lib install_site_platlib I don't claim Automake and Distutils should use identical terms, but we should settle on one or the other of "exec" and "plat". I like exec because most (all?) of the Python stuff under exec_prefix isn't executable, but it is platform-specific (shared objects for the most part). Also, I like having "lib" in the name just to be explicit about what's getting installed there. (You might have a different installation directory for scripts.) So I think I would rename your PYTHON_SITE and PYTHON_SITE_EXEC to PYTHON_SITE_LIB and PYTHON_SITE_PLATLIB, give or take a few underscores. And I think you would rename my install_site_lib and install_site_platlib to install_site and install_site_exec. I notice that both schemes have no notion of /usr/local/lib/site-python -- this is a feature, right? (Ie. has that directory been replaced by /usr/local/lib/python1.5/site-packages? or does it still live on?)
o PYTHON_SITE_PACKAGE
automake defines the variable PACKAGE, which I am taking also as the module name (nothing unusual about that, I hope).
Umm, are you talking about "package" in the Python sense of a special directory full of modules, or in the general sense of a discrete chunk of software to distribute? (The latter is called a "distribution" in the Distutils lexicon, because of the conflict. This seems to be common usage in the Perl world as well, since there's also an existing meaning for "package" over there.) Anyways, whichever it is, it's not necessarily the same as the "module name". Both packages (Python meaning) and packages (general meaning) may have many modules! In Distutils, the Python package may be implied by the layout of files in the source distribution, or explicitly specified in setup.py. The name of the distribution must be specified in setup.py.
*** question 3: Can distutils provide this sort of service?
I assume you mean the one-line compilation business. I would argue against Distutils providing a one-line compiler for use in Makefiles: if you have Distutils, you don't *need* a Makefile! (At least not for your Python components.)
Here's the list of other definitions created by configure.in. I cannot see how there's any real problem with these names, but who knows .... [...] pythondir = sys.prefix + "/python" + sys.version[:3]
Again, my inclination would be to make explicit the fact that this is the library directory, eg. "pythonlibdir". Greg P.S. Regarding your snippet of Perl:
(It really is the documentation. The code is:
&define_variable('PYTHON_COMPILE', "\$(PYTHON) \$(PYTHON_COMPILE_CMD)"); &define_variable('PYTHON_OCOMPILE', "\$(PYTHON) -O \$(PYTHON_COMPILE_CMD)") )
You can singly-quote those strings, and thus not have to escape the dollar signs. I tend to reserve double-quotes for when I need them, ie. when I actually want to interpolate Perl variables into a string. -- Greg Ward - software developer gward@cnri.reston.va.us Corporation for National Research Initiatives 1895 Preston White Drive voice: +1-703-262-5376 Reston, Virginia, USA 20191-5434 fax: +1-703-620-0913
Thanks for the comments, Greg.
I like exec because most (all?) of the Python stuff under exec_prefix isn't executable, but it is platform-specific (shared objects for the most part).
Did you mean you "like" or "don't like"? I personally do not like it for that reason. Still, that's the way Python does it which is why I (eventually) chose that name.
install_site_lib install_site_platlib
I would shy away from using 'lib'. Automake expects 'lib_' as a special prefix (for files which are installed into the standard library directory). Also, 'LIB' is the prefix for the suffixes (like 'LIBS', 'LIBTOOL', 'LIBADD', ...) related to the construction of static and shared libraries. I worry that those two uses (variables for Python libraries and "real" libraries) should have names which are more distinct. This is important for us because we're going to use the same system for all of our code (C, C++, Python) so I want to make things pretty clear.
And I think you would rename my install_site_lib and install_site_platlib to install_site and install_site_exec.
Yep :) Though if it makes sense, I think people can live with the differences. However, do you distinguish between files which are placed under Python's lib/ directory and files which are placed, say, in /usr/local/lib/ ? I could make up an example, if you want, though since I cannot think of anything but contrived ones, I don't think it's an urgent need. Still, it may be useful that such an option is available.
I notice that both schemes have no notion of /usr/local/lib/site-python -- this is a feature, right?
Yes, based on Fred Drake's comment in this list that this directory is to be considered deprecated. Though for the automake mods it can be overridden with ./configure --with-python-site=/usr/local/lib/site-python This is important for us because we install all of our internally developed packages in /br/stable/lib/python1.5/ while externally developed ones are in the usual /usr/local/lib/python1.5/site-packages.
Umm, are you talking about "package" in the Python sense of a special directory full of modules, or in the general sense of a discrete chunk of software to distribute?
Indeed, I am confused by its definition in the Python world. However, in this case I use "PACKAGE" because that's the word specifically used by automake, and automake uses it in the general sense of the world. PYTHON_SITE_PACKAGE is the combination of (my) "PYTHON_SITE" directory and (automake's) "PACKAGE" name. Also, someone can override PYTHON_SITE_PACKAGE in the configure.in file to be anywhere they want it to be. My code just sets the default and uses that variable wherever it might be useful.
Anyways, whichever it is, it's not necessarily the same as the "module name". Both packages (Python meaning) and packages (general meaning) may have many modules!
Yes, just like in C you can have a single source distribution which includes several programs, each of which installs to different places. Automake supports this; you can override almost everything as long as you are cleaverer in how you use it. I think what I've added is able to support having a distribution with several Python module distributions. Though I haven't tested it, because we're operating under the "one distribution - one python package" development philosophy.
The name of the distribution must be specified in setup.py.
The automake way lets you define/override information in the configure.in file(s)
I assume you mean the one-line compilation business. I would argue against Distutils providing a one-line compiler for use in Makefiles: if you have Distutils, you don't *need* a Makefile! (At least not for your Python components.)
It was either that or petition for an option to 'compileall' to take a list of files to compile rather than a directory name. We (Bioreason) still need a Makefile since it drives things not part of the Makefile, like tagging everything in CVS with the current build tag, updating the build number, removing .pyo and .pyc files with "make clean", driving the building of the documentation from LaTex (or pod), running the regression tests, etc.
pythondir = sys.prefix + "/python" + sys.version[:3]
Again, my inclination would be to make explicit the fact that this is the library directory, eg. "pythonlibdir".
This variable name also is an automake-ism. The existance of a "pythondir" tells automake that targets like "python-clean" exist. It also says that "python_PYTHON" contains the list of Python files.
You can singly-quote those [Perl] strings
Yeah. There again I was sticking with the existing automake code, which uses double quotes for the equivalent section related to emacs lisp compilation. Perhaps it was a hobgoblin consistancy. Andrew dalke@bioreason.com
Greg said:
Umm, are you talking about "package" in the Python sense of a special directory full of modules, or in the general sense of a discrete chunk of software to distribute?
To which I responded:
Indeed, I am confused by its definition in the Python world.
Quick clarification question, then. What do you call a single file which is placed in python1.5/site-packages/something.py and referenced via 'import something' and what do you call a set of files contained in a directory named 'something_else', placed in python1.5/site-packages/something_else/* and contains the __init__.py to tell Python that this importable via import something_else Is something == 'module' and something_else == 'package' ? If so, I want to change my name for the first (currently is 'classes', for lack of a better word) and the second from 'module' to 'package'. Andrew dalke@bioreason.com
[I mis-speak myself]
I like exec because most (all?) of the Python stuff under exec_prefix isn't executable, but it is platform-specific (shared objects for the most part).
[Andrew catches me]
Did you mean you "like" or "don't like"? I personally do not like it for that reason. Still, that's the way Python does it which is why I (eventually) chose that name.
Ooops! I *don't like* using "execlib" for "platform-specific library directory". I now see that that usage descends from Autoconf's "exec prefix" notion, which is pretty well established by now. However, in switching from the Autoconf point-of-view ("let's build this Python thing, which is basically a C program with some ancillary files, some of which are platform-specific and some not") to the Distutils POV ("let's build this bundle of modules to add to the Python library; some of the files to install are pure Python modules, and some are platform-specific extension modules"), a change of terminology is in order. The convention in Python-land seems to be "plat" for "platform" (as opposed to "arch" for "architecture" -- six of one, half a dozen of the other!), so I went with "install_platlib" and "install_site_platlib" as the directories to which platform-specific files will be installed. (Most distributions will install to install_site*; only distributions that are part of the standard library will use the "install_*" directories. The idea here is that some distribution -- say, the Distutils itself -- will be part of the standard library, but might be released more frequently than Python itself.)
I would shy away from using 'lib'. Automake expects 'lib_' as a special prefix (for files which are installed into the standard library directory). Also, 'LIB' is the prefix for the suffixes (like 'LIBS', 'LIBTOOL', 'LIBADD', ...) related to the construction of static and shared libraries. I worry that those two uses (variables for Python libraries and "real" libraries) should have names which are more distinct.
This is important for us because we're going to use the same system for all of our code (C, C++, Python) so I want to make things pretty clear.
That makes sense for you in the Automake context. If Automake/Autoconf think that "lib" is a platform-specific C library (libfoo.a, libfoo.so), then it makes sense for you to stick to that narrow definition. However, we all know perfectly well that foo.py is a Python library (or part of one), and Python is just as good as C -- so why come up with some other word than library? So I think your scheme makes sense for Automake, but I would still consider changing "exec" to "plat" at some point if it makes sense and Automake doesn't whine. And I think my scheme makes sense for a Python-specific build/distribute/install mechanism, so I'm gonna stick with what I've got.
However, do you distinguish between files which are placed under Python's lib/ directory and files which are placed, say, in /usr/local/lib/ ? I could make up an example, if you want, though since I cannot think of anything but contrived ones, I don't think it's an urgent need. Still, it may be useful that such an option is available.
That's quite possible for a Python application that has configuration files and such. Note that the Distutils "prefix" is still (eg.) /usr/local -- it's just Python's prefix. So there's no problem in a particular application (or even module distribution, although it's probably bad practice for a programming library to have config files) using that to put its stuff in /usr/local/lib. If there's a demand for it, Distutils could probably have direct support for installing "ancillary files", but I don't see that being an issue until we truly support Python *applications* (as opposed to libraries). Greg -- Greg Ward - software developer gward@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
Greg Ward writes:
particular application (or even module distribution, although it's probably bad practice for a programming library to have config files) using that to put its stuff in /usr/local/lib. If there's a demand for it, Distutils could probably have direct support for installing "ancillary files", but I don't see that being an issue until we truly support Python *applications* (as opposed to libraries).
There are too many examples of libraries needing supplemental data to ignore this. A common example would be a library that provides character set re-encoding; the code could be fairly simple, and specific encodings could be loaded on demand from tables associated with a library. Similar considerations may be applicable to many other functions; the tables may contain font information for a layout engine, etc. -Fred -- Fred L. Drake, Jr. <fdrake@acm.org> Corporation for National Research Initiatives
Quoth Andrew Dalke, on 07 April 1999:
Quick clarification question, then.
Quick answer: while still_confused: read_page ('http://www.python.org/doc/essays/packages.html') Longer answer:
What do you call a single file which is placed in python1.5/site-packages/something.py
and referenced via 'import something'
I call that a module. But that's not the only kind of module!
and what do you call a set of files contained in a directory named 'something_else', placed in
python1.5/site-packages/something_else/*
and contains the __init__.py to tell Python that this importable via
import something_else
I call that a package. But remember, a package is also a module!
Is something == 'module' and something_else == 'package' ?
So yes, this is correct.
If so, I want to change my name for the first (currently is 'classes', for lack of a better word) and the second from 'module' to 'package'.
Calling a module "classes" is ugly and doesn't tell the whole story (a module can also provide functions and global variables!). Calling a package a module is *very* confusing! I definitely think you should make this change. Here's my take on packages and modules in Python: A Python source file ending in ".py" and living in a directory on sys.path is a "module". But this isn't the only kind of module. A directory living on sys.path containing a file called "__init__.py" is a special kind of module called a "package". A platform-specific dynamically loaded file on sys.path might also be a module, usually called an "extension module". In general, modules can provide any kind of Python object, where something "provided by" a module may be directly pulled into another namespace using "from module import name", or accessed via the module as "module.name". Usually, packages only provide other modules, but they can provide classes, functions, variables, etc. Usually, "pure Python" modules provide classes, functions, and variables, but they can provide other modules (eg. 'os' provides a module called 'path'). And usually, extension modules only provide functions and variables -- my understanding is that they cannot provided classes, and I have no idea what the other hard-and-fast limitations on extension modules are (I really have to play around more there!). Assuming all that is correct, I hope that clears things up! (And if anything up there is *not* correct, somebody tell me soon before I hard-code my misunderstandings in the Distutils...) Greg -- Greg Ward - software developer gward@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
Greg said:
So I think your scheme makes sense for Automake, but I would still consider changing "exec" to "plat" at some point if it makes sense and Automake doesn't whine. And I think my scheme makes sense for a Python-specific build/distribute/install mechanism, so I'm gonna stick with what I've got.
The automake people suggested an even better alternative; don't provide those options at all from the configure script (which gets rid of the --with-python-site-exec). And, the "plat" extension means nothing (that I know of) in automake, so I can change that. That nomenclature does make more sense.
Is something == 'module' and something_else == 'package' ?
So yes, this is correct.
Also now on my change list. (I've got to wait, I assume, until the automake people get told by the FSF that I've sent in the right copyright disclaimer papers; though it's been over a week since I mailed them.)
Assuming all that is correct, I hope that clears things up! (And if anything up there is *not* correct, somebody tell me soon before I hard-code my misunderstandings in the Distutils...)
Sounds good to me. And besides, even if it is wrong, by documenting and implement it one way, sometimes things become right even if originally wrong! Andrew dalke@bioreason.com
participants (4)
-
Andrew Dalke
-
Fred L. Drake
-
Greg Stein
-
Greg Ward