Changes for docs/install/install.md: 12 added lines, 14 removed lines.
Original line number
Diff line number
Diff line
@@ -2,33 +2,31 @@
pythermogis has been designed to be used as a python package you import into your own python projects.
It works by creating a python API access to the ThermoGIS techno-economic application, which is written in Java.
Because of this dependency you need to Install a Java 17 VM and store the ThermoGIS Jar (a Java executable file) on your computer:
Because of this dependency you need to Install a Java 17 VM.
### 1. Install Java 17 and Download the ThermoGIS JAR
### 1. Install Java 17
This package requires a Java 17 VM (we recommend using [Amazon Corretto 17](https://docs.aws.amazon.com/corretto/latest/corretto-17-ug/downloads-list.html)) and a [ThermoGIS Jar file](https://ci.tno.nl/gitlab/ags_public/pythermogis/-/blob/main/resources/thermogis_jar/thermogis-1.7.0-shaded.jar?ref_type=heads) (Version >=1.7).
This package requires a Java 17 VM (we recommend using [Amazon Corretto 17](https://docs.aws.amazon.com/corretto/latest/corretto-17-ug/downloads-list.html)).
*(You can find the JAR in this repository's resources folder: /resources/thermogis_jar.)*
*(You can find the JAR in this repository's resources folder: /resources/thermogis_jar)*
### 2. Create Required Environment Variables
### 2. Ensure JAVA_HOME is set
Create a file called ``.env`` in your project root folder.
This file should contain the following variables:
When installing the Java 17 Virtual Machine (JVM), a global environment variable _should_ have been set: `JAVA_HOME`. This stores the path to the JVM that was installed in step 1 and enables pythermogis to read the core Java code.
If, for some reason, this was not done during installation you can either set it yourself or create a ``.env`` file in your project root folder.
This `.env` file should contain the following variable:
-`JAVA_HOME`: Path to the Java 17 installation
*(e.g., on Windows: `C:\Program Files\Amazon Corretto\jdk17.0.0_0`)*
-`THERMOGIS_JAR`: Path to the ThermoGIS `.jar` file; __including__ the name of the jar file
Changes for src/pythermogis/thermogis_classes/jvm_start.py: 6 added lines, 17 removed lines.
Original line number
Diff line number
Diff line
importos
frompathlibimportPath
importjpype
importfaulthandler
fromdotenvimportload_dotenv
frompythermogis.constantsimportTHERMOGIS_JAR_PATH
load_dotenv()
defget_thermogis_jar_path()->str:
"""
From the resources directory, return the path to the ThermoGIS Jar
From within thermogis, find the thermogis-jar, return the path to the ThermoGIS Jar
"""
tg_jar=os.getenv("THERMOGIS_JAR")
iftg_jarisNone:
raiseValueError("THERMOGIS_JAR environment variable is not set in the .env file.")
thermogis_jar_path=Path(tg_jar)
ifnotthermogis_jar_path.exists():
raiseFileNotFoundError(f"Jar file not found at {thermogis_jar_path}, check that you have downloaded the ThermoGIS Jar and set the THERMOGIS_JAR environment variable.")
returnstr(thermogis_jar_path)
ifnotTHERMOGIS_JAR_PATH.exists():
raiseFileNotFoundError(f"Jar file not found at {THERMOGIS_JAR_PATH}.")
returnstr(THERMOGIS_JAR_PATH)
defstart_jvm():
@@ -28,16 +21,12 @@ def start_jvm():
This method ensures a clean startup of the jvm packaged with this repo
:return:
"""
java_home=os.getenv("JAVA_HOME")
ifjava_homeisNone:
raiseValueError("JAVA_HOME environment variable is not set in the .env file.")
ifnotjpype.isJVMStarted():
# when running pytest with jpype a "Windows fatal exception" is thrown which in reality has no affect on the outcome or performance.
# the current workaround from the jpype package is to disable the pytest faulthandler. (This will not prevent python or java errors in the test).
faulthandler.disable()
# automatically looks up the java version in JAVA_HOME