diff --git a/.gitea/workflows/python-package.yml b/.gitea/workflows/python-package.yml index 09275ea..69f3d9e 100644 --- a/.gitea/workflows/python-package.yml +++ b/.gitea/workflows/python-package.yml @@ -1,16 +1,33 @@ +# WARNING! +# THIS IS AN AUTOGENERATED FILE! +# MANUAL CHANGES CAN AND WILL BE OVERWRITTEN! + name: Package Python on: push: tags: - 'v[0-9]+.[0-9]+.[0-9]+' - paths-ignore: ["README.md", ".gitignore", "LICENSE", "ruff.toml"] + paths-ignore: ['README.md', '.gitignore', 'LICENSE', 'CONVENTIONS.md', 'ruff.toml'] jobs: - Package: - uses: jmaa/workflows/.gitea/workflows/python-package.yaml@v6.21 - with: - REGISTRY_DOMAIN: gitfub.space - REGISTRY_ORGANIZATION: jmaa - secrets: - PIPY_REPO_USER: ${{ secrets.PIPY_REPO_USER }} - PIPY_REPO_PASS: ${{ secrets.PIPY_REPO_PASS }} + Package-Python-And-Publish: + runs-on: ubuntu-latest + container: + image: node:21-bookworm + steps: + - name: Setting up Python ${{ env.PYTHON_VERSION }} for ${{runner.arch}} ${{runner.os}} + run: | + apt-get update + apt-get install -y python3 python3-pip + - name: Check out repository code + if: success() + uses: actions/checkout@v3 + - name: Installing Python Dependencies + if: success() + run: python3 -m pip install --upgrade pip setuptools wheel build twine pytest --break-system-packages + - name: Build + if: success() + run: python3 -m build + - name: Publish + if: success() + run: python3 -m twine upload --repository-url "https://gitfub.space/api/packages/jmaa/pypi" -u ${{ secrets.PIPY_REPO_USER }} -p ${{ secrets.PIPY_REPO_PASS }} dist/* diff --git a/.gitea/workflows/python-test.yml b/.gitea/workflows/python-test.yml index 6334129..cd86450 100644 --- a/.gitea/workflows/python-test.yml +++ b/.gitea/workflows/python-test.yml @@ -1,8 +1,12 @@ +# WARNING! +# THIS IS AN AUTOGENERATED FILE! +# MANUAL CHANGES CAN AND WILL BE OVERWRITTEN! + name: Run Python tests (through Pytest) on: push: - paths-ignore: ["README.md", ".gitignore", "LICENSE", "ruff.toml"] + paths-ignore: ['README.md', '.gitignore', 'LICENSE', 'CONVENTIONS.md', 'ruff.toml'] jobs: Test: diff --git a/.gitea/workflows/python-version-check.yml b/.gitea/workflows/python-version-check.yml index b802b76..057d55c 100644 --- a/.gitea/workflows/python-version-check.yml +++ b/.gitea/workflows/python-version-check.yml @@ -1,8 +1,12 @@ +# WARNING! +# THIS IS AN AUTOGENERATED FILE! +# MANUAL CHANGES CAN AND WILL BE OVERWRITTEN! + name: Verify Python project can be installed, loaded and have version checked on: push: - paths-ignore: ["README.md", ".gitignore", "LICENSE", "ruff.toml"] + paths-ignore: ['README.md', '.gitignore', 'LICENSE', 'CONVENTIONS.md', 'ruff.toml'] jobs: Test: diff --git a/CONVENTIONS.md b/CONVENTIONS.md new file mode 100644 index 0000000..9bdf447 --- /dev/null +++ b/CONVENTIONS.md @@ -0,0 +1,36 @@ + + + + +# Conventions + +When contributing code to this project, you MUST follow the requirements +specified here. + +## Code Conventions + +When contributing code to this project, you MUST follow these principles: + +- Code should be easy to read and understand. +- Keep the code as simple as possible. Avoid unnecessary complexity. +- Use meaningful names for variables, functions, etc. Names should reveal intent. +- Functions should be small and do one thing well. They should not exceed a few lines. +- Function names should describe the action being performed. +- Only use comments when necessary, as they can become outdated. Instead, strive to make the code self-explanatory. +- When comments are used, they should add useful information that is not readily apparent from the code itself. +- Properly handle errors and exceptions to ensure the software's robustness. +- Use exceptions rather than error codes for handling errors. +- Consider security implications of the code. Implement security best practices to protect against vulnerabilities and attacks. +- Documentation should document semantics, not syntax. +- Prefer importing modules, not individual items from modules. +- Do not use f-strings in logging statements. +- Loop variables and walrus-expression-variables should be deleted when + unneeded to keep scope clean, and to avoid accidental use. + +## Testing + +When contributing test to this project, you MUST follow these principles: + +- Do not use any testing libraries other than `pytest`. +- Mocking is the root of all evil. Writing your own stubs is much more + preferable. diff --git a/LICENSE b/LICENSE index 7d3bf4b..c523464 100644 --- a/LICENSE +++ b/LICENSE @@ -1,3 +1,3 @@ -Copyright (c) 2022-2024 Jon Michael Aanes +Copyright (c) 2022-2025 Jon Michael Aanes All rights reserved. diff --git a/README.md b/README.md index 99a1193..e50eb29 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ - - - - + + + # Datagraph Library @@ -11,10 +10,11 @@ Utility for working with scheme+ld and other data-graph and semantic web formats. - ## Dependencies -All requirements can be installed easily using: +This project requires [Python](https://www.python.org/) 3.8 or newer. + +All required libraries can be installed easily using: ```bash pip install -r requirements.txt @@ -26,10 +26,32 @@ Full list of requirements: - [wikidata](https://pypi.org/project/wikidata/) +## Contributing + +Feel free to submit pull requests. Please follow the [Code Conventions](CONVENTIONS.md) when doing so. + + +### Testing + +Testing requires the [pytest](https://docs.pytest.org/en/stable/) library. + +Run tests with the following command: + +```sh +pytest test +``` + +Test coverage can be run using the [`pytest-cov`](https://pypi.org/project/pytest-cov/) extension: + +```sh +pytest --cov=datagraph test +``` + + ## License ``` -Copyright (c) 2022-2024 Jon Michael Aanes +Copyright (c) 2022-2025 Jon Michael Aanes All rights reserved. ``` diff --git a/setup.py b/setup.py index d4505b0..c0bda93 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,6 @@ -# WARNING -# -# THIS IS AN AUTOGENERATED FILE. -# -# MANUAL CHANGES CAN AND WILL BE OVERWRITTEN. +# WARNING! +# THIS IS AN AUTOGENERATED FILE! +# MANUAL CHANGES CAN AND WILL BE OVERWRITTEN! import re @@ -21,7 +19,8 @@ Utility for working with scheme+ld and other data-graph and semantic web formats def parse_version_file(text: str) -> str: - match = re.match(r'^__version__\s*=\s*(["\'])([\d\.]+)\1$', text) + text = re.sub('^#.*', '', text, flags=re.MULTILINE) + match = re.match(r'^\s*__version__\s*=\s*(["\'])([\d\.]+)\1$', text) if match is None: msg = 'Malformed _version.py file!' raise Exception(msg) @@ -52,7 +51,6 @@ setup( author='Jon Michael Aanes', author_email='jonjmaa@gmail.com', url='https://gitfub.space/Jmaa/' + PACKAGE_NAME, - packages=[PACKAGE_NAME], install_requires=REQUIREMENTS_MAIN, extras_require={ 'test': REQUIREMENTS_TEST,