2

I have a confusing issue with python packaging

I have a setup.py that looks like this:

import os

try:
    from setuptools import setup
except ImportError:
    from ez_setup import use_setuptools
    use_setuptools()
    from setuptools import setup

config = {
    "name": "mypackage",
    "version": "3.0.15",
    "include_package_data": True,
    "scripts": ["something.py"],
    "entry_points": {},
    "zip_safe": False,
    }

setup(**config)

and a MANIFEST.in that looks like:

recursive-include mypackage *.*
recursive-exclude mypackage *.pyc .DS_Store

If I do python setup.py sdist a tar.gz file is written which contains all the right files

If I do python setup.py bdist_egg and then extract the contents of the egg using Stuffit Expander... I see a scripts/something.py file but none of the mypackage source files.

However in the extracted egg SOURCES.txt the mypackage files are listed, so it seems like the minifest has been parsed, it just hasn't put them into the egg.

What am I misunderstanding/doing wrong?

Anentropic
  • 32,188
  • 12
  • 99
  • 147

1 Answers1

3

You'll need to list files to include in your binary distribution in the package_data entry to setuptools.setup():

config = {
    "name": "mypackage",
    "version": "3.0.15",
    "include_package_data": True,
    "scripts": ["something.py"],
    "entry_points": {},
    "package_data": {'': ['*.ext1', '*.ext2']},
    "zip_safe": False,
    }
Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • [The docs](http://peak.telecommunity.com/DevCenter/setuptools#including-data-files) say "`package_data`: Specify additional patterns to match files and directories that may or may not be matched by MANIFEST.in or found in source control." ...from that I understood that the above should not be necessary, it should use what is in `MANIFEST.in` – Anentropic Jul 31 '14 at 12:20
  • @Anentropic: but those files would not be installed from the source to the package on installation. There are 2 stages here: source packaging, and producing an installation on the target from the source. The MANIFEST controls the first stage, `package_data` the second. – Martijn Pieters Jul 31 '14 at 12:21
  • @Anentropic: `bdist` aims to skip the first step packaging the result of the second step. – Martijn Pieters Jul 31 '14 at 12:22
  • ok that explains it. in my case since I only need the python packages it looks like I could specify `packages: ['mypackage']` and not `package_data` ...I was trying to avoid the latter since I understood it would not automatically recurse through sub directories. I see my mistake was trying to control everything from the manifest – Anentropic Jul 31 '14 at 12:26
  • 2
    perhaps I have failed at reading but I found the docs and the process unclear and confusing – Anentropic Jul 31 '14 at 12:28
  • 1
    @Anentropic: the process *is* unclear and confusing. Took me quite some time to grasp these concepts too. :-) – Martijn Pieters Jul 31 '14 at 12:28