The aedt_compat.py module#
Summary#
Raised when the process already loaded another AEDT version’s gRPC client. |
Normalize an AEDT version to the |
|
Validate an |
|
Map an |
|
Make |
|
Fix |
|
Apply the version fixes to this process. |
Environment variable forwarding |
|
Description#
In-process PyAEDT version fixes applied by lane backends.
PyAEDT treats the newest installed AEDT that is not newer than its
CURRENT_STABLE_AEDT_VERSION as the default. With a newer AEDT installed,
launch_aedt without a version starts the older release, and
connect_to_aedt(port=...) can decide the port belongs to another AEDT
version and launch a new session instead of attaching. Also, once a process
loads the gRPC client of one AEDT version it can never attach to another
version ([WinError 127] The specified procedure could not be found).
install() addresses this without modifying PyAEDT:
The default version becomes the newest installed AEDT, or the one chosen with
--aedt-version.Attaching to a local port uses the version of the AEDT process on that port.
Attaching to a version the process can no longer load fails fast with an actionable message.
Module detail#
- aedt_compat.normalize_version(value: Any) str#
Normalize an AEDT version to the
YYYY.Rform.- Parameters:
- value
Any Version such as
"271","27.1","2027.1", or"2027 R1".
- value
- Returns:
strNormalized version, for example
"2027.1".
- Raises:
ValueErrorIf
valueis not a recognized AEDT version.
- aedt_compat.validate_preference(value: str) str#
Validate an
--aedt-versionvalue.- Parameters:
- value
str "latest","pyaedt", or an AEDT version.
- value
- Returns:
strNormalized preference.
- Raises:
ValueErrorIf
valueis not a valid preference.
- aedt_compat.resolve_default_version(preference: str, installed: collections.abc.Iterable[str]) str | None#
Map an
--aedt-versionpreference to the version to pin.- Parameters:
- Returns:
- aedt_compat.pin_default_version(version: str) None#
Make
versionthe PyAEDT default for this process.- Parameters:
- version
str Normalized AEDT version.
- version
- aedt_compat.rewrite_desktop_arguments(arguments: dict[str, Any], *, find_session: collections.abc.Callable[[int], tuple[str, bool] | None], installed: dict[str, str], loaded_plugin_dir: str | None, reusing_session: bool) list[str]#
Fix
Desktop.__init__arguments in place.- Parameters:
- arguments
dict[str,Any] Bound
Desktop.__init__arguments with defaults applied.- find_session
Callable[[int],tuple[str, bool] |None] Returns the version and student flag of the AEDT serving a port.
- installed
dict[str,str] Installed versions mapped to their installation directories.
- loaded_plugin_dir
str,optional Directory of the gRPC client already loaded by the process.
- reusing_sessionbool
Whether PyAEDT is about to return an existing session. In that case nothing is changed.
- arguments
- Returns:
- Raises:
AedtVersionClashErrorIf the target version cannot be loaded by this process.
- aedt_compat.install(preference: str | None = None) str | None#
Apply the version fixes to this process.
Calling it more than once is safe.
- Parameters:
- preference
str,optional AEDT version preference. Defaults to
VERSION_ENV, then"latest".
- preference
- Returns:
- aedt_compat.VERSION_ENV = 'ANSYS_AEDT_MCP_LANE_AEDT_VERSION'#
Environment variable forwarding
--aedt-versionto lane backends.
- aedt_compat.DEFAULT_PREFERENCE = 'latest'#
- aedt_compat.logger#