commit ffb976d94ec594d7273b0e57dc41afb4d4bdf40c Author: JJJHolscher Date: Thu Oct 19 10:43:26 2023 +0200 ginit diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000..8aa26455d --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) [year] [fullname] + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 000000000..f5c7cd77f --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +# README + +## files + +______________________________________________________________________ +|.gitignore |a list of unshared files| +|makefile|dev tools for installing, publisizing etc.| +|pyproject.toml |project metadata| +|requirements.txt |python dependencies| +|setup.py|necessary for `pip install -e .`| +|src/main.py|first file that gets called| +-------------------------------------------- diff --git a/makefile b/makefile new file mode 100644 index 000000000..d1e0f95e4 --- /dev/null +++ b/makefile @@ -0,0 +1,96 @@ + +pwd = $(shell pwd) +name = $(notdir $(pwd)) +email = $(shell cat "$$HOME/.secret/email.txt") +version = $(shell yq ".project.version" pyproject.toml) + +binlink = ${HOME}/.local/bin/$(name) +srclink = $(pwd)/$(name) +venv = $(pwd)/.venv +venvbin = $(venv)/bin +activate = $(venv)/bin/activate + +define clear_dir + if [ -d $(1) ]; then rm -r $(1); fi + mkdir $(1) +endef + +$(venv): $(venvbin) $(binlink) $(srclink) + touch $(venv) + +$(venvbin): $(activate) requirements.txt + . .venv/bin/activate && \ + pip install -r requirements.txt + touch $(venvbin) + +$(activate): + python -m venv --prompt $(name) .venv + . .venv/bin/activate && \ + pip install --upgrade pip; + +$(binlink): + echo "#!/bin/sh\n$(venv)/bin/python $(pwd)/src/main.py \"\$$@\"" > $(binlink) + chmod +x $(binlink) + +$(srclink): + ln -s "./src" "$(srclink)" + sed 's/NAME/$(name)/' pyproject.toml > pyproject.temp + mv pyproject.temp pyproject.toml + +# Make sure to have a public branch, possibly by running make share_init +share: $(venv) + git checkout main && \ + git push public --tags + +test_local: $(venv) + python -m unittest src.tests + +build: + $(call clear_dir,dist) + mv pyproject.toml pyproject.temp + sed 's/^email = .*/email = "$(email)"/' pyproject.temp > pyproject.toml + python -m build + mv pyproject.temp pyproject.toml + +increment_patch: + $(eval patch = $(shell echo $(version) | grep -o '[0-9]*$$')) + $(eval patch = $(shell echo "$$(($(patch)+1))")) + $(eval majorminor = $(shell echo $(version) | grep -o '^[0-9]*.[0-9]*.')) + $(eval version = $(majorminor)$(patch)) + sed 's/version = .*/version = "$(version)"/' pyproject.toml > pyproject.temp + mv pyproject.temp pyproject.toml + echo "$(version)" + +test: $(venv) test_local increment_patch build + twine upload dist/* -r pypitest + $(call clear_dir,"tmp") + cd tmp && \ + python -m venv .venv + . tmp/.venv/bin/activate && \ + pip install --extra-index-url "https://test.pypi.org/simple" "$(name) == $(version)" || \ + pip install --extra-index-url "https://test.pypi.org/simple" "$(name) == $(version)" && \ + python -m unittest "$(name).tests" + +publish: $(venv) + $(call clear_dir,"dist") + python -m build + twine upload dist/* + +to_github: + $(eval user_name = $(shell yq ".git.github" pyproject.toml)) + curl -u "$(user_name)" "https://api.github.com/user/repos" -d "{\"name\":\"$(name)\",\"private\":false}" + +share_init: + git checkout -b main || git checkout main + $(eval user_name = $(shell yq ".git.github" pyproject.toml)) + git remote add github "https://github.com/$(user_name)/$(name)" + git remote add public "/mnt/nas/git/$(name)" + git remote set-url --add --push public "/mnt/nas/git/$(name)" + git remote set-url --add --push public "https://github.com/$(user_name)/$(name)" + git push public main + +clean: + rm -r .venv + rm $(binlink) + rm $(srclink) + diff --git a/ml_requirements.txt b/ml_requirements.txt new file mode 100644 index 000000000..d4eefd00c --- /dev/null +++ b/ml_requirements.txt @@ -0,0 +1,24 @@ +build +debugpy +equinox +jax>=0.4.14 +jaxtyping +matplotlib +nbclassic +notebook +optax +pandas +pyright +scikit-learn +tensorboard +tensorboardX +torch +torchvision +tqdm +twine +typeguard +git+file://../jo3util +git+https://github.com/kiyoon/jupynium.nvim@v0.2.1 +git+https://github.com/JJJHolscher/jupytools +-f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html +-f https://download.pytorch.org/whl/cu118 diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 000000000..355e6bd0a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,48 @@ + +[project] +name = "NAME" +version = "0.0.0" # TODO; automatically update versions by looking at git +description = "" +dependencies = [] +dynamic = ["readme"] +requires-python = ">=3.11" +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", +] + +[project.optional-dependencies] +demo = [] + +[git] +github = "JJJHolscher" + +[project.urls] +homepage = "https://github.com/JJJHolscher/NAME" + +[[project.authors]] +name = "Jochem Hölscher" +email = "a.fake@e.mail" + +[build-system] +requires = [ + "setuptools>=61.0", +] +build-backend = "setuptools.build_meta" + +[tool.setuptools.packages.find] +include = ["NAME"] + +[tool.setuptools.dynamic] +readme = {file = ["README.md"], content-type = "text/markdown"} + +[tool.jupytext] +formats = "ipynb,py" + +[tool.pyright] +# see https://github.com/microsoft/pyright/blob/main/docs/configuration.md +exclude = ".venv" +venvPath = "." +venv = ".venv" +reportMissingImports = false diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 000000000..97462a890 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,11 @@ +argtoml +build +debugpy +jo3util +nbclassic +notebook +pyright +twine +typeguard +git+https://github.com/kiyoon/jupynium.nvim@v0.2.1 +git+https://github.com/JJJHolscher/jupytools diff --git a/setup.py b/setup.py new file mode 100644 index 000000000..0ca740b4a --- /dev/null +++ b/setup.py @@ -0,0 +1,3 @@ +#! /usr/bin/env python3 +from setuptools import setup +setup() diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/src/__main__.py b/src/__main__.py new file mode 100644 index 000000000..9789cc129 --- /dev/null +++ b/src/__main__.py @@ -0,0 +1,7 @@ +#! /usr/bin/env python3 +# vim:fenc=utf-8 + +""" + +""" + diff --git a/src/tests b/src/tests new file mode 120000 index 000000000..6dd24e02b --- /dev/null +++ b/src/tests @@ -0,0 +1 @@ +../tests \ No newline at end of file diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 000000000..7ac262898 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1 @@ +from .test_main import * diff --git a/tests/test_main.py b/tests/test_main.py new file mode 100644 index 000000000..d672c6881 --- /dev/null +++ b/tests/test_main.py @@ -0,0 +1,24 @@ +#! /usr/bin/env python3 +# vim:fenc=utf-8 + +""" +Example asserts: + +self.assertEqual(code(), 'Hello World!') +self.assertTrue(code()) +self.assertFalse(code()) +with self.assertRaises(TypeError): + code() +""" + +import unittest + +from src.__main__ import * + + +class TestMain(unittest.TestCase): + def test_main(self): + self.assertEqual(UNITTESTS(), 0) + +if __name__ == "__main__": + unittest.main()