ginit
This commit is contained in:
commit
ffb976d94e
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -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.
|
12
README.md
Normal file
12
README.md
Normal file
|
@ -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|
|
||||||
|
--------------------------------------------
|
96
makefile
Normal file
96
makefile
Normal file
|
@ -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)
|
||||||
|
|
24
ml_requirements.txt
Normal file
24
ml_requirements.txt
Normal file
|
@ -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
|
48
pyproject.toml
Normal file
48
pyproject.toml
Normal file
|
@ -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
|
11
requirements.txt
Normal file
11
requirements.txt
Normal file
|
@ -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
|
3
setup.py
Normal file
3
setup.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#! /usr/bin/env python3
|
||||||
|
from setuptools import setup
|
||||||
|
setup()
|
0
src/__init__.py
Normal file
0
src/__init__.py
Normal file
7
src/__main__.py
Normal file
7
src/__main__.py
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
#! /usr/bin/env python3
|
||||||
|
# vim:fenc=utf-8
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
1
tests/__init__.py
Normal file
1
tests/__init__.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
from .test_main import *
|
24
tests/test_main.py
Normal file
24
tests/test_main.py
Normal file
|
@ -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()
|
Loading…
Reference in New Issue
Block a user