diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e19aab9 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,28 @@ +[tool.poetry] +name = "odapi" +version = "0.1.0" +description = "Odyfo RESTful API" +authors = ["coolneng "] +license = "GPL-3.0-or-later" + +[tool.poetry.dependencies] +python = "^3.8" +fastapi = "^0.63.0" +uvicorn = "^0.13.3" +pydantic = "^1.7.3" +email-validator = "^1.1.2" +SQLAlchemy = "^1.3.23" +alembic = "^1.5.4" +twilio = "^6.51.1" +passlib = "^1.7.4" +bcrypt = "^3.2.0" +psycopg2 = "^2.8.6" + +[tool.poetry.dev-dependencies] +pytest = "^6.2.2" +isort = "^5.7.0" +pyflakes = "^2.2.0" + +[build-system] +requires = ["poetry-core>=1.0.0"] +build-backend = "poetry.core.masonry.api" diff --git a/shell.nix b/shell.nix index a197bba..01138fa 100644 --- a/shell.nix +++ b/shell.nix @@ -2,22 +2,27 @@ with pkgs; -mkShell { - buildInputs = [ - # Dependencies - python38Packages.fastapi - python38Packages.uvicorn - python38Packages.pydantic - python38Packages.email_validator - python38Packages.sqlalchemy - python38Packages.alembic - python38Packages.pytest - python38Packages.twilio - python38Packages.passlib - python38Packages.bcrypt - sqlite - # Development tools - python38Packages.isort - python38Packages.pyflakes - ]; +let + sql_file = "assets/db_creation.sql"; + data_dir = "$(pwd)/.pgdata"; + +in mkShell { + buildInputs = [ python38 poetry postgresql ]; + + shellHook = '' + trap "kill 0" EXIT + export PGDATA="${data_dir}" + export PGHOST="${data_dir}" + + if [ ! -d ${data_dir} ]; then + initdb --auth-local=trust --no-locale --encoding=UTF8 + fi + + if ! pg_ctl status; then + pg_ctl start -o "--unix_socket_directories=${data_dir} --listen_addresses='''" + fi + + psql -d postgres -f ${sql_file} + alias psql='psql -d postgres' + ''; }