From 20af652d0cd346c02989b1358db25db1e1ec5afc Mon Sep 17 00:00:00 2001 From: Minkyu Choi <142529016+minkyu-choi07@users.noreply.github.com> Date: Sun, 17 Dec 2023 07:32:26 +0900 Subject: [PATCH] Initial commit --- .github/workflows/ruff.yml | 17 ++ .gitignore | 163 ++++++++++++++++++ .ruff.toml | 58 +++++++ LICENSE | 21 +++ README.md | 23 +++ example.py | 7 + pyproject.toml | 48 ++++++ tests/__init__.py | 1 + tests/subpackage_name/__init__.py | 1 + .../test_subpackage_module_name.py | 1 + tests/test_module_name.py | 1 + your_project_name/__init__.py | 2 + your_project_name/module_name.py | 0 your_project_name/subpackage_name/__init__.py | 1 + .../subpackage_name/subpackage_module_name.py | 1 + 15 files changed, 345 insertions(+) create mode 100644 .github/workflows/ruff.yml create mode 100644 .gitignore create mode 100644 .ruff.toml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 example.py create mode 100644 pyproject.toml create mode 100644 tests/__init__.py create mode 100644 tests/subpackage_name/__init__.py create mode 100644 tests/subpackage_name/test_subpackage_module_name.py create mode 100644 tests/test_module_name.py create mode 100644 your_project_name/__init__.py create mode 100644 your_project_name/module_name.py create mode 100644 your_project_name/subpackage_name/__init__.py create mode 100644 your_project_name/subpackage_name/subpackage_module_name.py diff --git a/.github/workflows/ruff.yml b/.github/workflows/ruff.yml new file mode 100644 index 0000000..8442cb1 --- /dev/null +++ b/.github/workflows/ruff.yml @@ -0,0 +1,17 @@ +name: Ruff +on: [ push, pull_request ] + +jobs: + ruff: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v4 + with: + python-version: "3.9" + - uses: chartboost/ruff-action@v1 + with: + config: .ruff.toml + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: 'style fixes by ruff' diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d1c340c --- /dev/null +++ b/.gitignore @@ -0,0 +1,163 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ + +# VS Code +.vscode diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 0000000..8545534 --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,58 @@ +# Exclude a variety of commonly ignored directories. +exclude = [ + ".bzr", + ".direnv", + ".eggs", + ".git", + ".git-rewrite", + ".hg", + ".mypy_cache", + ".nox", + ".pants.d", + ".pytype", + ".ruff_cache", + ".svn", + ".tox", + ".venv", + "__pypackages__", + "_build", + "buck-out", + "build", + "dist", + "node_modules", + "venv", +] + +# Same as Black. +line-length = 80 +indent-width = 4 + +# Assume Python 3.9 +target-version = "py39" + +[lint] +# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default. +# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or +# McCabe complexity (`C901`) by default. +select = ["E4", "E7", "E9", "F"] +ignore = [] + +# Allow fix for all enabled rules (when `--fix`) is provided. +fixable = ["ALL"] +unfixable = [] + +# Allow unused variables when underscore-prefixed. +dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" + +[format] +# Like Black, use double quotes for strings. +quote-style = "double" + +# Like Black, indent with spaces, rather than tabs. +indent-style = "space" + +# Like Black, respect magic trailing commas. +skip-magic-trailing-comma = false + +# Like Black, automatically detect the appropriate line ending. +line-ending = "auto" \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7dc8d97 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 UTAustin-SwarmLab + +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..73a2bc9 --- /dev/null +++ b/README.md @@ -0,0 +1,23 @@ +# Python-Project-Template + +This is a template repository. Please initialize your python project using this template. + +1. Make sure you have a right python version installed locally and change the version of python from the files below + - `.github/workflows/ruff.yml` + - `pyproject.toml` + +2. `your_project_name` is your project package name including src. + +3. Development + ``` + python -m venv .venv + source .venv/bin/activate + python -m pip install --upgrade pip build + python -m pip install --editable ."[dev, test]" + ``` + +5. If you want to build a project + ``` + python -m build + ``` + diff --git a/example.py b/example.py new file mode 100644 index 0000000..1351862 --- /dev/null +++ b/example.py @@ -0,0 +1,7 @@ +def main(): + """Provide example code to run your code / application.""" + print("You're all set") + + +if __name__ == "__main__": + main() diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..c6a0596 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,48 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +[project] +name = "your_project_name" +version = "0.0.1" +authors = [ + { name="Example Author", email="author@example.com" }, +] +description = "A small example package" +readme = "README.md" +requires-python = ">=3.9" +classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", +] +dependencies = [ + "numpy==1.22.0", + "pandas" +] + +[project.urls] +"Homepage" = "https://github.com/UTAustin-SwarmLab/Python-Project-Template" +"Bug Tracker" = "https://github.com/UTAustin-SwarmLab/Python-Project-Template/issues" + +[project.optional-dependencies] +dev = ["black", "ruff", "mypy"] +test = ["pytest", "pytest-cov", "pytest-mock"] + +[tool.black] +line-length = 80 + +[tool.ruff] +select = [ + "E", # pycodestyle + "F", # pyflakes + "UP", # pyupgrade + "D", # pydocstyle +] + +[tool.ruff.pydocstyle] +convention = "google" + +ignore = ["ANN101", "ANN102"] + +extend-exclude = [".venv", "venv", "vscode"] diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..b89b4ee --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1 @@ +"""Package containing your_project name.""" diff --git a/tests/subpackage_name/__init__.py b/tests/subpackage_name/__init__.py new file mode 100644 index 0000000..b89b4ee --- /dev/null +++ b/tests/subpackage_name/__init__.py @@ -0,0 +1 @@ +"""Package containing your_project name.""" diff --git a/tests/subpackage_name/test_subpackage_module_name.py b/tests/subpackage_name/test_subpackage_module_name.py new file mode 100644 index 0000000..5ff819f --- /dev/null +++ b/tests/subpackage_name/test_subpackage_module_name.py @@ -0,0 +1 @@ +"""test script of subpackage module.""" diff --git a/tests/test_module_name.py b/tests/test_module_name.py new file mode 100644 index 0000000..5ca1a9f --- /dev/null +++ b/tests/test_module_name.py @@ -0,0 +1 @@ +"""test script of module.""" diff --git a/your_project_name/__init__.py b/your_project_name/__init__.py new file mode 100644 index 0000000..0fa30eb --- /dev/null +++ b/your_project_name/__init__.py @@ -0,0 +1,2 @@ +"""Package containing your_project name.""" +__version__ = "0.0.1" diff --git a/your_project_name/module_name.py b/your_project_name/module_name.py new file mode 100644 index 0000000..e69de29 diff --git a/your_project_name/subpackage_name/__init__.py b/your_project_name/subpackage_name/__init__.py new file mode 100644 index 0000000..b89b4ee --- /dev/null +++ b/your_project_name/subpackage_name/__init__.py @@ -0,0 +1 @@ +"""Package containing your_project name.""" diff --git a/your_project_name/subpackage_name/subpackage_module_name.py b/your_project_name/subpackage_name/subpackage_module_name.py new file mode 100644 index 0000000..79f8c14 --- /dev/null +++ b/your_project_name/subpackage_name/subpackage_module_name.py @@ -0,0 +1 @@ +"""subpackage module."""