Rushy Panchal
Rushy Panchal

Reputation: 17552

Python Distutils Package Distribution

I am trying to create a package installer using distutils on Python 2.7.

Here's my setup.py:

from distutils.core import setup
import distutils.command.bdist as bdist

setup_options = {
    'name': 'tk',
    'version': '1.0',
    'description': 'Graphics package that supplements native Tkinter',
    'package_dir': {'tk': ''},
    # this is because setup.py is in the same directory as the package contents
    'packages': ['tk', 'tk.latex'],
    }

setup(**setup_options)

Using python setup.py bdist --format=wininst, then using 7-Zip to look through the executable, I find this directory of files and folders:

PURELIB/ # excepted for the executable
    tk/ # also expected
    latex/ # subpackage, should not be here
    some_file_in_tk.py # this should only be located in tk, not in this main directory

When using the installer on another computer, it installs the tk package under site-packages, as expected. However, it also installs the latex subpackage (which is in tk) and all other files in tk. Why does this happen, and can I resolve this? Thanks!

Upvotes: 0

Views: 95

Answers (1)

jfs
jfs

Reputation: 414805

Examples from the docs suggest the following directory layout:

<root>
├── setup.py
└── tk
    ├── __init__.py
    └── latex
        └── __init__.py

where setup.py:

from distutils.core import setup

setup(
    name='tk',
    version='1.0',
    description='Graphics package that supplements native Tkinter',
    packages=['tk', 'tk.latex'],
)

Upvotes: 2

Related Questions