PyAnsys Geometry is a Python client library for the Ansys Geometry service.
Contents
There are different ways of getting started with using the Geometry service and its client library, PyAnsys Geometry.
For more information, see Getting Started documentation.
PyAnsys Geometry has three installation modes: user, developer, and offline.
Before installing PyAnsys Geometry in user mode, make sure you have the latest version of pip with:
python -m pip install -U pip
Then, install PyAnsys Geometry with:
python -m pip install ansys-geometry-core
Installing PyAnsys Geometry in developer mode allows you to modify the source and enhance it.
Note
Before contributing to the project, ensure that you are thoroughly familiar with the PyAnsys Developer's Guide.
To install PyAnsys Geometry in developer mode, perform these steps:
Clone the
pyansys-geometry
repository:git clone https://github.com/ansys/pyansys-geometry
Access the
pyansys-geometry
directory where the repository has been cloned:cd pyansys-geometry
Create a 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
Make sure you have the latest required build system tools:
python -m pip install -U pip tox
Install the project in editable mode:
# 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]
If you lack an internet connection on your installation machine, you should install PyAnsys Geometry by downloading the wheelhouse archive from the Releases page for your corresponding machine architecture.
Each wheelhouse archive contains all the Python wheels necessary to install PyAnsys Geometry from scratch on Windows, Linux, and MacOS from Python 3.9 to 3.11. You can install this on an isolated system with a fresh Python installation or on a virtual environment.
For example, on Linux with Python 3.9, unzip the wheelhouse archive and install it with:
unzip ansys-geometry-core-v0.4.dev0-wheelhouse-ubuntu-latest-3.9.zip wheelhouse
pip install ansys-geometry-core -f wheelhouse --no-index --upgrade --ignore-installed
If you're on Windows with Python 3.9, unzip to a wheelhouse directory and install using the preceding command.
Consider installing using a virtual environment.
This project takes advantage of tox. This tool automate common development tasks (similar to Makefile), but it is oriented towards Python development.
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.
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 documentation building process.
pyvista-pytest plugin
This plugin facilitates the comparison of the images produced in PyAnsys Geometry for testing the plots. If you are changing the images, use flag
--reset_image_cache
which is not recommended except for testing or for potentially a major or minor release. For more information, see pyvista-pytest.
If required, from the command line, you can call style commands, including black, isort, and flake8, and unit testing commands like pytest. However, this does not guarantee that your project is being tested in an isolated environment, which is the reason why tools like tox exist.
The style checks take advantage of pre-commit. Developers are not forced but encouraged to install this tool with:
python -m pip install pre-commit && pre-commit install
For building documentation, you can run the usual rules provided in the Sphinx Makefile, such as:
make -C doc/ html && your_browser_name doc/html/index.html
However, the recommended way of checking documentation integrity is to use
tox
:
tox -e doc && your_browser_name .tox/doc_out/index.html
If you would like to create either source or wheel files, start by installing the building requirements and then executing the build module:
python -m pip install -U pip
python -m build
python -m twine check dist/*