1

Situation

I createt my setup.py file. Most of it works out of the box but I'm having some trouble by shipping some additional files with it. But I noticed that the following files are not included to my tar.gz when running

python setup.py sdist
  • doc files
  • virtual files
  • service script

The location of the doc files can be os specific. But I would like to see the service script in /etc/init.d/ and a sample configuration (stored in my doc files) in /etc/package. The virtual files can be stored in my package folder.

Question

How can I ship those files in my tar.gz?

Source

setup.py

from setuptools import setup                                                    

setup(                                                                          
    name="package",                                                             
    version="0.1",                                                              
    description="package Daemon",                                               
    author="me",                                                   
    author_email="my-email",                               
    url="http://my-url",                                             
    package_dir={"package": "src",                                              
                 "package-utils": "src/utils"},                                 
    packages=[                                                                  
        "package",                                                              
        "package.modules",                                                      
        "package.modules.core",                                                 
        "package.modules.config",                                               
        "package.modules.commands",                                             
        "package.modules.dblog",                                                
        "package.utils",                                                        
        "twisted.plugins",                                                      
    ],                       

    package_data={                                                              
        "package": [                                                            
            "src/virtual/cmd/bin/*",                                           
            "src/virtual/cmd/sbin/*",                                          
            "src/virtual/usr/bin/*",                                           
            "src/virtual/files/etc/*",                                         
            "src/virtual/proc/*",                                              
            "src/virtual/*.db"]},                                              

    data_files=[                                                                
        ("/usr/local/doc/package", ["doc/COPYRIGHT",                            
                                    "doc/LICENCE",                              
                                    "doc/README",                               
                                    "doc/sql/mysql.sql",                        
                                    "doc/package.cfg.sample"]),                 
        ("/etc/init.d/", ["src/package"]),                                      
        ("/etc/package", ["doc/package.cfg.sample"])                            
    ],                                                                          

    entry_points={                                                              
        'console_scripts': [                                                    
        ['package-setup = package.utils.setup:main'],                                                      
        ],                                                                      
    },                                                                          
)                                                                               

try:                                                                            
    from twisted.plugin import IPlugin, getPlugins                              
except ImportError:                                                             
    pass                                                                        
else:                                                                           
    list(getPlugins(IPlugin))

tree -d

.
├── doc
│   └── sql
├── src
│   ├── virtual
│   │   ├── cmd
│   │   │   ├── bin
│   │   │   ├── sbin
│   │   │   └── usr
│   │   │       └── bin
│   │   └── files
│   │       ├── etc
│   │       └── proc
│   ├── modules
│   │   ├── commands
│   │   ├── config
│   │   ├── core
│   │   └── dblog
│   └── utils
└── twisted
    └── plugins
Denny Crane
  • 637
  • 6
  • 19
  • You'll have to create a `MANIFEST` file. See [Specifying the files to distribute](http://docs.python.org/2/distutils/sourcedist.html#specifying-the-files-to-distribute) – Lukas Graf Aug 09 '13 at 10:22

1 Answers1

3

You'll have to use a MANIFEST.in file to list data files that you want included in a source distribution. package_data is only consulted for binary distributions (a great shortcoming).

See The MANIFEST.in template in the distutils documentation.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • Ah, I completely misunderstood the use if MANIFEST. Bulding a a tar.gz works now. BUt when trying to build an rpm it fails cause it can't find my doc folder? – Denny Crane Aug 09 '13 at 11:19