|
142 | 142 | To be used only with Ansys Discovery and Ansys SpaceClaim. |
143 | 143 | """ |
144 | 144 |
|
| 145 | +ANSYS_GEOMETRY_SERVICE_ROOT = "ANSYS_GEOMETRY_SERVICE_ROOT" |
| 146 | +"""Local Geometry Service install location. This is for GeometryService and CoreGeometryService.""" |
| 147 | + |
145 | 148 |
|
146 | 149 | class ProductInstance: |
147 | 150 | """``ProductInstance`` class. |
@@ -283,25 +286,35 @@ def prepare_and_start_backend( |
283 | 286 |
|
284 | 287 | port = _check_port_or_get_one(port) |
285 | 288 | installations = get_available_ansys_installations() |
286 | | - if product_version is not None: |
287 | | - try: |
288 | | - _check_version_is_available(product_version, installations) |
289 | | - except SystemError as serr: |
290 | | - # The user requested a version as a Student version... |
291 | | - # Let's negate it and try again... if this works, we override the |
292 | | - # product_version variable. |
293 | | - try: |
294 | | - _check_version_is_available(-product_version, installations) |
295 | | - except SystemError: |
296 | | - # The student version is not installed either... raise the original error. |
297 | | - raise serr |
298 | | - |
299 | | - product_version = -product_version |
| 289 | + if os.getenv(ANSYS_GEOMETRY_SERVICE_ROOT) is not None and backend_type in ( |
| 290 | + BackendType.WINDOWS_SERVICE, |
| 291 | + BackendType.LINUX_SERVICE, |
| 292 | + BackendType.CORE_WINDOWS, |
| 293 | + BackendType.CORE_LINUX, |
| 294 | + ): |
| 295 | + # If the user has set the ANSYS_GEOMETRY_SERVICE_ROOT environment variable, |
| 296 | + # we will use it as the root folder for the Geometry Service. |
| 297 | + pass |
300 | 298 | else: |
301 | | - product_version = get_latest_ansys_installation()[0] |
| 299 | + if product_version is not None: |
| 300 | + try: |
| 301 | + _check_version_is_available(product_version, installations) |
| 302 | + except SystemError as serr: |
| 303 | + # The user requested a version as a Student version... |
| 304 | + # Let's negate it and try again... if this works, we override the |
| 305 | + # product_version variable. |
| 306 | + try: |
| 307 | + _check_version_is_available(-product_version, installations) |
| 308 | + except SystemError: |
| 309 | + # The student version is not installed either... raise the original error. |
| 310 | + raise serr |
| 311 | + |
| 312 | + product_version = -product_version |
| 313 | + else: |
| 314 | + product_version = get_latest_ansys_installation()[0] |
302 | 315 |
|
303 | | - # Verify that the minimum version is installed. |
304 | | - _check_minimal_versions(product_version, specific_minimum_version) |
| 316 | + # Verify that the minimum version is installed. |
| 317 | + _check_minimal_versions(product_version, specific_minimum_version) |
305 | 318 |
|
306 | 319 | if server_logs_folder is not None: |
307 | 320 | # Verify that the user has write permissions to the folder and that it exists. |
@@ -357,17 +370,27 @@ def prepare_and_start_backend( |
357 | 370 | ) |
358 | 371 |
|
359 | 372 | elif backend_type == BackendType.WINDOWS_SERVICE: |
| 373 | + root_service_folder = os.getenv(ANSYS_GEOMETRY_SERVICE_ROOT) |
| 374 | + if root_service_folder is None: |
| 375 | + root_service_folder = Path( |
| 376 | + installations[product_version], WINDOWS_GEOMETRY_SERVICE_FOLDER |
| 377 | + ) |
| 378 | + else: |
| 379 | + root_service_folder = Path(root_service_folder) |
360 | 380 | args.append( |
361 | 381 | Path( |
362 | | - installations[product_version], |
363 | | - WINDOWS_GEOMETRY_SERVICE_FOLDER, |
| 382 | + root_service_folder, |
364 | 383 | GEOMETRY_SERVICE_EXE, |
365 | 384 | ) |
366 | 385 | ) |
367 | 386 | # This should be modified to Windows Core Service in the future |
368 | 387 | elif BackendType.is_core_service(backend_type): |
369 | 388 | # Define several Ansys Geometry Core Service folders needed |
370 | | - root_service_folder = Path(installations[product_version], CORE_GEOMETRY_SERVICE_FOLDER) |
| 389 | + root_service_folder = os.getenv(ANSYS_GEOMETRY_SERVICE_ROOT) |
| 390 | + if root_service_folder is None: |
| 391 | + root_service_folder = Path(installations[product_version], CORE_GEOMETRY_SERVICE_FOLDER) |
| 392 | + else: |
| 393 | + root_service_folder = Path(root_service_folder) |
371 | 394 | native_folder = root_service_folder / "Native" |
372 | 395 | cad_integration_folder = root_service_folder / "CADIntegration" |
373 | 396 | schema_folder = root_service_folder / "Schema" |
@@ -395,8 +418,7 @@ def prepare_and_start_backend( |
395 | 418 | # For Windows, we need to use the exe file to launch the Core Geometry Service |
396 | 419 | args.append( |
397 | 420 | Path( |
398 | | - installations[product_version], |
399 | | - CORE_GEOMETRY_SERVICE_FOLDER, |
| 421 | + root_service_folder, |
400 | 422 | CORE_GEOMETRY_SERVICE_EXE, |
401 | 423 | ) |
402 | 424 | ) |
@@ -431,8 +453,7 @@ def prepare_and_start_backend( |
431 | 453 | args.append("dotnet") |
432 | 454 | args.append( |
433 | 455 | Path( |
434 | | - installations[product_version], |
435 | | - CORE_GEOMETRY_SERVICE_FOLDER, |
| 456 | + root_service_folder, |
436 | 457 | CORE_GEOMETRY_SERVICE_EXE.replace(".exe", ".dll"), |
437 | 458 | ) |
438 | 459 | ) |
|
0 commit comments