Why does setupupools not copy modules to a subfolder?

I have a project called hwrt (see GitHub , PyPI ) with the following structure:

.
β”œβ”€β”€ bin
β”œβ”€β”€ docs
β”œβ”€β”€ hwrt
β”‚   β”œβ”€β”€ datasets
β”‚   β”‚   β”œβ”€β”€ crohme_eval.py
β”‚   β”‚   β”œβ”€β”€ __init__.py
β”‚   β”‚   β”œβ”€β”€ inkml.py
β”‚   β”‚   β”œβ”€β”€ README.md
β”‚   β”‚   └── results.csv
β”‚   β”œβ”€β”€ __init__.py
β”‚   β”œβ”€β”€ misc: Not important for this question
β”‚   β”œβ”€β”€ selfcheck.py
β”‚   β”œβ”€β”€ serve.py
β”‚   β”œβ”€β”€ ... (more Python modules)
β”‚   β”œβ”€β”€ templates: Not important for this question
β”‚   └── view.py
β”œβ”€β”€ LICENSE
β”œβ”€β”€ Makefile
β”œβ”€β”€ MANIFEST.in
β”œβ”€β”€ README.md
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ setup.cfg
β”œβ”€β”€ setup.py
└── tests: Not important for this question

My problem is that

$ python
>>> from hwrt.datasets import inkml
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named datasets

root/of/project$ python
>>> from hwrt.datasets import inkml
>>> 

Note that the folder datasetshas __init__.py. So this is not a problem. One problem (?) Is that setuptools does not copy the dataset folder. Do I have to do anything else than put __init__.pyin a folder?

setup.py

try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup

config = {
    'name': 'hwrt',
    'version': '0.1.217',
    'author': 'Martin Thoma',
    'author_email': 'info@martin-thoma.de',
    'maintainer': 'Martin Thoma',
    'maintainer_email': 'info@martin-thoma.de',
    'packages': ['hwrt'],
    'scripts': ['bin/hwrt', 'bin/backup.py',
                'bin/test.py', 'bin/train.py',
                'bin/create_testset_online_once.py'],
    'package_data': {'hwrt': ['templates/*', 'misc/*']},
    'platforms': ['Linux', 'MacOS X', 'Windows'],
    'url': 'https://github.com/MartinThoma/hwrt',
    'license': 'MIT',
    'description': 'Handwriting Recognition Tools',
    'long_description': ("A tookit for handwriting recognition. It was "
                         "developed as part of the bachelors thesis of "
                         "Martin Thoma."),
    'install_requires': [
        "argparse",
        "theano",
        "nose",
        "natsort",
        "PyYAML",
        "matplotlib",
        "nntoolkit",
        "h5py",
        "flask",
        "flask-bootstrap",
        "requests",
        "six"
    ],
    'keywords': ['HWRT', 'recognition', 'handwriting', 'on-line'],
    'download_url': 'https://github.com/MartinThoma/hwrt',
    'classifiers': ['Development Status :: 3 - Alpha',
                    'Environment :: Console',
                    'Intended Audience :: Developers',
                    'Intended Audience :: Science/Research',
                    'License :: OSI Approved :: MIT License',
                    'Natural Language :: English',
                    'Programming Language :: Python :: 2.7',
                    'Programming Language :: Python :: 3',
                    'Programming Language :: Python :: 3.3',
                    'Programming Language :: Python :: 3.4',
                    'Topic :: Scientific/Engineering :: Artificial Intelligence',
                    'Topic :: Software Development',
                    'Topic :: Utilities'],
    'zip_safe': False,
    'test_suite': 'nose.collector'
}

setup(**config)
+4
source share
1 answer

"packages" setup() . , , setup.py. "hwrt.datasets" .

, , - find_packages.

:

from setuptools import setup, find_packages

setup(
    # ...
    packages=find_packages(".")
)

. http://setuptools.readthedocs.io/en/latest/setuptools.html#using-find-packages

+5

All Articles