Contribute#

Overall guidance on contributing to a PyAnsys library appears in the Contributing topic in the PyAnsys developer’s guide. Ensure that you are thoroughly familiar with this guide before attempting to contribute to PyAdditive.

The following contribution information is specific to PyAdditive-Widgets.

Install in developer mode#

Installing PyAdditive-Widgets in developer mode allows you to modify and enhance the source.

Note

For information on required Ansys products and Python packages, see Prerequisites and Package dependencies.

Perform these steps to install PyAdditive-Widgets in developer mode:

  1. Clone the repository:

    git clone https://github.com/ansys/pyadditive-widgets
    
  2. Create a fresh-clean Python virtual environment and activate it:

    # 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. Make sure that you have the latest required build system and documentation, testing, and CI tools:

    python -m pip install -U pip flit tox
    python -m pip install -e .[doc,tests]
    
  4. Install the project in editable mode:

    python -m pip install --editable ansys-additive-widgets
    
  5. Verify your development installation:

    tox
    

Test#

This project takes advantage of tox. Similar to Makefile, this tool allows you to automate common development tasks, but it is oriented towards Python development.

Use tox#

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

The following environments 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 the documentation-building process.

Perform raw testing#

If required, you can always call code style commands, such as Black, isort, and Flake8, or unit testing tools, such as pytest, from the command line. However, using these tools do not guarantee that your project is being tested in an isolated environment, which is the reason why a tool like tox exists.

Run style checks#

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

Adhere to code style#

PyAdditive follows the PEP8 standard as indicated in PEP 8 in the PyAnsys developer’s guide. It also implements style checking using pre-commit.

To ensure your code meets minimum code styling standards, run these commands:

pip install pre-commit
pre-commit run --all-files

You can also install this as a Git pre-commit hook by running this command:

pre-commit install

This way, it’s not possible for you to push code that fails the code style checks:

$ pre-commit install
$ git commit -am "added my cool feature"
black....................................................................Passed
blacken-docs.............................................................Passed
isort....................................................................Passed
flake8...................................................................Passed
docformatter.............................................................Passed
codespell................................................................Passed
pydocstyle...............................................................Passed
check for merge conflicts................................................Passed
debug statements (python)................................................Passed
check yaml...............................................................Passed
trim trailing whitespace.................................................Passed
Add License Headers......................................................Passed
Validate GitHub Workflows................................................Passed

Build documentation#

To build documentation, you can run the usual rules provided in the Sphinx Makefile with a command like this:

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

However, the recommended way of checking documentation integrity is to use a tox command like this:

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

Distribute#

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

python -m pip install -r requirements/requirements_build.txt
python -m build
python -m twine check dist/*

Post issues#

Use the PyAdditive-Widgets Issues page to report bugs and request new features. When possible, use the issue templates provided. If your issue does not fit into one of these templates, click the link for opening a blank issue.

If you have general questions about the PyAnsys ecosystem, email pyansys.core@ansys.com. If your question is specific to PyAdditive-Widgets, ask your question in an issue as described in the previous paragraph.