What's Wrong With This `setup.py`?
Solution 1:
The problem is well explained here:
Setuptools has many silent failure modes. One of them is failure to include all files in sdist release (well not exactly a failure, you could RTFM, but the default behavior is unexpected). This post will serve as a google-yourself-answer for this problem, until we get new, shinier, Distribute solving all of our problems.
As comments point out, the bug (misdesign) is actually in distutils -- setuptools just fails to fix it (if you're using svn, things are actually a bit better).
I can reproduce your problem as you observe it, i.e., shortening file names a bit, I have:
$ ls -lR
total 8
-rw-r--r-- 1 aleax eng 0 Oct 24 11:25 __init__.py
-rw-r--r-- 1 aleax eng 0 Oct 24 11:25 modu.py
drwxr-xr-x 4 aleax eng 136 Oct 24 11:25 mysub
-rw-r--r-- 1 aleax eng 323 Oct 24 11:26 setup.py
./mysub:
total 0
-rw-r--r-- 1 aleax eng 0 Oct 24 11:25 __init__.py
-rw-r--r-- 1 aleax eng 0 Oct 24 11:25 deepmod.py
and running python setup.py sdist
produces (as well as warnings):
$ ls -lR
total 16
-rw-r--r-- 1 aleax eng 104 Oct 24 11:35 MANIFEST
-rw-r--r-- 2 aleax eng 0 Oct 24 11:25 __init__.py
drwxr-xr-x 3 aleax eng 102 Oct 24 11:35 dist
-rw-r--r-- 2 aleax eng 0 Oct 24 11:25 modu.py
drwxr-xr-x 5 aleax eng 170 Oct 24 11:35 mypack
drwxr-xr-x 4 aleax eng 136 Oct 24 11:25 mysub
-rw-r--r-- 1 aleax eng 323 Oct 24 11:26 setup.py
./dist:
total 8
-rw-r--r-- 1 aleax eng 483 Oct 24 11:35 a-0.1.tar.gz
./mypack:
total 0
-rw-r--r-- 2 aleax eng 0 Oct 24 11:25 __init__.py
-rw-r--r-- 2 aleax eng 0 Oct 24 11:25 modu.py
drwxr-xr-x 4 aleax eng 136 Oct 24 11:35 mysub
./mypack/mysub:
total 0
-rw-r--r-- 2 aleax eng 0 Oct 24 11:25 __init__.py
-rw-r--r-- 2 aleax eng 0 Oct 24 11:25 deepmod.py
./mysub:
total 0
-rw-r--r-- 2 aleax eng 0 Oct 24 11:25 __init__.py
-rw-r--r-- 2 aleax eng 0 Oct 24 11:25 deepmod.py
One solution is to change the directory layout as follows (from the current mypack dir):
$ mkdir mypack
$ mv __init__.py modu.py mysub/ mypack
$ touch README.txt
so getting:
$ ls -lR
total 8
-rw-r--r-- 1 aleax eng 0 Oct 24 11:37 README.txt
drwxr-xr-x 5 aleax eng 170 Oct 24 11:37 mypack
-rw-r--r-- 1 aleax eng 323 Oct 24 11:26 setup.py
./mypack:
total 0
-rw-r--r-- 1 aleax eng 0 Oct 24 11:25 __init__.py
-rw-r--r-- 1 aleax eng 0 Oct 24 11:25 modu.py
drwxr-xr-x 4 aleax eng 136 Oct 24 11:25 mysub
./mypack/mysub:
total 0
-rw-r--r-- 1 aleax eng 0 Oct 24 11:25 __init__.py
-rw-r--r-- 1 aleax eng 0 Oct 24 11:25 deepmod.py
(and getting rid of one of the warnings, the one about README -- the one about missing MANIFEST.in clearly remains;-). Also change one line of setup.py to:
package_dir={'': '.'},
Now, after python setup.py sdist
, you do get a decent tarball:
$ tar tvf dist/a-0.1.tar.gz
drwxr-xr-x aleax/eng 0 2009-10-24 11:40:05 a-0.1/
drwxr-xr-x aleax/eng 0 2009-10-24 11:40:05 a-0.1/mypack/
-rw-r--r-- aleax/eng 0 2009-10-24 11:25:30 a-0.1/mypack/__init__.py
-rw-r--r-- aleax/eng 0 2009-10-24 11:25:30 a-0.1/mypack/modu.py
drwxr-xr-x aleax/eng 0 2009-10-24 11:40:05 a-0.1/mypack/mysub/
-rw-r--r-- aleax/eng 0 2009-10-24 11:25:30 a-0.1/mypack/mysub/__init__.py
-rw-r--r-- aleax/eng 0 2009-10-24 11:25:30 a-0.1/mypack/mysub/deepmod.py
-rw-r--r-- aleax/eng 156 2009-10-24 11:40:05 a-0.1/PKG-INFO
-rw-r--r-- aleax/eng 0 2009-10-24 11:37:41 a-0.1/README.txt
-rw-r--r-- aleax/eng 322 2009-10-24 11:39:46 a-0.1/setup.py
the MANIFEST file is still created in your current directory of course, but I hope that's not a problem.
Solution 2:
Instead of this:
my_package\
my_subpackage\
__init__.py
deep_module.py
__init__.py
module.py
setup.py
Try this:
my_package_source\
setup.py
README.txt
my_package\
my_subpackage\
__init__.py
deep_module.py
__init__.py
module.py
You don't actually need a README, it's just for illustrative purpose for what kind of things sit in the root directory of your project's folder.
=== EDIT ======================================
I should elaborate. After you run it your directory should then look something like this:
my_package_source\
setup.py
README.txt
MANIFEST
PKG-INFO
dist\
my_package_0.X.tar.gz (or .zip on windows I believe)
my_package\
my_subpackage\
__init__.py
deep_module.py
__init__.py
module.py
Use the package under the dist directory to distribute.
Post a Comment for "What's Wrong With This `setup.py`?"