Package: ansys-mechanical-env
OverviewPyMechanical-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.InstallationTwo installation modes are provided: user and developer.Install in user modeBefore installing theansys-mechanical-envpackage, make sure that you
have the latest version ofpipwith this command:python-mpipinstall-UpipThen, install theansys-mechanical-envpackage with this command:python-mpipinstallansys-mechanical-envInstall in developer modeInstalling theansys-mechanical-envpackage in developer mode allows you to modify the
source and enhance it.Before contributing to the project, ensure that you are thoroughly familiar with thePyAnsys Developer’s Guide.To install theansys-mechanical-envpackage in developer mode, perform these steps:Clone the PyMechanical-Env repository with this command:gitclonehttps://github.com/ansys/pymechanical-envCreate a clean Python environment and activate it with these commands:# Create a virtual environmentpython-mvenv.venv# Activate it in a POSIX systemsource.venv/bin/activate# Activate it in Windows CMD environment.venv\Scripts\activate.bat# Activate it in Windows Powershell.venv\Scripts\Activate.ps1Make sure you have the latest required build system and documentation, testing, and CI tools
with these commands:python-mpipinstall-Upipsetuptoolstoxpython-mpipinstall-rrequirements/requirements_build.txtpython-mpipinstall-rrequirements/requirements_tests.txtInstall the project in editable mode with this command:python-mpipinstall--editableansys-mechanical-envVerify your development installation by running this command:toxBasic usageOnce theansys-mechanical-envandansys-mechanical-corepackages 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-envpythonIn the Python shell, use this code to run an embedded instance of PyMechanical:importansys.mechanical.coreaspymechanicalapp=pymechanical.App()print(app)Run all embedding tests in the PyMechanical repository with this command:xvfb-runmechanical-envpytest-membeddingHow to testThis project takes advantage oftox. This tool allows you to automate common
development tasks (similar to Makefile), but it is oriented towards Python
development.UsingtoxAs Makefile has rules,toxhas environments. In fact,toxcreates 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 testingIf 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 liketoxexist.A note on pre-commitThe style checks take advantage ofpre-commit. Developers are not forced but
encouraged to install this tool with this command:python-mpipinstallpre-commit&&pre-commitinstallDistributingIf you would like to create either source or wheel files, start by installing
the building requirements and then execute the build module:python-mpipinstall-rrequirements/requirements_build.txtpython-mbuildpython-mtwinecheckdist/*Documentation and issuesDocumentation for the latest stable release of this package can be found in this
README file.On thePyMechanical-Env Issues page,
you can create issues to report bugs and request new features. On thePyMechanical-Env Discussionspage or theDiscussions pageon the Ansys Developer portal, you
can post questions, share ideas, and get community feedback.To reach the project support team, emailpyansys.core@ansys.com.License and acknowledgmentsPyMechanical-Env is licensed under theMIT license.For more information, see the.reuse/dep5 filefile, which follows theReuse specification.PyMechanical-Env makes no commercial claim over Ansys whatsoever. This tool supportsPyMechanical, 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 theAnsys Mechanicalpage on the Ansys website.