[Python] Wheel File Not Including templates Directory and Root Files in Python Package

Discussão em 'Python' iniciado por Stack, Dezembro 17, 2024.

  1. Stack

    Stack Membro Participativo

    Background:

    I am new to using 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="your_email@example.com",
    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 other files from the root folder (such as README.md, LICENSE, etc.). There is a directory, OraTAPI-1.0.6.data/data, in the wheel file, but it only contains the root files. Whether I use the MANIFEST.in file or not, I seem to get the same results.

    What I’ve Tried:

    • Ensured include_package_data=True is set in setup.py.
    • Explicitly defined package_data in setup.py.
    • Double-checked that the templates directory is correctly included in MANIFEST.in.
    • Ran the python3 setup.py sdist bdist_wheel command multiple times after making changes.
    Questions:

    1. What do I need to do to ensure that the wheel file includes both the templates directory and root-level files like LICENSE, README.md, etc.?
    2. Am I missing any steps in the packaging process to make sure the wheel is complete?

    Continue reading...

Compartilhe esta Página