ginit
This commit is contained in:
commit
855bb106a0
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|
|
||||||
|
--------------------------------------------
|
92
makefile
Normal file
92
makefile
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
share: $(venv) .git/refs/remotes/public
|
||||||
|
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/*
|
||||||
|
|
||||||
|
.git/refs/remotes/public:
|
||||||
|
git checkout -b main
|
||||||
|
$(eval user_name = $(shell yq ".git.github" pyproject.toml))
|
||||||
|
curl -u "$(user_name)" "https://api.github.com/user/repos" -d "{\"name\":\"$(name)\",\"private\":false}"
|
||||||
|
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)
|
||||||
|
|
43
pyproject.toml
Normal file
43
pyproject.toml
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
|
||||||
|
[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",
|
||||||
|
]
|
||||||
|
|
||||||
|
[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]
|
||||||
|
exclude = ".venv"
|
||||||
|
venvPath = "."
|
||||||
|
venv = ".venv"
|
10
requirements.txt
Normal file
10
requirements.txt
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
build
|
||||||
|
debugpy
|
||||||
|
ipython
|
||||||
|
jupytext
|
||||||
|
matplotlib-backend-kitty
|
||||||
|
numpy
|
||||||
|
pandas
|
||||||
|
pyright
|
||||||
|
result
|
||||||
|
twine
|
3
setup.py
Normal file
3
setup.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#! /usr/bin/env python3
|
||||||
|
from setuptools import setup
|
||||||
|
setup()
|
3
src/__init__.py
Normal file
3
src/__init__.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#! /usr/bin/env python3
|
||||||
|
# Remove this file if you don't have a main.py.
|
||||||
|
from .main import *
|
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 *
|
14
tests/test_main.py
Normal file
14
tests/test_main.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#! /usr/bin/env python3
|
||||||
|
# vim:fenc=utf-8
|
||||||
|
|
||||||
|
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