TNO Intern

Commit 5a79de78 authored by Hen Brett's avatar Hen Brett 🐔
Browse files

Resolve "Package the thermogis jar with pythermogis, thus reducing the installation steps"

parent aaa2af82
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@ Run tests:
    - apt-get install -y build-essential gcc tk openjdk-17-jdk
    - export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
    - export PATH=$JAVA_HOME/bin:$PATH
    - export THERMOGIS_JAR=$CI_PROJECT_DIR/resources/thermogis_jar/thermogis-1.7.0-shaded.jar
    - pixi install
    - pixi run pytest -rx tests/
    - rm -rf /var/lib/apt/lists/*
+11 −12
Original line number Diff line number Diff line
@@ -16,29 +16,28 @@ pixi run mkdocs serve

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)*

### 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
  *(e.g. `/path/to/the/thermogis-1.7.0-shaded.jar`)*

Example .env contents:

Example `.env` contents (The specific path could be different depending on your OS, or file architecture):
```
THERMOGIS_JAR = /path/to/the/thermogis-1.7.0-shaded.jar
JAVA_HOME = C:\Program Files \Amazon Corretto\jdk17.0.0_0
```

@@ -68,7 +67,7 @@ git clone git@ci.tno.nl:ags_public/pythermogis.git
cd pythermogis
pixi install
```
(Make sure you have followed the step installing a Java17 VM and saving the ThermoGIS Jar)
(Make sure you have followed step 1 and 2: installing a Java 17 VM)

---

+12 −14
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
  *(e.g. `/path/to/the/thermogis-1.7.0-shaded.jar`)*

Example .env contents:

Example `.env` contents (The specific path could be different depending on your OS, or file architecture):
```
THERMOGIS_JAR = /path/to/the/thermogis-1.7.0-shaded.jar
JAVA_HOME = C:\Program Files \Amazon Corretto\jdk17.0.0_0
```


### 3. Import pythermogis into your own python projects

You can use pip to install the package directly from the gitlab project:
@@ -55,6 +53,6 @@ git clone git@ci.tno.nl:ags_public/pythermogis.git
cd pythermogis
pixi install
```
(Make sure you have followed the step installing a Java17 VM and saving the ThermoGIS Jar)
(Make sure you have followed step 1 and 2: installing a Java 17 VM)

---
+2 −2
Original line number Diff line number Diff line
@@ -4920,8 +4920,8 @@ packages:
  timestamp: 1740946648058
- pypi: ./
  name: pythermogis
  version: 1.2.3
  sha256: 6c8828289c71f3180f90af7d940428d8362b440e147bf8a6e533c4d28a8232d2
  version: 1.2.4
  sha256: 41970125f848a057eda9f00cac0c2046df6c0b149f67081432922484a4320b9d
  requires_dist:
  - jpype1>=1.5.2,<2
  - xarray==2024.9.0.*
+4 −1
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "pythermogis"
version = "1.2.3"
version = "1.2.4"
description = "This repository is used as a python API for the ThermoGIS Doublet simulations"
authors = [
    { name = "Hen Brett", email = "hen.brett@tno.nl" },
@@ -37,6 +37,9 @@ markers = [
[tool.setuptools]
package-dir = {"" = "src"}

[tool.setuptools.package-data]
"pythermogis" = ["thermogis_jar/*.jar"]  # Ensure all files inside 'lib/' are included

[tool.pixi.workspace]
channels = ["conda-forge"]
platforms = ["win-64", "linux-64"]
Loading