Question

I'm writing a setup.py file for a Python project so that I can distribute it. The aim is to eventually create a .egg file, but I'm trying to get it to work first with distutils and a regular .zip.

This is an eclipse pydev project and my file structure is something like this:

ProjectName
   src
      somePackage
         module1.py
         module2.py
         ...
   config
      propsFile1.ini
      propsFile2.ini
      propsFile3.ini
   setup.py

Here's my setup.py code so far:

from distutils.core import setup

setup(name='ProjectName', 
      version='1.0', 
      packages=['somePackage'],
      data_files = [('config', ['..\config\propsFile1.ini', 
                                '..\config\propsFile2.ini', 
                                '..\config\propsFile3.ini'])]
      )

When I run this (with sdist as a command line parameter), a .zip file gets generated with all the python files - but the config files are not included. I thought that this code:

 data_files = [('config', ['..\config\propsFile1.ini', 
                                    '..\config\propsFile2.ini', 
                                    '..\config\propsFile3.ini'])]

indicates that those 3 specified config files should be copied to a "config" directory in the zip distribution. Why is this code not accomplishing anything? What am I doing wrong?

(I have also tried playing around with the paths of the config files... But nothing seems to help. Would Python throw an error or warning if the path was incorrect / file was not found?)

Was it helpful?

Solution 2

I finally got this to work by moving the entire config directory into the src folder. This must mean that my paths are off... but as I couldn't seem to find a way to back up a directory ("..\" didn't make a difference), I'm going to stick with this solution for now.

OTHER TIPS

Create a MANIFEST.in file like this:

include config\*

(EDIT) Look here for more information: http://docs.python.org/distutils/sourcedist.html#specifying-the-files-to-distribute

I guess you have to escape the backslashes in the filenames; e.g., instead of '..\config\whatever', write '..\\config\\whatever', or use the raw string syntax: r'..\config\whatever'.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top