79297980

Date: 2024-12-20 17:31:41
Score: 1
Natty:
Report link

After looking at serveral resourced (and a link included by sinoroc in the comments - thanks) and Youtube videos, I ended up reorganising my layout:

├── LICENSE
├── pyproject.toml
├── README.md
└── src
    ├── controller
    │   ├── conn_mgr.py
    │   └── ora_tapi.py
    ├── __init__.py
    ├── lib
    │   ├── config_manager.py
    │   └── __init__.py
    ├── model
    │   ├── api_generator.py
    │   ├── db_objects.py
    │   ├── framework_errors.py
    │   ├── __init__.py
    │   ├── session_manager.py
    │   └── user_security.py
    ├── OraTAPI.csv
    ├── resources
    │   ├── config
    │   │   ├── OraTAPI.ini
    │   │   └── OraTAPI.ini.sample
    │   └── templates
    │       ├── column_expressions
    │       │   ├── inserts
    │       │   │   ├── created_by.tpt
    │       │   │   ├── created_by.tpt.sample
    │       │   │   ├── updated_on.tpt
    │       │   │   └── updated_on.tpt.sample
    │       │   └── updates
    │       │       ├── created_by.tpt
    │       │       ├── created_by.tpt.sample
    │       │       ├── updated_on.tpt
    │       │       └── updated_on.tpt.sample
    │       ├── misc
    │       │   ├── trigger
    │       │   │   ├── table_name_biu.tpt
    │       │   │   └── table_name_biu.tpt.sample
    │       │   └── view
    │       │       ├── view.tpt
    │       │       ├── view.tpt.lbase_sample
    │       │       └── view.tpt.sample
    │       └── packages
    │           ├── body
    │           │   ├── package_footer.tpt
    │           │   ├── package_footer.tpt.sample
    │           │   ├── package_header.tpt
    │           │   └── package_header.tpt.sample
    │           ├── procedures
    │           │   ├── delete.tpt
    │           │   ├── delete.tpt.sample
    │           │   ├── upsert.tpt
    │           │   └── upsert.tpt.sample
    │           └── spec
    │               ├── package_footer.tpt
    │               ├── package_footer.tpt.sample
    │               ├── package_header.tpt
    │               └── package_header.tpt.sample
    ├── setup.sh
    └── view
        ├── console_display.py
        ├── __init__.py
        ├── interactions.py
        └── ora_tapi_csv.py

I removed the setup.py and MANIFEST.ini and went with the following pyproject.toml file:

[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "OraTAPI"
version = "1.0.6"
description = "Oracle Table API Generator Application"
authors = [
    { name = "Clive" }
]

# Useful if publishing through PyPI
keywords = [
    "python",
    "oracle",
    "database",
    "plsql",
    "table api",
    "stored procedures",
    "views",
    "database triggers",
    "code generator",
    "automation"
]

# Metadata
classifiers = [
    "Programming Language :: Python :: 3",
    "Development Status :: 4 - Beta",
    "Intended Audience :: Developers",
    "Topic :: Database",
    "Topic :: Software Development :: Code Generators",
    "License :: OSI Approved :: MIT License",
    "Operating System :: OS Independent"
]

# Specify the package directory
[tool.setuptools.packages.find]
where = ["src"]

[project.urls]
"Repository" = "https://github.com/avalon60/OraTAPI"

# Include additional resources
[tool.setuptools.package-data]
"*" = ["*.ini", "*.ini.sample", "*.tpt", "*.tpt.sample"]

# Declare scripts as dynamic
dynamic = ["scripts"]

# Scripts defined under `[project.scripts]`
[project.scripts]
conn_mgr = "controller.conn_mgr:main"
ora_tapi = "controller.ora_tapi:main"

NOTE: I didn't include the dependencies in the above.

It was this section which was critical:

*# Include additional resources
[tool.setuptools.package-data]
"*" = ["*.ini", "*.ini.sample", "*.tpt", "*.tpt.sample"]*

This caused the wheel file to start including the resources folder. However, it didn't include the resources folders into the dist file. To get these to be included, I had to use this command:

git add src/**/*.ini src/**/*.tpt

Note that you need to use setuptools-scm for the above solution.

I was hoping that I would be able to get the entrypoint scripts working:

*# Scripts defined under `[project.scripts]`
[project.scripts]
conn_mgr = "controller.conn_mgr:main"
ora_tapi = "controller.ora_tapi:main"*

But this just didn't seem to work - nothing got placed in the venv/bin directory. Anyway, I came to the conclusion that deploying an application, which includes config files and templates that the end-user needs to modify, just wasn't that practical - they get hidden deep in the site-packages directory, e.g. venv/lib/python3.10/site-packages. If I had gotten the entrypoints working I may have considered having the program clone the config and templates to a more suitable location, but the juice didn't apear to be worth the squeeze.

At least I got to the point where I'd be able to develop a distributable package the newer way (using pyproject.toml).

Anyone interested may find this Youtube video useful, and educational. Especially the techniques used to handle your own packages: https://www.youtube.com/watch?v=v6tALyc4C10&t=1613s

Reasons:
  • Blacklisted phrase (0.5): thanks
  • Blacklisted phrase (1): youtube.com
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: avalon20