Re: [Distutils] unicode bug in distutils

2007-02-24 Thread Paul Pogonyshev
Tarek Ziadé wrote:
> I have created a setup.py file for  distirbution and I bumped into
> a small bug when i tried to set my name in the contact field (Tarek Ziadé)
> 
> Using string (utf8 file):
> 
> setup(
>   maintainer="Tarek Ziadé"
> )

How about maintainer = u"Tarek Ziadé"?

Paul
___
Distutils-SIG maillist  -  Distutils-SIG@python.org
http://mail.python.org/mailman/listinfo/distutils-sig


Re: [Distutils] c extensions: how to rebuild and test quickly

2007-02-15 Thread Paul Pogonyshev
Thomas Heller wrote:
> Paul Pogonyshev schrieb:
> > Thomas Heller wrote:
> >> Paul Pogonyshev schrieb:
> >> > Hi,
> >> > 
> >> > Distutils create dynamic library for a C extension in `build/...'
> >> > directory.  This makes it impossible to run program without
> >> > installing it, which I find very important for developing.  Ideally,
> >> > process should look like this:
> >> > [...]
> >>
> >> What I do is to create a loader module named .py that  
> >> 'replaces' itself with the real extension, loading it via imp
> >> from the platform specific build directory that distutils creates.
> > 
> > This looks clever.  However, how do you make sure the module doesn't
> > get itself installed?  I.e. I'd not want this hack make it into the
> > installed copy, while it is perfectly OK for quick in-place builds
> > and tests.
> 
> I'm not sure this trick works for every case, but it works for the ctypes
> separate distribution.
> 
> The point is that ctypes is a package, and the ctypes package uses the
> _ctypes.pyd/so and _ctypes_test.pyd/.so extension modules.  The extension
> modules are not inside the package, they are top-level modules.  Here
> is the source layout in the SVN repository:
> 
> ./setup.py
> ./_ctypes.py# the loader module
> ./_ctypes_test.py   # the other loader module
> ./ctypes/__init__.py# the ctypes package
> ./ctypes/...# other parts of the package
> 
> Now, when you call 'setup.py build_ext', the extension modules
> are built and put into this directory:
> 
> ./build/lib.win32-2.4/_ctypes.pyd
> ./build/lib.win32-2.4/_ctypes_test.pyd
> 
> The setup script contains these lines:
> 
> setup(...,
>   extensions = [Extension(_ctypes, ...), Extension(_ctypes_test, ...)],
>   packages = ["ctypes", "ctypes.test", "ctypes.macholib"],
>   )
> 
> so the loader script will not be included in the distributions.
> 
> I am not sure if this recipe can be extended to support extensions
> that are inside packages; but for now I find it nicer than the setuptools
> 'develop' approach.
> 
> Thomas

Hm, looks too complicated.  Thanks anyway.

I ended up with custom build_ext command:

from distutils.command.build_ext import build_ext as _build_ext

class build_ext (_build_ext):

def build_extension (self, extension):
_build_ext.build_extension (self, extension)

if not self.inplace and os.name == 'posix':
filename = self.get_ext_filename (extension.name)

try:
os.remove (filename)
except:
# Ignore all errors.
pass

try:
os.symlink (os.path.join (os.pardir, self.build_lib, filename),
os.path.join ('notify', os.path.basename 
(filename)))
except:
# Ignore all errors.
pass

Maybe I should copy on non-posix systems.

Paul
___
Distutils-SIG maillist  -  Distutils-SIG@python.org
http://mail.python.org/mailman/listinfo/distutils-sig


Re: [Distutils] c extensions: how to rebuild and test quickly

2007-02-15 Thread Paul Pogonyshev
John Machin wrote:
> On 15/02/2007 10:30 AM, Paul Pogonyshev wrote:
> > Hi,
> > 
> > Distutils create dynamic library for a C extension in `build/...'
> > directory.  This makes it impossible to run program without
> > installing it,
> 
> Could you not put the build directory on your PYTHONPATH?
> Possible, if inconvenient.

Not really, because I want users (package is a library) to be able to
run unit tests.  They should be able to do this without any extra steps.

> > [...]
> Is
> setup.py build_ext --inplace
> what you are looking for?

No, for the same reason.

Paul
___
Distutils-SIG maillist  -  Distutils-SIG@python.org
http://mail.python.org/mailman/listinfo/distutils-sig


Re: [Distutils] c extensions: how to rebuild and test quickly

2007-02-15 Thread Paul Pogonyshev
Thomas Heller wrote:
> Paul Pogonyshev schrieb:
> > Hi,
> > 
> > Distutils create dynamic library for a C extension in `build/...'
> > directory.  This makes it impossible to run program without
> > installing it, which I find very important for developing.  Ideally,
> > process should look like this:
> > [...]
>
> What I do is to create a loader module named .py that  
> 'replaces' itself with the real extension, loading it via imp
> from the platform specific build directory that distutils creates.

This looks clever.  However, how do you make sure the module doesn't
get itself installed?  I.e. I'd not want this hack make it into the
installed copy, while it is perfectly OK for quick in-place builds
and tests.

Paul
___
Distutils-SIG maillist  -  Distutils-SIG@python.org
http://mail.python.org/mailman/listinfo/distutils-sig


Re: [Distutils] c extensions: how to rebuild and test quickly

2007-02-15 Thread Paul Pogonyshev
Phillip J. Eby wrote:
> At 01:30 AM 2/15/2007 +0200, Paul Pogonyshev wrote:
> >Hi,
> >
> >Distutils create dynamic library for a C extension in `build/...'
> >directory.  This makes it impossible to run program without
> >installing it, which I find very important for developing.  Ideally,
> >process should look like this:
> [...]
> 
> As someone else has mentioned, build_ext --inplace will do the trick.
> 
> However, I find it a bit awkward to use, as you have to manually rebuild 
> when testing  different Python versions (and/or platforms: I sometimes use 
> both Cygwin and Windows Python, for example).
> 
> So, setuptools' "test" and "develop" commands (as well as its own version 
> of "build_ext --inplace") do the build in the build/ subdirectory, but then 
> *copy* the files to the source directory.  Because each build directory has 
> its own platform-specific files, this automatically uses the right files 
> for the Python version you're running the "test" command with.
> 
> It's still not perfect, but it can be a nice improvement over plain 
> "build_ext -i" usage.

Yeah, I will do that if there is no better way.

Paul
___
Distutils-SIG maillist  -  Distutils-SIG@python.org
http://mail.python.org/mailman/listinfo/distutils-sig


[Distutils] c extensions: how to rebuild and test quickly

2007-02-14 Thread Paul Pogonyshev
Hi,

Distutils create dynamic library for a C extension in `build/...'
directory.  This makes it impossible to run program without
installing it, which I find very important for developing.  Ideally,
process should look like this:

edit Python code -> test (uninstalled);

or

edit C code -> ./setup.by build -> test (uninstalled).

This is all possible if I create a symbolic link from build
directory to the sources.  Then extension module can be imported
normally and everything is like it was with all code limited to
Python.

Is it possible in some standard (and preferably portable) way with
distutils?  Is it already done?

Paul
___
Distutils-SIG maillist  -  Distutils-SIG@python.org
http://mail.python.org/mailman/listinfo/distutils-sig