Skip to main content

A Python wrapper to create Ansys-tailored pre-commit hooks

Project description

PyAnsys Python PyPI GH-CI MIT Black pre-commit.ci status

This Ansys repository contains pre-commit hooks for different purposes. The following hooks are currently available:

  • add-license-headers: Add missing license headers to files by using REUSE . To use this hook, you must have REUSE implemented in your repository.

  • tech-review: Do a technical review of your repository according to Ansys repository requirements

How to install

The following sections provide instructions for installing the ansys-pre-commit-hooks package in two installation modes: user and developer.

For users

Before installing the package, to ensure that you have the latest version of pip, run this command:

python -m pip install -U pip

Then, to install the package, run this command:

python -m pip install ansys-pre-commit-hooks

For developers

Installing the package in developer mode allows you to modify and enhance the source code.

Before contributing to the project, ensure that you are familiar with the PyAnsys Developer’s Guide.

For a developer installation, you must follow these steps:

  1. Clone the repository with this command:

    git clone https://github.com/ansys/pre-commit-hooks
  2. Create a fresh-clean Python environment and activate it with these commands:

    # Create a virtual environment
    python -m venv .venv
    
    # Activate it in a POSIX system
    source .venv/bin/activate
    
    # Activate it in Windows CMD environment
    .venv\Scripts\activate.bat
    
    # Activate it in Windows Powershell
    .venv\Scripts\Activate.ps1
  3. Ensure that you have the latest required build system tools by running this command:

    python -m pip install -U pip flit tox twine
  4. Install the project in editable mode by running one of these commands:

    # Install the minimum requirements
    python -m pip install -e .
    
    # Install the minimum + tests requirements
    python -m pip install -e .[tests]
    
    # Install the minimum + doc requirements
    python -m pip install -e .[doc]
    
    # Install all requirements
    python -m pip install -e .[tests,doc]
  5. Verify your development installation by running this command:

    tox

How to test it

This project takes advantage of tox. This tool automates common development tasks (similar to Makefile), but it is oriented towards Python development.

Using tox

While Makefile has rules, tox has environments. In fact, tox creates its own virtual environment so that anything being tested is isolated from the project to guarantee the project’s integrity.

These environment commands are provided:

  • tox -e style: Checks for coding style quality.

  • tox -e py: Checks for unit tests.

  • tox -e py-coverage: Checks for unit testing and code coverage.

  • tox -e doc: Checks for successfully building the documentation.

Raw testing

If required, you can always call style commands, such as black, isort, and flake8, or unit testing commands, such as pytest, from the command line. However, calling these commands does not guarantee that your project is being tested in an isolated environment, which is the reason why tools like tox exist.

A note on pre-commit

The style checks take advantage of pre-commit. Developers are not forced but encouraged to install this tool by running this command:

python -m pip install pre-commit && pre-commit install

Documentation

For building documentation, you can run the usual rules provided in the Sphinx Makefile with a command that is formatted like this:

make -C doc/ html && your_browser_name doc/html/index.html

However, the recommended way of checking documentation integrity is by running tox with a command that is formatted like this:

tox -e doc && your_browser_name .tox/doc_out/index.html

Distributing

If you would like to create either source or wheel files, install the building requirements and then execute the build module with these commands:

python -m pip install .
python -m build
python -m twine check dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ansys_pre_commit_hooks-0.5.2.tar.gz (54.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ansys_pre_commit_hooks-0.5.2-py3-none-any.whl (49.8 kB view details)

Uploaded Python 3

File details

Details for the file ansys_pre_commit_hooks-0.5.2.tar.gz.

File metadata

  • Download URL: ansys_pre_commit_hooks-0.5.2.tar.gz
  • Upload date:
  • Size: 54.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for ansys_pre_commit_hooks-0.5.2.tar.gz
Algorithm Hash digest
SHA256 b85bce81d43985d84099c4d9a17869b1c4cde626ba8622c72b429d109330d3fc
MD5 bdb362659d6f23f5dd5eee31f40fd164
BLAKE2b-256 2790691f48d5f76f5d04f42bd8f12729899cbd61ceaba59084535db8561ccae1

See more details on using hashes here.

File details

Details for the file ansys_pre_commit_hooks-0.5.2-py3-none-any.whl.

File metadata

File hashes

Hashes for ansys_pre_commit_hooks-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8c53b119b0d5f7f6e74991d551702d6bd49ebde10b715d764993f561f1769027
MD5 2147819220c70fb4b920d89c36c4a31e
BLAKE2b-256 3fc3c084b979d24aaa19892fd6718afa53a4c16a3230dd3cd4df484b82cbba0b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page