Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

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

Overview

PyMechanical-Env contains a package, ansys-mechanical-env, that facilitates the integration of PyMechanical within a Linux environment. The package has the ability to:

  • Automatically determine the version and location of the Ansys Mechanical software.

  • Offer users the option to manually specify the version number for Mechanical.

  • Configure and set the requisite environment variables.

Installation

Two installation modes are provided: user and developer.

Install in user mode

Before installing the ansys-mechanical-env package, make sure that you have the latest version of pip with this command:

python -m pip install -U pip

Then, install the ansys-mechanical-env package with this command:

python -m pip install ansys-mechanical-env

Install in developer mode

Installing the ansys-mechanical-env package in developer mode allows you to modify the source and enhance it.

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

To install the ansys-mechanical-env package in developer mode, perform these steps:

  1. Clone the PyMechanical-Env repository with this command:

    git clone https://github.com/ansys/pymechanical-env
  2. Create a 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. Make sure you have the latest required build system and documentation, testing, and CI tools with these commands:

    python -m pip install -U pip setuptools tox
    python -m pip install -r requirements/requirements_build.txt
    python -m pip install -r requirements/requirements_tests.txt
  4. Install the project in editable mode with this command:

    python -m pip install --editable ansys-mechanical-env
  5. Verify your development installation by running this command:

    tox

Basic usage

Once the ansys-mechanical-env and ansys-mechanical-core packages are installed, you can run the PyMechanical-Env command-line tool to launch and test embedded instances of PyMechanical on Linux.

Launching a Python shell containing environment variables set up by PyMechanical-Env allows you to run embedded instances of PyMechanical on Linux.

Launch the Python shell with this command:

mechanical-env python

In the Python shell, use this code to run an embedded instance of PyMechanical:

import ansys.mechanical.core as pymechanical
app = pymechanical.App()
print(app)

Run all embedding tests in the PyMechanical repository with this command:

xvfb-run mechanical-env pytest -m embedding

How to test

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

Using tox

As Makefile has rules, tox has environments. In fact, tox creates its own virtual environment so 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.

Raw testing

If required, you can always call the style commands (black, isort, flake8…) or unit testing ones (pytest) from the command line. However, this 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 with this command:

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

Distributing

If you would like to create either source or wheel files, start by installing the building requirements and then execute the build module:

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

Documentation and issues

Documentation for the latest stable release of this package can be found in this README file.

On the PyMechanical-Env Issues page, you can create issues to report bugs and request new features. On the PyMechanical-Env Discussions page or the Discussions page on the Ansys Developer portal, you can post questions, share ideas, and get community feedback.

To reach the project support team, email pyansys.core@ansys.com.

License and acknowledgments

PyMechanical-Env is licensed under the MIT license.

For more information, see the .reuse/dep5 file file, which follows the Reuse specification.

PyMechanical-Env makes no commercial claim over Ansys whatsoever. This tool supports PyMechanical, which extends the functionality of Ansys Mechanical by adding a Python interface to the Mechanical service without changing the core behavior or license of the original software. The use of PyMechanical with an embedded or remote instance of the Mechanical application requires a legally licensed local copy of Ansys.

For more information on the Mechanical application, see the Ansys Mechanical page on the Ansys website.

Release files for ansys-mechanical-env 0.1.17

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ansys-mechanical-env 0.1.17
File Size Uploaded
ansys_mechanical_env-0.1.17.tar.gz 14.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ansys-mechanical-env 0.1.17
File Interpreter ABI Platform
ansys_mechanical_env-0.1.17-py3-none-any.whl Python 3 none any Details

Total release size: 29.1 kB

Release files / ansys_mechanical_env-0.1.17.tar.gz

Download URL ansys_mechanical_env-0.1.17.tar.gz
Size 14.7 kB
Tags Source
SHA-256 checksum
How to use checksums
65f052b4450ace3b01703ea34a134084d25657102d192eb8e14d15f384871cd4
BLAKE2b-256 checksum
How to use checksums
0c89b84c35ddb8904c1fba11e66e5543c4d89f212fb446da7c59ddce94c8a7f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13

Release files / ansys_mechanical_env-0.1.17-py3-none-any.whl

Download URL ansys_mechanical_env-0.1.17-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d051396a05b1d1e2fb6673632b97838ff5bec0de3f43dd7cbd5dc8bfa3c2708d
BLAKE2b-256 checksum
How to use checksums
180b38981dc2ae021a1b93b0b65df71c781e5938468b1b4ae62e2f324d2f6cf5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.13
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page