Skip to content

Commit

Permalink
Merge pull request #12 from cite-reader/packaging
Browse files Browse the repository at this point in the history
Makes the app an installable package
  • Loading branch information
drahamim authored Dec 28, 2022
2 parents 6c5144a + 4042326 commit f1e9c23
Show file tree
Hide file tree
Showing 18 changed files with 77 additions and 23 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,10 @@ venv.bak/

# code editor stuff
.vscode
.idea/

database.db

.DS_Store

config.toml
config.toml
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include src/invenflask/schema.sql
include src/invenflask/templates/*.html
39 changes: 26 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -32,4 +45,4 @@ sqlite> .mode csv
sqlite> .import ./test_data/<your staff file>.csv staffs
# verify it worked
sqlite> SELECT * from staffs;
```
```
9 changes: 0 additions & 9 deletions init_db.py

This file was deleted.

23 changes: 23 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Empty file added src/invenflask/__init__.py
Empty file.
File renamed without changes.
24 changes: 24 additions & 0 deletions src/invenflask/init_db.py
Original file line number Diff line number Diff line change
@@ -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()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit f1e9c23

Please sign in to comment.