6

I've created package with distutils including package data. When i look in tar.gz of my package I see expected files, BUT after package installation (by pip or by 'python setup.py install') there is no any package data. Only python scripts included. My setup.py is:

# py3.3
#from packaging.core import setup
# py3.2
from distutils.core import setup

setup(
    name = 'mypkg',
    version = '0.7dev',
    author = 'Projekt Alef',
    author_email = 'tymoteusz.jankowski@gmail.com',
    packages = [
        'my_pkg',
        'my_pkg/tests',
        'my_pkg/plugins',
    ],
    #scritps=['bin/setup.sh',],
)
Fred Foo
  • 355,277
  • 75
  • 744
  • 836
xliiv
  • 5,399
  • 5
  • 29
  • 35

1 Answers1

6

Package data to be installed should be included as a package_data={} dictionary passed to the setup() function. Each dictionary gives the module (package) to be installed and a list of patterns to find data files to be installed from/with it, such as:

package_data = {
    'exceptional_middleware': [ 'templates/http_responses/*.html' ],
}

Additionally, you may prefer not to install your tests (just drop pkg/tests from the packages list).

James Aylett
  • 3,332
  • 19
  • 20
  • What about MANIFEST.in? I thought the MANIFEST.in is enough. All the more desired 'package data' files are included in my 'python setup.py sdist' output. The problem is that the package (with all files i want) after installation lost 'package data' files. O_o – xliiv Mar 11 '12 at 12:42
  • 1
    Having something in the sdist means it'll be distributed to anyone who wants to install it, *not* that it'll get installed. I can't remember offhand the details of MANIFEST.in vs package_data, and the python doc site is down right now. Looking at an example I have here, it's in both, which seems ridiculous but apparently works. – James Aylett Mar 11 '12 at 12:44
  • You're 100% right. Manifest.in is NOT enough.. . Placing package_data var in setup function is mandatory to achieve that. O_o Thanks :) – xliiv Mar 12 '12 at 08:22
  • It depends on your Python version. In 2.7, distutils was fixed so that files included in package_data don’t need to be added to MANIFEST.in. – merwok Mar 12 '12 at 17:23