Background:
I am new to using the standard Python packaging tools and have typically relied on custom tooling. However, I’ve decided to get a better understanding of the packaging process, but I’m running into an issue.
I’m trying to create artifacts for distributing my application, and I’ve successfully generated both an sdist file and a wheel file. While I could probably set up a process to install from the sdist file, I’m concerned that I might be missing something. The wheel file, however, is being generated with an incomplete inventory.
Project Structure:
.
├── bin
│ ├── conn_mgr.sh
│ └── ora_tapi.sh
├── config
│ ├── OraTAPI.ini
│ └── OraTAPI.ini.sample
├── controller
│ ├── conn_mgr.py
│ ├── __init__.py
│ └── ora_tapi.py
├── lib
│ ├── config_manager.py
│ └── __init__.py
├── LICENSE
├── MANIFEST.in
├── model
│ ├── api_generator.py
│ ├── db_objects.py
│ ├── framework_errors.py
│ ├── __init__.py
│ ├── session_manager.py
│ └── user_security.py
├── pyproject.toml
├── README.md
├── requirements.txt
├── setup.py
├── setup.sh
├── templates
│ ├── column_expressions
│ │ ├── inserts
│ │ │ └── updated_on.tpt
│ │ └── updates
│ │ └── updated_on.tpt
│ ├── misc
│ │ ├── trigger
│ │ │ └── table_name_biu.tpt
│ │ └── view
│ │ └── view.tpt
│ └── packages
│ ├── body
│ │ ├── package_footer.tpt
│ │ └── package_header.tpt
│ ├── procedures
│ │ ├── delete.tpt
│ │ ├── insert.tpt
│ │ ├── select.tpt
│ │ └── update.tpt
│ └── spec
│ ├── package_footer.tpt
│ └── package_header.tpt
└── view
├── console_display.py
├── __init__.py
├── interactions.py
└── ora_tapi_csv.py
setup.py File:
from setuptools import setup, find_packages
setup(
name="OraTAPI",
version="1.0.6",
description="Oracle TAPI Application",
author="Your Name",
author_email="[email protected]",
packages=find_packages(),
include_package_data=True, # Include files from the MANIFEST.in
package_data={ # Include non-Python files in specific packages
"templates": ["**/*.tpt", "**/*.tpt.sample"],
},
data_files=[ # Include root-level files and other extras
(".", ["setup.py", "LICENSE", "setup.sh", "requirements.txt", "README.md"]),
],
entry_points={
"console_scripts": [
"conn_mgr=controller.conn_mgr:main",
"ora_tapi=controller.ora_tapi:main",
]
},
)
MANIFEST.in File:
include *.sh
recursive-include bin *.sh
recursive-include templates *.tpt *.tpt.sample
include config/*.ini
include config/*.ini.sample
include LICENSE
include README.md
The Issue:
I’m creating the package by running the following:
source venv/bin/activate
python3 setup.py sdist bdist_wheel
Both the sdist and wheel files are created, but I’m finding that the wheel file doesn’t include my templates directory or any of its sub-directories and their contents. I notice that files from the root folder (such as README.md, LICENSE, etc.) are displaced to an OraTAPI-1.0.6.data/datadirectory.
Whether I use the MANIFEST.in file or not, I seem to get the same results.
What I’ve Tried:
- Ensured
include_package_data=Trueis set insetup.py. - Explicitly defined
package_datainsetup.py. - Double-checked that the
templatesdirectory is correctly included inMANIFEST.in. - Ran the
python3 setup.py sdist bdist_wheelcommand multiple times after making changes.
Questions:
- What do I need to do to ensure that the wheel file includes both the
templatesdirectory and root-level files likeLICENSE,README.md, etc.? - Am I missing any steps in the packaging process to make sure the wheel is complete?
Update:
I forgot to mention that the modules discovered during deployment are deployed under the global site packages (something which I will avoid using a venv), but only Python modules are deployed - the templates are not:
clive@ryzen-mint:~/.local/lib/python3.10/site-packages$ ls -1
bump2version-1.0.1.dist-info
bumpversion
controller
lib
model
OraTAPI-1.0.6.dist-info
view
src/oratapidirectory and move all the code and data files into this directory and subdirectories of it. This would make things much easier to handle.__init__.pyyou might want to try withfind_namespace_packages()instead offind_packages().data_files, it is deprecated, and also there is no point in having the files you listed underdata_filesbe listed indata_filesto begin with, this is unnecessary. -- What you want is "package data". But as the name says, the data has to be in an importable package or a subdirectory of an importable package. I recommend you start with a minimal project ([mre)], I recommend this tutorial (pay attention to the directory structure) and build up from there one file at a time.