I have created a python package.
At the advice of several internet sources (including https://github.com/pypa/sampleproject ), I have set up the directory structure like so:
root_dir
├── bin
│ └── do_stuff.py
├── MANIFEST.in
├── README.md
├── my_lib
│ ├── __init__.py
│ ├── __main__.py
│ └── my_lib.py
├── setup.cfg
├── setup.py
├── important_script.py
└── tests
├── __init__.py
└── test_lib.py
I have included tests
, bin
, and important_script.py
in the manifest, and set include_package_data
in setup.py
to True.
However, after running pip install root_dir
, I see that it correctly installed my_lib
but bin
and tests
were just placed directly into Lib/site-packages
as if they were separate packages.
I can't find important_script.py
at all, and I don't think it was installed.
How do I correctly include these files/directories in my installation?
EDIT
So, it turns out that the bin
and tests
directories being placed directly into the site-packages
directory was caused by something I was doing previously, but I can't discover what. At some point a build
and a dist
directory were generated in my root_dir
(I assume by pip or setuptools?), and any changes I made to the project after that were not actually showing up in the installed package. After deleting these directories, I am no longer able to reproduce that issue.
The sample project distributes neither bin
nor tests
, it even explicitly excludes tests
.
To include bin
you should use scripts
or entry_points
(like in the sample project). Add this to your setup.py
to setup()
call:
scripts=['bin/do_stuff.py'],
To include tests
you should restructure your tree to include the directory tests
under the package directory:
root_dir
├── bin
│ └── do_stuff.py
├── MANIFEST.in
├── README.md
├── my_lib
│ ├── __init__.py
│ ├── __main__.py
│ └── my_lib.py
│ └── tests
│ ├── __init__.py
│ └── test_lib.py
├── setup.cfg
├── setup.py
├── important_script.py