I am working on packaging a Python project that has the directory structure:
package-main (located on Desktop)
- my_package
- __init__.py
- datasets
- plot.py
- shapefiles
- __init__.py
- shapefile1
- shapefile1.shp
- shapefiel1.dbf
- (and 4 other file formats)
- shapefile2
- shapefile2.shp
- shapefiel2.dbf
- (and 4 other file formats)
- utils.py
- states.py
- my_package.egg-info
- LICENSE.txt
- setup.cfg
- README.md
- tests
- docs
- pyproject.toml
- dist
- my_package.egg-info
I am running into a problem where when I upload the package my_package
to testPyPI, and then download the package to my local machine using the command:
pip install my_package
it is not downloading all of the files.
When I create a venv
to check the package files, and then go into the package files for the virtual environment it only shows:
my_package
my_package-0.1.1.dist-info
When I open up the my_package
directory all I see is the following structure:
my_package
- __init__py
- __pychache__
- plot.py
- shapefiles
- __init__.py
- __pychache__
- states.py
- utils.py
I have determined that this must have something to do with how I setting up the setup.cfg
file (perhaps I am not telling it to download all of the package files?
My current setup.cfg
file looks like this:
[options]
install_requires =
numpy
geopandas
matplotlib
python_requires = >=3.6
packages = find:
I have read the documentation for setuptools here, but this does not fully clear things up for me. I need to tell the package to download the shape files as well.
I have seen multiple examples on how to do this with setup.py
, but since it was advised on the Python packaging tutorial that I do not use this method since its dynamic vs static, I have not been able to find any examples online of how to do this.
Any links to resources or examples would be greatly appreciated.
Question: How do I change the setup.cfg file to make sure that it downloads all of the files the package needs to function correctly?
Edit:
The MANIFEST.in
file looks like this:
include my_package/shapefiles/shapefile1/*.shp
include my_package/shapefiles/shapefile1/*.dbf
include my_package/shapefiles/shapefile2/*.shp
include my_package/shapefiles/shapefile2/*.dbf
According to setuptools
docs on "Configuring setup() using setup.cfg files", you could try the following:
[options]
...
include_package_data = True
...
[options.package_data]
* = *.dbf, *.shp, *.ext1, *.ext2, *.ext3, *.ext4