You do not need to manually create your own package, though you're welcome to if you want.
There are two important steps in getting the package to work automatically:
- Create a proper python package
- Ensure your
setup.py
is correct.
In your case, the model
subdirectory is causing issues. The quick fix is to move trainer/model/*
to trainer/
. Otherwise, you probably want to make model
a proper sub-package by adding a (probably blank) __init__.py
file in the model/
subdirectory.
Next, ensure your setup.py
file is correctly specified. A sample script is provided in this documentation, repeated here for convenience:
from setuptools import find_packages
from setuptools import setup
setup(name='trainer',
version='0.1',
include_package_data=True,
description='blah',
packages=find_packages()
)
You can verify that it worked by running:
python setup.py sdist
That will create a dist
subdirectory with a file trainer-0.1.tar.gz
. Extracting the contents of that file shows that all of the files were correctly included:
$ cd dist
$ tar -xvf trainer-0.1.tgz
$ find trainer-0.1/
trainer-0.1/
trainer-0.1/setup.py
trainer-0.1/setup.cfg
trainer-0.1/trainer
trainer-0.1/trainer/data_util.py
trainer-0.1/trainer/task.py
trainer-0.1/trainer/__init__.py
trainer-0.1/trainer/model
trainer-0.1/trainer/model/__init__.py
trainer-0.1/trainer/model/model.py
trainer-0.1/trainer/model/seq2seq.py
trainer-0.1/PKG-INFO
trainer-0.1/trainer.egg-info
trainer-0.1/trainer.egg-info/dependency_links.txt
trainer-0.1/trainer.egg-info/PKG-INFO
trainer-0.1/trainer.egg-info/SOURCES.txt
trainer-0.1/trainer.egg-info/top_level.txt