From 455bd34d3bf1eeefe436aa654d618f90fbb54342 Mon Sep 17 00:00:00 2001 From: Stefan Harmuth Date: Sat, 11 Nov 2023 15:02:27 +0100 Subject: [PATCH] build/publish pipeline --- .gitea/workflows/demo.yaml | 18 --------- .gitea/workflows/publish.yaml | 50 +++++++++++++++++++++++++ LICENSE | 6 +-- README.md | 6 +++ btree_test.py | 56 ---------------------------- pyproject.toml | 26 +++++++++++++ setup.py | 12 ------ __init__.py => src/tools/__init__.py | 0 {tools => src/tools}/aoc.py | 4 +- {tools => src/tools}/aoc_ocr.py | 0 {tools => src/tools}/coordinate.py | 8 ++-- {tools => src/tools}/daemon.py | 0 {tools => src/tools}/datafiles.py | 0 {tools => src/tools}/grid.py | 0 {tools => src/tools}/int_seq.py | 0 {tools => src/tools}/irc.py | 0 {tools => src/tools}/lists.py | 0 {tools => src/tools}/math.py | 0 {tools => src/tools}/schedule.py | 0 {tools => src/tools}/simplesocket.py | 0 {tools => src/tools}/stopwatch.py | 0 {tools => src/tools}/tools.py | 0 {tools => src/tools}/trees.py | 2 +- {tools => src/tools}/types.py | 0 tools/__init__.py | 0 25 files changed, 92 insertions(+), 96 deletions(-) delete mode 100644 .gitea/workflows/demo.yaml create mode 100644 .gitea/workflows/publish.yaml delete mode 100644 btree_test.py create mode 100644 pyproject.toml delete mode 100644 setup.py rename __init__.py => src/tools/__init__.py (100%) rename {tools => src/tools}/aoc.py (99%) rename {tools => src/tools}/aoc_ocr.py (100%) rename {tools => src/tools}/coordinate.py (98%) rename {tools => src/tools}/daemon.py (100%) rename {tools => src/tools}/datafiles.py (100%) rename {tools => src/tools}/grid.py (100%) rename {tools => src/tools}/int_seq.py (100%) rename {tools => src/tools}/irc.py (100%) rename {tools => src/tools}/lists.py (100%) rename {tools => src/tools}/math.py (100%) rename {tools => src/tools}/schedule.py (100%) rename {tools => src/tools}/simplesocket.py (100%) rename {tools => src/tools}/stopwatch.py (100%) rename {tools => src/tools}/tools.py (100%) rename {tools => src/tools}/trees.py (99%) rename {tools => src/tools}/types.py (100%) delete mode 100644 tools/__init__.py diff --git a/.gitea/workflows/demo.yaml b/.gitea/workflows/demo.yaml deleted file mode 100644 index 7a56228..0000000 --- a/.gitea/workflows/demo.yaml +++ /dev/null @@ -1,18 +0,0 @@ -name: Gitea Actions Demo -run-name: ${{ gitea.actor }} is testing out Gitea Actions πŸš€ -on: [push] -jobs: - Explore-Gitea-Actions: - runs-on: ubuntu-latest - steps: - - run: echo "πŸŽ‰ The job was automatically triggered by a ${{ gitea.event_name }} event." - - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!" - - run: echo "πŸ”Ž The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." - - name: Check out repository code - uses: actions/checkout@v3 - - run: echo "πŸ’‘ The ${{ gitea.repository }} repository has been cloned to the runner." - - run: echo "πŸ–₯️ The workflow is now ready to test your code on the runner." - - name: List files in the repository - run: | - ls ${{ gitea.workspace }} - - run: echo "🍏 This job's status is ${{ gitea.status }}." diff --git a/.gitea/workflows/publish.yaml b/.gitea/workflows/publish.yaml new file mode 100644 index 0000000..5562b1d --- /dev/null +++ b/.gitea/workflows/publish.yaml @@ -0,0 +1,50 @@ +name: Publish to PyPI +on: + push: + tags: + - "*" + +jobs: + publish: + name: Publish to PyPI + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: "3.11.2" + + - name: Setup Build Environment + run: python -m pip install --upgrade pip build + + - name: Build Package + run: python -m build + + - name: Publish Package + uses: pypa/gh-action-pypi-publish@v1 + with: + password: ${{ secrets.PYPI_API_TOKEN }} + + +#name: Gitea Actions Demo +#run-name: ${{ gitea.actor }} is testing out Gitea Actions πŸš€ +#on: [push] +#jobs: +# Explore-Gitea-Actions: +# runs-on: ubuntu-latest +# steps: +# - run: echo "πŸŽ‰ The job was automatically triggered by a ${{ gitea.event_name }} event." +# - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!" +# - run: echo "πŸ”Ž The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}." +# - name: Check out repository code +# uses: actions/checkout@v3 +# - run: echo "πŸ’‘ The ${{ gitea.repository }} repository has been cloned to the runner." +# - run: echo "πŸ–₯️ The workflow is now ready to test your code on the runner." +# - name: List files in the repository +# run: | +# ls ${{ gitea.workspace }} +# - run: echo "🍏 This job's status is ${{ gitea.status }}." +# \ No newline at end of file diff --git a/LICENSE b/LICENSE index ed96948..786d84f 100644 --- a/LICENSE +++ b/LICENSE @@ -208,8 +208,8 @@ If you develop a new program, and you want it to be of the greatest possible use To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the β€œcopyright” line and a pointer to where the full notice is found. - py-tools - Copyright (C) 2023 DF_Public + shs-tools + Copyright (C) 2023 Stefan Harmuth This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. @@ -221,7 +221,7 @@ Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - py-tools Copyright (C) 2023 DF_Public + shs-tools Copyright (C) 2023 Stefan Harmuth This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. diff --git a/README.md b/README.md index 8c7b4ab..66a1df3 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,8 @@ # py-tools +An assortment of helper functions, primarily developed for use in [Advent Of Code](https://adventofcode.com/) + +## Installation + +`pip install shs-tools` + diff --git a/btree_test.py b/btree_test.py deleted file mode 100644 index 97d5b77..0000000 --- a/btree_test.py +++ /dev/null @@ -1,56 +0,0 @@ -from heapq import heappop, heappush -from tools.trees import MinHeap, BinarySearchTree -from tools.stopwatch import StopWatch - - -s = StopWatch() -h = [] -for x in range(100_000): - heappush(h, x) -print("Heappush:", s.elapsed()) -s.reset() -while h: - heappop(h) -print("Heappop:", s.elapsed()) - -s = StopWatch() -h = MinHeap() -for x in range(100_000): - h.add(x) -print("MinHeap.add():", s.elapsed()) -s.reset() -while not h.empty(): - h.pop() -print("MinHeap.pop():", s.elapsed()) - -s = StopWatch() -b = set() -for x in range(1_000_000): - b.add(x) -print("set.add():", s.elapsed()) -s.reset() -for x in range(1_000_000): - _ = x in b -print("x in set:", s.elapsed()) - -s = StopWatch() -b = BinarySearchTree() -for x in range(1_000_000): - b.add(x) -print("AVL.add():", s.elapsed()) -s.reset() -for x in range(1_000_000): - _ = x in b -print("x in AVL:", s.elapsed()) - -print("DFS/BFS Test") -b = BinarySearchTree() -for x in range(20): - b.add(x) -b.print() -print("DFS:") -for x in b.iter_depth_first(): - print(x) -print("BFS:") -for x in b.iter_breadth_first(): - print(x) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..331da95 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,26 @@ +[build-system] +requires = ['setuptools', "wheel", "setuptools-git-versioning"] +build-backend = 'setuptools.build_meta' + +[tool.setuptools-git-versioning] +enabled = true + +[project] +dynamic = ['version'] +name = "shs-tools" +authors = [ + { name="Stefan Harmuth", email="pennywise@drock.de" }, +] +description = "An assortment of little helper functions" +readme = "README.md" +requires-python = ">=3.6" +classifiers = [ + "Programming Language :: Python :: 3", + "Development Status :: 4 - Beta", + "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", + "Operating System :: OS Independent", +] + +[project.urls] +"homepage" = "https://git.domainforge.de/public/py-tools" +"Bug Tracker" = "https://git.domainforge.de/public/py-tools/issues" \ No newline at end of file diff --git a/setup.py b/setup.py deleted file mode 100644 index e1bee02..0000000 --- a/setup.py +++ /dev/null @@ -1,12 +0,0 @@ -from setuptools import setup - -setup( - name='py-tools', - version='0.2', - packages=['tools'], - url='', - license='GPLv3', - author='Stefan Harmuth', - author_email='pennywise@drock.de', - description='Just some small tools to make life easier' -) diff --git a/__init__.py b/src/tools/__init__.py similarity index 100% rename from __init__.py rename to src/tools/__init__.py diff --git a/tools/aoc.py b/src/tools/aoc.py similarity index 99% rename from tools/aoc.py rename to src/tools/aoc.py index 31b07be..1a31117 100644 --- a/tools/aoc.py +++ b/src/tools/aoc.py @@ -6,8 +6,8 @@ import requests import time import webbrowser from bs4 import BeautifulSoup -from tools.datafiles import JSONFile -from tools.stopwatch import StopWatch +from src.tools.datafiles import JSONFile +from src.tools.stopwatch import StopWatch from typing import Any, Callable, List, Tuple, Type, Union from .tools import get_script_dir diff --git a/tools/aoc_ocr.py b/src/tools/aoc_ocr.py similarity index 100% rename from tools/aoc_ocr.py rename to src/tools/aoc_ocr.py diff --git a/tools/coordinate.py b/src/tools/coordinate.py similarity index 98% rename from tools/coordinate.py rename to src/tools/coordinate.py index 32092cc..bb96cba 100644 --- a/tools/coordinate.py +++ b/src/tools/coordinate.py @@ -278,7 +278,7 @@ class HexCoordinate(Coordinate): def __init__(self, x: int, y: int, z: int): assert (x + y + z) == 0 - super().__init__(x, y, z) + super(HexCoordinate, self).__init__(x, y, z) def get_length(self) -> int: return (abs(self.x) + abs(self.y) + abs(self.z)) // 2 @@ -321,7 +321,7 @@ class HexCoordinateF(HexCoordinate): } def __init__(self, x: int, y: int, z: int): - super().__init__(x, y, z) + super(HexCoordinateF, self).__init__(x, y, z) class Shape: @@ -393,7 +393,7 @@ class Shape: class Square(Shape): def __init__(self, top_left, bottom_right): - super().__init__(top_left, bottom_right) + super(Square, self).__init__(top_left, bottom_right) self.mode_3d = False @@ -401,4 +401,4 @@ class Cube(Shape): def __init__(self, top_left, bottom_right): if top_left.z is None or bottom_right.z is None: raise ValueError("Both Coordinates need to be 3D") - super().__init__(top_left, bottom_right) + super(Cube, self).__init__(top_left, bottom_right) diff --git a/tools/daemon.py b/src/tools/daemon.py similarity index 100% rename from tools/daemon.py rename to src/tools/daemon.py diff --git a/tools/datafiles.py b/src/tools/datafiles.py similarity index 100% rename from tools/datafiles.py rename to src/tools/datafiles.py diff --git a/tools/grid.py b/src/tools/grid.py similarity index 100% rename from tools/grid.py rename to src/tools/grid.py diff --git a/tools/int_seq.py b/src/tools/int_seq.py similarity index 100% rename from tools/int_seq.py rename to src/tools/int_seq.py diff --git a/tools/irc.py b/src/tools/irc.py similarity index 100% rename from tools/irc.py rename to src/tools/irc.py diff --git a/tools/lists.py b/src/tools/lists.py similarity index 100% rename from tools/lists.py rename to src/tools/lists.py diff --git a/tools/math.py b/src/tools/math.py similarity index 100% rename from tools/math.py rename to src/tools/math.py diff --git a/tools/schedule.py b/src/tools/schedule.py similarity index 100% rename from tools/schedule.py rename to src/tools/schedule.py diff --git a/tools/simplesocket.py b/src/tools/simplesocket.py similarity index 100% rename from tools/simplesocket.py rename to src/tools/simplesocket.py diff --git a/tools/stopwatch.py b/src/tools/stopwatch.py similarity index 100% rename from tools/stopwatch.py rename to src/tools/stopwatch.py diff --git a/tools/tools.py b/src/tools/tools.py similarity index 100% rename from tools/tools.py rename to src/tools/tools.py diff --git a/tools/trees.py b/src/tools/trees.py similarity index 99% rename from tools/trees.py rename to src/tools/trees.py index a067b74..cee8519 100644 --- a/tools/trees.py +++ b/src/tools/trees.py @@ -1,6 +1,6 @@ from dataclasses import dataclass, field from enum import Enum -from tools.lists import Queue, Stack +from src.tools.lists import Queue, Stack from typing import Any, List, Union diff --git a/tools/types.py b/src/tools/types.py similarity index 100% rename from tools/types.py rename to src/tools/types.py diff --git a/tools/__init__.py b/tools/__init__.py deleted file mode 100644 index e69de29..0000000