From 38c5e18b94c1f2f506b89cfa582b4aba80fe48d7 Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Mon, 5 Aug 2024 14:32:56 -0500 Subject: Add python and a bunch of documentation Signed-off-by: Matt Strapp --- .github/workflows/cmake.yml | 4 +- .github/workflows/go.yml | 3 +- .github/workflows/python.yml | 28 +++++++ .github/workflows/rust.yml | 8 +- .gitignore | 164 +++++++++++++++++++++++++++++++++++++++ .vscode/settings.json | 10 ++- CMakeLists.txt | 9 ++- README.md | 43 +--------- docs/C.md | 4 +- docs/Go.md | 26 +++++++ docs/Python.md | 26 +++++++ docs/Rust.md | 29 +++++++ include/locusts.h | 4 +- pyproject.toml | 3 + src/lib.rs | 13 +++- src/locusts-r-us/__init__.py | 0 src/locusts-r-us/locusts.py | 6 ++ src/locusts-r-us/test_locusts.py | 9 +++ 18 files changed, 334 insertions(+), 55 deletions(-) create mode 100644 .github/workflows/python.yml create mode 100644 docs/Go.md create mode 100644 docs/Python.md create mode 100644 docs/Rust.md create mode 100644 pyproject.toml create mode 100644 src/locusts-r-us/__init__.py create mode 100644 src/locusts-r-us/locusts.py create mode 100644 src/locusts-r-us/test_locusts.py diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 37f112f..66eceac 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -13,7 +13,7 @@ on: jobs: cmake: name: CMake Builds - runs-on: $ {{ matrix.os }} + runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: @@ -25,3 +25,5 @@ jobs: run: cmake -B build -S . - name: Build run: cmake --build build + - name: Test + run: ctest --test-dir build --output-on-failure diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index b415085..81c96b8 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -14,8 +14,9 @@ jobs: build: runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v2 - name: Set up Go diff --git a/.github/workflows/python.yml b/.github/workflows/python.yml new file mode 100644 index 0000000..a353559 --- /dev/null +++ b/.github/workflows/python.yml @@ -0,0 +1,28 @@ +name: Python + +on: + push: + paths: + - '**.py' + - 'pyproject.toml' + pull_request: + paths: + - '**.py' + - 'pyproject.toml' + +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + steps: + - name: Checkout repository + uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: '3.x' + - name: Test + run: python -m unittest discover -s src/locusts-r-us \ No newline at end of file diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 712eb10..833f2c8 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -3,12 +3,12 @@ name: Rust on: push: paths: - - "**.c" - - "**.h" + - "**.rs" + - "Cargo.**" pull_request: paths: - - "**.c" - - "**.h" + - "**.rs" + - "Cargo.**" jobs: rust: diff --git a/.gitignore b/.gitignore index 0e9d14a..8a3bbbc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +dist/ + # Prerequisites *.d @@ -138,3 +140,165 @@ go.work.sum # Added by cargo /target +# 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/latest/usage/project/#working-with-version-control +.pdm.toml +.pdm-python +.pdm-build/ + +# 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/ diff --git a/.vscode/settings.json b/.vscode/settings.json index 7082e0e..dae50b0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,11 @@ { - "mesonbuild.configureOnOpen": true + "python.testing.unittestArgs": [ + "-v", + "-s", + "./src/locusts-r-us", + "-p", + "test_*.py" + ], + "python.testing.pytestEnabled": false, + "python.testing.unittestEnabled": true } \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index e5e8927..6442c4f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,4 +33,11 @@ install( LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} -) \ No newline at end of file +) + +add_executable(test_locusts tests/test_locusts.c) +target_link_libraries(test_locusts PRIVATE ocusts) + +enable_testing() + +add_test(NAME test_locusts COMMAND test_locusts) \ No newline at end of file diff --git a/README.md b/README.md index 7865ba5..210a8c5 100644 --- a/README.md +++ b/README.md @@ -1,42 +1,3 @@ -# liboCusts +# Locusts: A universal library -## Description -liboCusts is a library that provides a way to introduce locusts into your code. - -Why would you want to do that? I don't know. - -## Example -```c -#include "locusts.h" -int main(void) { - introduce_locusts(); - /* Locusts are now in your codebase! */ - return 0; -} -``` - -## Building -Multiple build systems are supported. - -### Meson -```sh -meson setup builddir --buildtype=release -meson compile -C builddir -``` - -### CMake -```sh -cmake -S . -B build -cmake --build build -``` - -### Autoconf -```sh -autoreconf -fi -./configure -make -``` - - -## License -This project is licensed under the BSD Zero Clause License. See the [LICENSE](LICENSE) file for details. \ No newline at end of file +We here at Locusts-R-Us have developed a series of libraries for all sorts of programming languages to introduce locusts in all sorts of codebases. \ No newline at end of file diff --git a/docs/C.md b/docs/C.md index c5e2094..27ea047 100644 --- a/docs/C.md +++ b/docs/C.md @@ -37,7 +37,5 @@ autoreconf -fi make ``` - ## License -This project is licensed under the BSD Zero Clause License. See the [LICENSE](LICENSE) file for details. -``` +This project is licensed under the BSD Zero Clause License. See the [LICENSE](../LICENSE) file for details. \ No newline at end of file diff --git a/docs/Go.md b/docs/Go.md new file mode 100644 index 0000000..6532847 --- /dev/null +++ b/docs/Go.md @@ -0,0 +1,26 @@ +# Locusts + +## Description +Locusts is a library that provides a way to introduce locusts into your code. + +Why would you want to do that? I don't know. + +## Installation +```sh +go get github.com/locusts-r-us/locusts +``` + +## Example +```go +package main + +import "github.com/locusts-r-us/locusts" + +func main() { + locusts.IntroduceLocusts() + /* Locusts are now in your codebase! */ +} +``` + +## License +This project is licensed under the BSD Zero Clause License. See the [LICENSE](../LICENSE) file for details. \ No newline at end of file diff --git a/docs/Python.md b/docs/Python.md new file mode 100644 index 0000000..768ed33 --- /dev/null +++ b/docs/Python.md @@ -0,0 +1,26 @@ +# locusts-r-us + +## Description +locusts-r-us is a library that provides a way to introduce locusts into your code. + +Why would you want to do that? I don't know. + +## Installation +```sh +pip install locusts-r-us +``` + +## Example +```python +import locusts + +def main(): + locusts.introduce_locusts() + # Locusts are now in your codebase! + +if __name__ == "__main__": + main() +``` + +## License +This project is licensed under the BSD Zero Clause License. See the [LICENSE](../LICENSE) file for details. \ No newline at end of file diff --git a/docs/Rust.md b/docs/Rust.md new file mode 100644 index 0000000..11f232d --- /dev/null +++ b/docs/Rust.md @@ -0,0 +1,29 @@ +# locusts + +## Description +locusts is a library that provides a way to introduce locusts into your code. + +Why would you want to do that? I don't know. + +## Installation +Add this to your `Cargo.toml`: +```toml +[dependencies] +locusts = "1" +``` +or +```sh +cargo add locusts +``` + +## Example +```rust +use locusts; + +fn main() { + locusts::introduce_locusts(); + /* Locusts are now in your codebase! */ +} +``` +## License +This project is licensed under the BSD Zero Clause License. See the [LICENSE](../LICENSE) file for details. \ No newline at end of file diff --git a/include/locusts.h b/include/locusts.h index 316bfdb..1f2fdf5 100644 --- a/include/locusts.h +++ b/include/locusts.h @@ -9,8 +9,8 @@ extern "C" { /** * @brief Add locusts to your codebase. * - * NOTE: Locusts are not included in this library. - * You will have to provide your own. + * Note that locusts are not included with this package, + * you must provide your own. */ void introduce_locusts(void); diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..7fd26b9 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 4054f90..a77349a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,16 @@ #![no_std] -pub fn introduce_locusts(){} +/// Add locusts to your codebase. +/// +/// Note that locusts are not included with this package, you must provide your own. +/// +/// # Examples +/// +/// ``` +/// use locusts::introduce_locusts; +/// +/// introduce_locusts(); +/// ``` +pub fn introduce_locusts() {} #[cfg(test)] mod tests { diff --git a/src/locusts-r-us/__init__.py b/src/locusts-r-us/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/locusts-r-us/locusts.py b/src/locusts-r-us/locusts.py new file mode 100644 index 0000000..f050133 --- /dev/null +++ b/src/locusts-r-us/locusts.py @@ -0,0 +1,6 @@ +def introduce_locusts(): + """ + Introduce locusts into your codebase. + + Note that locusts are not included with this package, you must provide your own. + """ diff --git a/src/locusts-r-us/test_locusts.py b/src/locusts-r-us/test_locusts.py new file mode 100644 index 0000000..68e6df7 --- /dev/null +++ b/src/locusts-r-us/test_locusts.py @@ -0,0 +1,9 @@ +import unittest +from locusts import introduce_locusts + +class TestLocusts(unittest.TestCase): + def test_introduce_locusts(self): + self.assertIsNone(introduce_locusts()) + +if __name__ == '__main__': + unittest.main() \ No newline at end of file -- cgit v1.2.3