[Distutils] Re: Mixing pure python and extension module and multi platform

Berthold Höllmann hoel@gl-group.com
Wed Mar 19 05:46:35 2003


"M.-A. Lemburg" <mal@lemburg.com> writes:

> Berthold Höllmann wrote:
> > "Juergen Hermann" <jh@web.de> writes:
> >
> >>On 18 Mar 2003 16:15:18 +0100, Berthold Höllmann wrote:
> >>
> >>>My problem now is that setup on a mixed module installes everything
> >>>into the system dependent branch of the install directories.
> >>
> >>Errmmmm, setup.py install --help
> >>
> >>Options for 'install' command:
> >>...
> >>  --install-base      base installation directory (instead of =
--prefix or --
> >>                      home)
> >>  --install-platbase  base installation directory for =
platform-specific files
> >>                      (instead of --exec-prefix or --home)
> >>  --install-purelib   installation directory for pure Python module
> >>                      distributions
> >>  --install-platlib   installation directory for non-pure module =
distributions
> > Errmmm, what I am looking for is a way to have, installing mixed
> > modules, the extension modules installed in the --install-platlib =
tree
> > and the pure python modules installed in the --install-purelib
> > path. Now when you install mixed moudules everything gets installed
> > into the --install-platlib tree, even the pure python modules.
> 
> If you are using packages, that's the only way it works (you can't
> have two parallel package structures with the same base name in
> Python). If you are distributing the files as top-level files,
> then this looks like a bug.

So it is, I guess a bug. I build a small example:

>cat spam.c 
#include <Python.h>

static PyObject *
spam_system(self, args)
    PyObject *self;
    PyObject *args;
{
    char *command;
    int sts;

    if (!PyArg_ParseTuple(args, "s", &command))
        return NULL;
    sts = system(command);
    return Py_BuildValue("i", sts);
}
static PyObject *SpamError;

static PyMethodDef SpamMethods[] = {
    {"system",  spam_system, METH_VARARGS,
     "Execute a shell command."},
    {NULL, NULL, 0, NULL}        /* Sentinel */
};

void
initspam(void)
{
    PyObject *m, *d;

    m = Py_InitModule("spam", SpamMethods);
    d = PyModule_GetDict(m);
    SpamError = PyErr_NewException("spam.error", NULL, NULL);
    PyDict_SetItemString(d, "error", SpamError);
}
>cat pork.py 
import spam as _spam

def spam():
    return _spam.system("ls -l")
>cat setup.py 
from distutils.core import setup,Extension

setup (name         = "pork.spam",
       version      = "0.0.0",
       description  = "just a test",
       author       = 'Berthold Höllmann',
       author_email = "hoel@GL-Group.com",
       ext_modules  = [Extension('spam', ['spam.c'])],
       package_dir = {'pork': '.'},
       py_modules   = ['pork.pork'],
)
>touch __init__.py
>python setup.py build
...
>python setup.py -n install
Adding parser accelerators ...
Done.
running install
running build
running build_py
not copying ./__init__.py (output up-to-date)
not copying ./pork.py (output up-to-date)
running build_ext
skipping 'spam' extension (up-to-date)
running install_lib
copying build/lib.linux-i686-2.2/pork/pork.py -> /usr/local/fitools/sandbox/linux/lib/python2.2/site-packages/pork
copying build/lib.linux-i686-2.2/pork/__init__.py -> /usr/local/fitools/sandbox/linux/lib/python2.2/site-packages/pork
copying build/lib.linux-i686-2.2/spam.so -> /usr/local/fitools/sandbox/linux/lib/python2.2/site-packages
error: file '/usr/local/fitools/sandbox/linux/lib/python2.2/site-packages/pork/pork.py' does not exist
[16957 refs]
>python -c "import distutils.sysconfig as d;print =
d.get_python_lib();print d.get_python_lib(True)"
Adding parser accelerators ...
Done.
/usr/local/fitools/sandbox/lib/python2.2/site-packages
/usr/local/fitools/sandbox/linux/lib/python2.2/site-packages
[5792 refs]

In my understanding pork.py sould have gone to
/usr/local/fitools/sandbox/lib/python2.2/site-packages/pork instead of
/usr/local/fitools/sandbox/linux/lib/python2.2/site-packages/pork
(same of course for __init__.py).

Regards
Berthold
-- 
Dipl.-Ing. Berthold Höllmann   __   Address:
hoel@GL-Group.com           G /  \ L Germanischer Lloyd
phone: +49-40-36149-7374    -+----+- Vorsetzen 32/35    P.O.Box 111606
fax  : +49-40-36149-7320      \__/   D-20459 Hamburg    D-20416 Hamburg
 
 
 
 
****************************************************
 
 
Beachten Sie:  Wir moechten Sie informieren, dass die E-Mail-Adresse des Germanischen Lloyd sowie unsere Web-Adresse mit Wirkung vom 1. Maerz 2003 auf den Namen gl-group.com umgestellt wurde.
 
 
Dies bedeutet, dass die bisherige Adresse Kurzzeichen@germanlloyd.org durch die neue Adresse Kurzzeichen@gl-group.com ersetzt wird. Die Homepage des GL ist kuenftig ueber die Adresse 'http://www.gl-group.com' aufrufbar. Die bisher verwendeten Adressen bleiben für eine Uebergangsfrist erreichbar.
 
 
**************************************************** 
 
Please notice: We would like to inform you that the e-mail address of Germanischer Lloyd as well as our internet address had been changed to  gl-group.com with effect from 1st March 2003.
 
 
This means that the previous address shortmark@germanlloyd.org will be replaced by shortmark@gl-group.com. From now on the GL homepage can be accessed at the address 'http://www.gl-group.com'. The old addresses remain valid for a transitional period.
 

 
 
****************************************************
 
 
 
 
This e-mail contains confidential information for the exclusive attention of the intended addressee. Any access of third parties to this e-mail is unauthorised. Any use of this e-mail by unintended recipients such as copying, distribution, disclosure etc. is prohibited and may be unlawful. When addressed to our clients the content of this e-mail is subject to the General Terms and Conditions of GL's Group of Companies applicable at the date of this e-mail.  
 
GL's Group of Companies does not warrant and/or guarantee that this message at the moment of receipt is authentic, correct and its communication free of errors, interruption etc.