commit fc8cc85a04f1462355f6c71cba30d8e0f55cfde2 Author: Kevo Date: Sun Jan 23 11:14:52 2022 +0100 Initial commit diff --git a/.github/workflows/build_documentation.yml b/.github/workflows/build_documentation.yml new file mode 100644 index 0000000..4b58d1d --- /dev/null +++ b/.github/workflows/build_documentation.yml @@ -0,0 +1,38 @@ +name: Build documentation + +on: + workflow_dispatch: + release: + types: [published] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.10] + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install pdoc + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + + - name: Build docs + run: | + chmod +x ./scripts/build_documentation.sh + bash ./scripts/build_documentation.sh + + - name: Deploy + uses: JamesIves/github-pages-deploy-action@4.1.4 + with: + branch: documentation + folder: ./documentation diff --git a/.github/workflows/publish_to_pypi.yml b/.github/workflows/publish_to_pypi.yml new file mode 100644 index 0000000..4aad18f --- /dev/null +++ b/.github/workflows/publish_to_pypi.yml @@ -0,0 +1,38 @@ +name: Upload Python Package to PyPI + +on: + release: + types: [published] + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '^3.6' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + + - name: Test with pyTest + run: | + python -m pytest -v + + - name: Build package + run: | + chmod +x ./scripts/compile_for_pypi.sh + ./scripts/compile_for_pypi.sh + + - name: Publish package + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml new file mode 100644 index 0000000..89a41d9 --- /dev/null +++ b/.github/workflows/pytest.yml @@ -0,0 +1,25 @@ +name: Test with pyTest + +on: [workflow_dispatch, push, pull_request] + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '^3.6' + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install pytest + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + + - name: Test with pyTest + run: | + python -m pytest -v diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1e94e76 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +# TODO: Your editor's folder +# .vscode/ +__pycache__/ +env/ + +.pytest-cache +documentation/ + +dist/* +*.egg-info diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..9589b6d --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + "version": "0.2.0", + "configurations": [ + // Pre-made Python debugger (automatically sets `PYTHONPATH` to workspace root directory) + { + "name": "Python: Current File", + "type": "python", + "request": "launch", + "program": "${file}", + "env": { + "PYTHONPATH": "${workspaceRoot}" + }, + "console": "integratedTerminal" + } + ] +} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c0aab09 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 SKevo + +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 0000000..75f6e89 --- /dev/null +++ b/README.md @@ -0,0 +1,62 @@ +# Python project template + +A template for new Python projects. + +## Features + +- Automatically builds [PDoc](https://pdoc3.github.io/pdoc/) documentation & uploads package to [PyPI](https://pypi.org) on new GitHub release, thanks to GitHub actions; +- Tests with pyTest before uploading to PyPI (or you can test manually with `workflow-dispatch`); +- Ready-to-go `setup.py` file; +- Scripts to build documentation and compile as a Python package; +- A to-do list below; +- Possibly more ;) + +## Your to-do list + +(*Approx. time to set up:* 15 - 25 minutes) + +- [ ] Edit `# FIXME` lines to match your project; + - [ ] setup.py + - [ ] Package name + - [ ] License + - [ ] Version + - [ ] Author + - [ ] Author email + - [ ] Description + - [ ] Keywords + - [ ] Classifiers + - [ ] Repository URL +- [ ] Setup virtualenv (`scripts/setup_virtualenv_windows.ps1` for Windows); +- [ ] Rename `python_project_template` folder and start writing your source code; +- [ ] Add your dependencies to `requirements.txt`; +- [ ] Update .gitingore with your stuff; +- [ ] Replace this `README.md` file with a fancier one; +- [ ] Upload code to your GitHub repository; +- [ ] Turn on GitHub pages and use `documentation` as your pages branch; +- [ ] Add your editior to `.gitignore`; +- [ ] Add your PyPI API key to GitHub secrets (`PYPI_API_TOKEN`); +- [ ] When your are done, make a new release at GitHub to build documentation and upload to PyPI; + - Don't forget to bump version in `setup.py` everytime you do a new release!!! + +That should be it. Happy coding! + +If you have any questions or found a bug, please open a new issue in this repository. + +## 🎁 Support me + +I create free software to benefit people. +If this project helps you and you like it, consider supporting me by donating via cryptocurrency: + +- Bitcoin: `bc1q6n7f4mllak9xts355wlyq2n3rce60w2r5aswxa`; `1LMS4u41beDGMb9AXmXzfH7ZkZSwGSkSyx` +- Ethereum: `0x12C598b3bC084710507c9d6d19C9434fD26864Cc` +- Litecoin: `LgHQK1NQrRQ56AKvVtSxMubqbjSWh7DTD2` +- Dash: `Xe7TYoRCYPdZyiQYDjgzCGxR5juPWV8PgZ` +- Zcash: `t1Pesobv3SShMHGfrZWe926nsnBo2pyqN3f` +- Dogecoin: `DALxrKSbcCXz619QqLj9qKXFnTp8u2cS12` +- Ripple: `rNQsgQvMbbBAd957XyDeNudA4jLH1ANERL` +- Monero: `48TfTddnpgnKBn13MdJNJwHfxDwwGngPgL3v6bNSTwGaXveeaUWzJcMUVrbWUyDSyPDwEJVoup2gmDuskkcFuNG99zatYFS` +- Bitcoin Cash: `qzx6pqzcltm7ely24wnhpzp65r8ltrqgeuevtrsj9n` +- Ethereum Classic: `0x383Dc3B83afBD66b4a5e64511525FbFeb2C023Db` + +More cryptocurrencies are supported. If you are interested in donating with a different one, please [E-mail me](mailto:me@kevo.link). +No other forms of donation are currently supported. diff --git a/python_project_template/__init__.py b/python_project_template/__init__.py new file mode 100644 index 0000000..a72b369 --- /dev/null +++ b/python_project_template/__init__.py @@ -0,0 +1,25 @@ +from typing import Generator +from random import random as rand + + + +def infinitum(multiplier: int = 314) -> Generator[int, None, None]: + """ + Generates an infinite sequence of random numbers. + """ + + while True: + yield round(((rand() + 1) ** multiplier) % 21768543) + + + +if __name__ == "__main__": + count = 0 + max_count = 10 + + for random in infinitum(): + print(random) + count += 1 + + if count >= max_count: + break diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e079f8a --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pytest diff --git a/scripts/build_documentation.sh b/scripts/build_documentation.sh new file mode 100644 index 0000000..d518426 --- /dev/null +++ b/scripts/build_documentation.sh @@ -0,0 +1,4 @@ +cd "$(dirname "$0")" +cd ../ + +pdoc -o documentation python_project_template # FIXME diff --git a/scripts/compile_everything.sh b/scripts/compile_everything.sh new file mode 100644 index 0000000..8cdb0fd --- /dev/null +++ b/scripts/compile_everything.sh @@ -0,0 +1,4 @@ +cd "$(dirname "$0")" + +bash ./build_documentation.sh +bash ./compile_for_pypi.sh diff --git a/scripts/compile_for_pypi.sh b/scripts/compile_for_pypi.sh new file mode 100644 index 0000000..906e55d --- /dev/null +++ b/scripts/compile_for_pypi.sh @@ -0,0 +1,4 @@ +cd "$(dirname "$0")" +cd ../ + +python setup.py sdist diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..0e20bda --- /dev/null +++ b/setup.py @@ -0,0 +1,61 @@ +from pathlib import Path + +import sys +sys.path.append('.') + +import setuptools + + +__description__ = "Python Project Template" # FIXME +__author__ = "SKevo" +__copyright__ = "Copyright (c) 2021, SKevo" +__credits__ = ["SKevo"] +__license__ = "MIT" +__version__ = "v1.0.0-beta" +__maintainer__ = "SKevo" +__email__ = "me@kevo.link" +__status__ = "4 - Beta" + + +README_PATH = Path(__file__).parent.absolute() / Path('README.md') + +try: + with open(README_PATH, 'r', encoding="UTF-8") as readme: + __readme__ = readme.read() + +except: + __readme__ = "Failed to read README.md!" + +__doc__ = __readme__ + + + +setuptools.setup( + name = 'python_project_template', # FIXME + packages = setuptools.find_packages(exclude=('tests',)), + + long_description=__readme__, + long_description_content_type='text/markdown', + + version = __version__, + license = __license__, + description = __description__, + keywords = [], # FIXME + + author = __author__, + author_email = __email__, + + url = 'https://github.com/CWKevo/python-project-template', # FIXME + + install_requires=[], # FIXME + + classifiers=[ + f'Development Status :: {__status__}', + 'Intended Audience :: Developers', + 'License :: OSI Approved :: MIT License', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + ], +) diff --git a/tests/test_infinite_random_numbers.py b/tests/test_infinite_random_numbers.py new file mode 100644 index 0000000..d05d2e4 --- /dev/null +++ b/tests/test_infinite_random_numbers.py @@ -0,0 +1,12 @@ +from python_project_template import infinitum + + + +def test_infinitum(): + """ + Tests the infinite random number generator. + """ + + for random in infinitum(): + assert type(random) == int + break