package_data issue (chopping off characters)

I have a strange problem with distutils and package_data. I'm using python 2.3.3, with the setuptools from CVS (so that I can use package_data). My setup.py contains: ------------------------------------------------------------------------ #!/usr/bin/env python # Veusz distutils setup script # $Id: setup.py,v 1.2 2005/04/13 17:03:55 jeremysanders Exp $ import glob from setuptools import setup version = open('VERSION').read().strip() descr = '''Veusz is a scientific plotting package, designed to create publication-ready Postscript output. It features GUI, command-line, and scripting interfaces. Graphs are constructed from "widgets", allowing complex layouts to be designed. Veusz supports plotting functions, data with errors, keys, labels, stacked plots, multiple plots, and fitting data.''' setup(name = 'veusz', version = version, description = 'A scientific plotting package', long_description = descr, author = 'Jeremy Sanders', author_email = 'jeremy@jeremysanders.net', url = 'http://home.gna.org/veusz/', license = 'GPL', classifiers = ['Programming Language :: Python', 'Development Status :: 4 - Beta', 'Environment :: X11 Applications :: Qt', 'Intended Audiance :: Advanced End Users', 'Licence :: OSI Approved :: ' 'GNU General Public License (GPL)', 'Topic :: Scientific/Engineering :: Visualization'], package_dir = { 'veusz': '', 'veusz.dialogs': 'dialogs', 'veusz.document': 'document', 'veusz.setting': 'setting', 'veusz.utils': 'utils', 'veusz.widgets': 'widgets', 'veusz.windows': 'windows' }, package_data = { 'veusz.windows': ['icons/*.png'], 'veusz': ['images/*.png'] }, packages = ['veusz', 'veusz.dialogs', 'veusz.document', 'veusz.setting', 'veusz.utils', 'veusz.widgets', 'veusz.windows'] ) ------------------------------------------------------------ When it is run with python setup.py bdist_rpm I get, running bdist running bdist_dumb running build running build_py creating build/lib/veusz/mages error: can't copy 'mages/logo.png': doesn't exist or not a regular file (I have tried removing the build and dist directories). Somehow the first character of 'images' has been chopped off. If I remove the package_data command, everything works (except the data don't get packaged). Any ideas??? Thanks Jeremy -- Jeremy Sanders <jeremy@jeremysanders.net> http://www.jeremysanders.net/ Cambridge, UK Public Key Server PGP Key ID: E1AAE053

Jeremy Sanders wrote:
When it is run with python setup.py bdist_rpm
I get,
running bdist running bdist_dumb running build running build_py creating build/lib/veusz/mages error: can't copy 'mages/logo.png': doesn't exist or not a regular file
Coincidentally I have seen the same symptom last night, though the context was different: The bdist_rpm command calls the 'install' commands (with all its subcommands) to install everything under a predefined root directory. It tells the 'install' command about that root path and the install command modifies all its paths accordingly (search for 'change_root' in distutils/commands/install.py). However, I made a small error in my 'install_clib' command's 'get_outputs()' method in that it didn't consider the modified paths but the original ones. bdist_rpm then cut off what it thought was the root directory, but due to the error the resulting paths were incorrect (i.e. appeared 'chopped off' as in your case). You didn't mention any custom commands, and so I'm not sure that's really related to your error. It may give some hints, though, as to where to look further. HTH, Stefan

On Wed, 13 Apr 2005, Stefan Seefeld wrote:
Coincidentally I have seen the same symptom last night, though the context was different:
The bdist_rpm command calls the 'install' commands (with all its subcommands) to install everything under a predefined root directory. It tells the 'install' command about that root path and the install command modifies all its paths accordingly (search for 'change_root' in distutils/commands/install.py).
However, I made a small error in my 'install_clib' command's 'get_outputs()' method in that it didn't consider the modified paths but the original ones. bdist_rpm then cut off what it thought was the root directory, but due to the error the resulting paths were incorrect (i.e. appeared 'chopped off' as in your case).
You didn't mention any custom commands, and so I'm not sure that's really related to your error. It may give some hints, though, as to where to look further.
No, I haven't used any custom commands. If anyone would like to look at the problem, download http://download.gna.org/veusz/testing/veusz-pre0.5.tar.gz unpack, cd to veusz, and run python setup.py bdist It then gives an error: copying windows/consolewindow.py -> build/lib/veusz/windows copying windows/__init__.py -> build/lib/veusz/windows copying windows/mainwindow.py -> build/lib/veusz/windows copying windows/treeeditwindow.py -> build/lib/veusz/windows copying windows/simplewindow.py -> build/lib/veusz/windows copying windows/action.py -> build/lib/veusz/windows copying windows/plotwindow.py -> build/lib/veusz/windows error: can't copy 'ERSION': doesn't exist or not a regular file where the setup.py file refers to VERSION, not ERSION. Thanks Jeremy -- Jeremy Sanders <jeremy@jeremysanders.net> http://www.jeremysanders.net/ Cambridge, UK Public Key Server PGP Key ID: E1AAE053

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Jeremy, On Thu, Apr 14, 2005 at 10:58:49AM +0100, Jeremy Sanders wrote:
http://download.gna.org/veusz/testing/veusz-pre0.5.tar.gz unpack, cd to veusz, and run python setup.py bdist [...] error: can't copy 'ERSION': doesn't exist or not a regular file
You are not using an official distutils build, but an internal (modified?) version "setuptools". Please use "from distutils.core import setup" instead of "from setuptools import setup" Then it works. Regards, Bastian - -- ,''`. Bastian Kleineidam : :' : GnuPG Schlüssel `. `' gpg --keyserver wwwkeys.pgp.net --recv-keys 32EC6F3E `- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCXmBOeBwlBDLsbz4RArrAAJ9rgslNIXXjcMsR8RrFL8f0xJXfpgCfZnRd kCjcr9sG6XNEE4wR9hOibtQ= =axu9 -----END PGP SIGNATURE-----

On Wed, 13 Apr 2005, Stefan Seefeld wrote:
Jeremy Sanders wrote:
When it is run with python setup.py bdist_rpm
I get,
running bdist running bdist_dumb running build running build_py creating build/lib/veusz/mages error: can't copy 'mages/logo.png': doesn't exist or not a regular file
Apologies to Bastian Kleineidam, I'm not on the list so this isn't a direct reply to your email! I'm using the cvs version "setuptools", as it was suggested in an email on this list: http://mail.python.org/pipermail/distutils-sig/2004-October/004214.html as I wanted my setup.py to work under Python-2.3. Are the distutils from Python-2.4 likely to work if I transplant it into my own program?? Thanks Jeremy -- Jeremy Sanders <jeremy@jeremysanders.net> http://www.jeremysanders.net/ Cambridge, UK Public Key Server PGP Key ID: E1AAE053

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, On Thu, Apr 14, 2005 at 02:37:49PM +0100, Jeremy Sanders wrote:
I'm using the cvs version "setuptools", as it was suggested in an email on this list:
http://mail.python.org/pipermail/distutils-sig/2004-October/004214.html
as I wanted my setup.py to work under Python-2.3. Ah, my fault. I tested only with 2.3. With 2.4 I can reproduce the error. I attached a quick fix that you can try out. If it works for you, I will submit it to the patch manager.
Are the distutils from Python-2.4 likely to work if I transplant it into my own program?? The 2.4 distutils should also work under Python 2.3.
Regards, Bastian PS: There are still some 'distutils' imports in your setuptools/ directory. You should change them also to 'setuptools' just to be sure that only those methods in setuptools are used. - -- ,''`. Bastian Kleineidam : :' : GnuPG Schlüssel `. `' gpg --keyserver wwwkeys.pgp.net --recv-keys 32EC6F3E `- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCXn8yeBwlBDLsbz4RAurXAJ0QqBSV2S/M3SJPyVpVm9r0EXcMtwCdEtgL 4XzoWZrCcC5ysu7D97pF5UY= =qj+h -----END PGP SIGNATURE-----

Sorry for not replying properly in the thread, but I think I've found the bug. I downloaded python from cvs and took the latest distutils from there. In command/build_py.py there is a function: def get_data_files (self): """Generate list of '(package,src_dir,build_dir,filenames)' tuples""" data = [] if not self.packages: return data for package in self.packages: # Locate package source directory src_dir = self.get_package_dir(package) # Compute package build directory build_dir = os.path.join(*([self.build_lib] + package.split('.'))) # Length of path to strip from found files plen = len(src_dir)+1 # Strip directory from globbed filenames filenames = [ file[plen:] for file in self.find_data_files(package, src_dir) ] data.append((package, src_dir, build_dir, filenames)) return data Note that the filename is chopped using file[plen:] above. If src_dir=="", as I have in my setup.py file (which is a perfectly acceptable package directory), then plen == 1, and so the first character gets chopped from each of the file names. self.find_data_files returns the correct files, but the first character gets chopped from them. Jeremy -- Jeremy Sanders <jeremy@jeremysanders.net> http://www.jeremysanders.net/ Cambridge, UK Public Key Server PGP Key ID: E1AAE053
participants (4)
-
Bastian Kleineidam
-
Bastian Kleineidam
-
Jeremy Sanders
-
Stefan Seefeld