diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..9826116 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +include src/invenflask/schema.sql +include src/invenflask/templates/*.html diff --git a/README.md b/README.md index eba7012..c945b56 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,35 @@ # Invenflask [![Release](https://github.com/drahamim/invenflask/actions/workflows/release.yml/badge.svg)](https://github.com/drahamim/invenflask/actions/workflows/release.yml) -Dependancies: -sqlite3 3.32.3 -Python 3.10.9 -Flask 2.2.2 -Werkzeug 2.2.2 - +A small inventory ledger, based on Flask. ## Setup -Initialize the database\ -``` python3 init_db.py``` - -start flask\ -```flask app.py``` - +Proper Python distributions are currently a work in progress. Until then, install from a git clone or a source code snapshot from [releases](https://github.com/drahamim/invenflask/releases). + +Within the unpacked directory: +1. Set up virtual environment: + ``` + python3 -m venv venv + ``` +2. Install invenflask: + ``` + venv/bin/pip install . + ``` +3. Initialize database: + ``` + venv/bin/invenflask-init-db + ``` + This will create or overwrite a sqlite3 database named `database.db` in the current directory, which is the only setup the application currently understands. + + Note that this is a destructive operation. If `database.db` already exists, all tables that +4. Start a development server: + ``` + venv/bin/flask --app invenflask.app run + ``` + +For development, perform an _editable install_ instead at step 2 above, with `pip install -e .` ## import staff This will require a CSV formatted file @@ -32,4 +45,4 @@ sqlite> .mode csv sqlite> .import ./test_data/.csv staffs # verify it worked sqlite> SELECT * from staffs; -``` \ No newline at end of file +``` diff --git a/init_db.py b/init_db.py deleted file mode 100644 index cf3786c..0000000 --- a/init_db.py +++ /dev/null @@ -1,9 +0,0 @@ -import sqlite3 - -connection = sqlite3.connect('database.db') - -with open('schema.sql') as f: - connection.executescript(f.read()) - -connection.commit() -connection.close() diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..d084d5e --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,23 @@ +[project] +name = "invenflask" +version = "2.0.0" +authors = [ + { name = "Daniel Rahamim" } +] +description = "A Flask-based asset checkin/checkout system" +readme = "README.md" +requires-python = ">=3.10" + +dependencies = [ + "flask >=2.2.2, <3" +] + +[project.scripts] +invenflask-init-db = "invenflask.init_db:main" + +[project.urls] +"Bug Tracker" = "https://github.com/drahamim/invenflask/issues" + +[build-system] +requires = ["setuptools>=61.0"] +build-backend = "setuptools.build_meta" diff --git a/src/invenflask/__init__.py b/src/invenflask/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app.py b/src/invenflask/app.py similarity index 100% rename from app.py rename to src/invenflask/app.py diff --git a/src/invenflask/init_db.py b/src/invenflask/init_db.py new file mode 100644 index 0000000..f7246b5 --- /dev/null +++ b/src/invenflask/init_db.py @@ -0,0 +1,24 @@ +import argparse +from importlib.resources import files +import sqlite3 + + +def main(): + parser = argparse.ArgumentParser( + prog="invenflask-init-db", + description="Initialize the database for an invenflask instance" + ) + parser.add_argument( + '--database', + default="database.db", + help="Database file to (re)initialize" + ) + args = parser.parse_args() + + schema_sql = files("invenflask").joinpath("schema.sql").read_text() + connection = sqlite3.connect(args.database) + try: + connection.executescript(schema_sql) + connection.commit() + finally: + connection.close() diff --git a/schema.sql b/src/invenflask/schema.sql similarity index 100% rename from schema.sql rename to src/invenflask/schema.sql diff --git a/templates/base.html b/src/invenflask/templates/base.html similarity index 100% rename from templates/base.html rename to src/invenflask/templates/base.html diff --git a/templates/checkin.html b/src/invenflask/templates/checkin.html similarity index 100% rename from templates/checkin.html rename to src/invenflask/templates/checkin.html diff --git a/templates/checkout.html b/src/invenflask/templates/checkout.html similarity index 100% rename from templates/checkout.html rename to src/invenflask/templates/checkout.html diff --git a/templates/create_asset.html b/src/invenflask/templates/create_asset.html similarity index 100% rename from templates/create_asset.html rename to src/invenflask/templates/create_asset.html diff --git a/templates/edit_asset.html b/src/invenflask/templates/edit_asset.html similarity index 100% rename from templates/edit_asset.html rename to src/invenflask/templates/edit_asset.html diff --git a/templates/history.html b/src/invenflask/templates/history.html similarity index 100% rename from templates/history.html rename to src/invenflask/templates/history.html diff --git a/templates/index.html b/src/invenflask/templates/index.html similarity index 100% rename from templates/index.html rename to src/invenflask/templates/index.html diff --git a/templates/staff.html b/src/invenflask/templates/staff.html similarity index 100% rename from templates/staff.html rename to src/invenflask/templates/staff.html diff --git a/templates/status.html b/src/invenflask/templates/status.html similarity index 100% rename from templates/status.html rename to src/invenflask/templates/status.html