Lisandro Dalcin | 1 Jul 20:57
Picon
Gravatar

[Cython] Fwd: Search paths for definition files

---------- Forwarded message ----------
From: Lisandro Dalcin <dalcinl@...>
Date: Wed, Jul 1, 2009 at 3:56 PM
Subject: Re: [Cython] Search paths for definition files
To: Sebastien Binet <seb.binet@...>

On Wed, Jul 1, 2009 at 4:02 AM, Sebastien Binet<seb.binet@...> wrote:
>
>> Other way (not recommended, not portable for POSIX/Windows):
>> add a setup.cfg file alongside your setup.py file, and write inside it
>> (use ";" to separate on Windows):
>
> I am a bit surprised by this non-portable behaviour.
> is it a (stdlib) distutils overlook or a Cython.Distutils one ?
>

It is (stdlib) distutils behaviour, and Cython.Distutils just followed
the rules... Though I would not say that is an overlook, but a
feature...

>
> IIRC one can standardize on the POSIX syntax for path-separators and friends,
> and have the posixpath module do the conversion for us:
>
>>>> import posixpath
>>>> assert posixpath.pathsep == ':'
>>>> assert posixpath.sep == '/'
>
> so always using the POSIX syntax in xyz.cfg files would be portable.
>

But what would happen if you want to pass a Windows path that has a
":" inside the name? That would be a valid Windows path...

IMHO, in the particular case of setup.cfg files, they should be used
as a last resort for letting users to pass include/library paths or
even compiler flags... distutils should not second-guess users about
pathnames...

Moreover, any Python package that export some sort of API, let say C
header files or Cython pxd files, should do what numpy does:

$ python -c 'import numpy; print numpy.get_include()'
/usr/lib/python2.5/site-packages/numpy/core/include

I'm doing that for my own projects:

$ python -c 'import mpi4py; print mpi4py.get_include()'
/u/dalcinl/lib/python/mpi4py/include

$ python -c 'import petsc4py; print petsc4py.get_include()'
/u/dalcinl/lib/python/petsc4py/include

$ python -c 'import slepc4py; print slepc4py.get_include()'
/u/dalcinl/lib/python/slepc4py/include

Then, if you want to use C headers and Cython pxd's, you have a
programatic way to pass things in your setup.py files...

--
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594

--

-- 
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594

Gmane