Skip to content

Commit

Permalink
Initial checkin of directory structure for future use with poetry / c…
Browse files Browse the repository at this point in the history
  • Loading branch information
magmasource committed Dec 11, 2023
0 parents commit ba696ee
Show file tree
Hide file tree
Showing 24 changed files with 231 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
workspaces/*/.venv
workspaces/*/poetry.lock
workspaces/*/poetry.toml
.poetry.toml
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
PROJECTS := $(notdir $(wildcard workspaces/*))


.clean-venv:
rm -rf .venv

.venv:
pipx run poetry config virtualenvs.create true --local
pipx run poetry install --sync

init: .clean-venv .venv

test-%: .venv
pipx run poetry install --sync --with $*
pipx run poetry run pytest workspaces/$*

tests: .venv $(addprefix test-, $(PROJECTS))

test-isolated-%: .venv
pipx run poetry install --sync --only $*
pipx run poetry run pytest workspaces/$*
4 changes: 4 additions & 0 deletions poetry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[virtualenvs]
in-project = true
create = true
path = ".venv"
32 changes: 32 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[tool.poetry]
name = "alphamelts"
version = "0.1.0"
description = ""
authors = []
readme = "README.md"
packages = []

[tool.poetry.group.main.dependencies]
python = "^3.10"

[tool.poetry.group.app.dependencies]
alphamelts-app = { path = "workspaces/app", develop = true}

[tool.poetry.group.lib.dependencies]
alphamelts-lib = { path = "workspaces/lib", develop = true}

[tool.poetry.group.lib-test.dependencies]
alphamelts-lib = { path = "workspaces/lib", develop = true, extras=["test"]}

[tool.poetry.group.cli.dependencies]
alphamelts-cli = { path = "workspaces/cli", develop = true}

[tool.poetry.group.app.dependencies]
alphamelts-mat = { path = "workspaces/mat", develop = true}

[tool.poetry.group.app.dependencies]
alphamelts-py = { path = "workspaces/py", develop = true}

[build-system]
requires = ["poetry-core", "setuptools", "setuptools-cpp"]
build-backend = "poetry.core.masonry.api"
15 changes: 15 additions & 0 deletions workspaces/app/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[tool.poetry]
name = "alphamelts-app"
version = "0.0.0"
description = ""
authors = []
packages = [{include = "alphamelts", from = "src"}]

[tool.poetry.dependencies]
python = "^3.10"
orjson = "^3.8.0"
alphamelts-cli = { path = "../cli"}

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Empty file.
19 changes: 19 additions & 0 deletions workspaces/app/src/alphamelts/app/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from time import sleep

import orjson

from alphamelts.lib import Foo


def main(max_iters: float | None) -> None:
iter = 0
if max_iters is None:
max_iters = float("inf")
while iter < max_iters:
iter +=1
print(orjson.dumps(Foo(name="app").dict()).decode())
sleep(1)


if __name__ == "__main__":
main()
3 changes: 3 additions & 0 deletions workspaces/app/src/alphamelts/app/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def test_import():
from alphamelts.app.main import main # type: ignore
main(1)
15 changes: 15 additions & 0 deletions workspaces/cli/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[tool.poetry]
name = "alphamelts-cli"
version = "0.0.0"
description = ""
authors = []
packages = [{include = "alphamelts", from = "src"}]

[tool.poetry.dependencies]
python = "^3.10"
rich = "^12.6.0"
alphamelts-lib = { path = "../lib"}

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Empty file.
11 changes: 11 additions & 0 deletions workspaces/cli/src/alphamelts/cli/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from rich import print

from alphamelts.lib import Foo


def main() -> None:
print(Foo(name="cli"))


if __name__ == "__main__":
main()
2 changes: 2 additions & 0 deletions workspaces/cli/src/alphamelts/cli/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def test_import():
from alpahmelts.cli.main import main # type: ignore
18 changes: 18 additions & 0 deletions workspaces/lib/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[tool.poetry]
name = "alphamelts-lib"
version = "0.0.0"
description = ""
authors = []
packages = [{include = "alphamelts", from = "src"}]

[tool.poetry.dependencies]
python = ">=3.7"
pydantic = { extras = ["email"], version = ">=1.10.2"}
pytest = { version = "*", optional = true }

[tool.poetry.extras]
test = ["pytest"]

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
5 changes: 5 additions & 0 deletions workspaces/lib/src/alphamelts/lib/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from pydantic import BaseModel


class Foo(BaseModel):
name: str
Empty file.
8 changes: 8 additions & 0 deletions workspaces/lib/tests/test_foo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import json
from alphamelts.lib import Foo


def test_foo() -> None:
got = json.loads(Foo(name="adrian").json())
expected = {"name": "adrian"}
assert got == expected
15 changes: 15 additions & 0 deletions workspaces/mat/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[tool.poetry]
name = "alphamelts-mat"
version = "0.0.0"
description = ""
authors = []
packages = [{include = "alphamelts", from = "src"}]

[tool.poetry.dependencies]
python = "^3.10"
orjson = "^3.8.0"
alphamelts-lib = { path = "../lib"}

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Empty file.
19 changes: 19 additions & 0 deletions workspaces/mat/src/alphamelts/mat/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from time import sleep

import orjson

from alphamelts.lib import Foo


def main(max_iters: float | None) -> None:
iter = 0
if max_iters is None:
max_iters = float("inf")
while iter < max_iters:
iter +=1
print(orjson.dumps(Foo(name="app").dict()).decode())
sleep(1)


if __name__ == "__main__":
main()
3 changes: 3 additions & 0 deletions workspaces/mat/src/alphamelts/mat/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def test_import():
from alphamelts.mat.main import main # type: ignore
main(1)
15 changes: 15 additions & 0 deletions workspaces/py/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[tool.poetry]
name = "alphamelts-py"
version = "0.0.0"
description = ""
authors = []
packages = [{include = "alphamelts", from = "src"}]

[tool.poetry.dependencies]
python = "^3.10"
orjson = "^3.8.0"
alphamelts-lib = { path = "../lib"}

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Empty file.
19 changes: 19 additions & 0 deletions workspaces/py/src/alphamelts/py/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from time import sleep

import orjson

from alphamelts.lib import Foo


def main(max_iters: float | None) -> None:
iter = 0
if max_iters is None:
max_iters = float("inf")
while iter < max_iters:
iter +=1
print(orjson.dumps(Foo(name="app").dict()).decode())
sleep(1)


if __name__ == "__main__":
main()
3 changes: 3 additions & 0 deletions workspaces/py/src/alphamelts/py/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def test_import():
from alphamelts.py.main import main # type: ignore
main(1)

0 comments on commit ba696ee

Please sign in to comment.