This Python package provides the core Python RPC-JSON interface for Motor-CAD.
PyMotorCAD has two installation modes: user and developer.
Before installing PyMotorCAD in user mode, run this command to esure that you have the latest version of pip:
python -m pip install -U pip
Then, run this command to install PyMotorCAD:
python -m pip install ansys-motorcad-core
Installing PyMotorCAD in developer mode allows you to modify the source and enhance it.
Note
Before contributing to this project, ensure that you are familiar with all guidelines in the PyAnsys Developer's Guide.
To install in developer mode, complete these steps:
Clone the
pymotorcad
repository with this command:git clone https://github.com/ansys/pymotorcad
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
Ensure that you have the latest required build system and documentation, testing, and CI tools with this command:
python -m pip install -U pip tox
Install the project in editable mode with this command:
python -m pip install --editable ansys-motorcad-core
Verify your development installation with this command:
tox
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.
While Makefile has rules, tox
has environments. In fact, tox
creates
its own virtual environment to guarantee the project's integrity by isolating
anything being tested.
Here are commands for running various checks in the tox
environment:
- 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.
If required, you can call style commands, including black, isort, and flake8 or unit testing commands like`pytest`_ from the command line. However, using these commands does not guarantee that your project is being tested in an isolated environment, which is why tools like tox exist.
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
To build documentation, you can run the usual rules provided in the Sphinx Makefile with a command like this:
make -C doc/ html && your_browser_name doc/html/index.html
However, the recommended way of checking documentation integrity is to use
this tox
command:
tox -e doc && your_browser_name .tox/doc_out/index.html
For more information, see the Documentation page in the PyMotorCAD documentation.
If you would like to create either source or wheel files, run the following code to install the building requirements and execute the build module:
python -m pip install -U pip
python -m build
python -m twine check dist/*