diff --git a/README.md b/README.md index ccd5a620..4ca6f729 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ There are 4 alternative ways to install CNApy: 1. The easiest way for any user to install CNApy is by downloading its installer, which is provided for Windows, Linux and MacOS, see [Using CNApy installer](#using-cnapy-installer) for more. 2. If you already have installed Python 3.10 (no other version) on your system, you can install CNApy simply through ```pip install cnapy``` in your console. Afterwards, you can start CNApy's GUI by running either ```cnapy``` or, if this doesn't work, ```python -m cnapy``` where "python" must call your Python 3.10 installation. -3. If you already use conda or mamba (for mamba, just change the "conda" command to "mamba"), you can create a CNApy environment named ```cnapy-1.2.5``` as follows: 1) Run ```conda create --name cnapy-1.2.5 python=3.10 pip openjdk -c conda-forge```, 2) run ```conda activate cnapy-1.2.5```, 3) run ```pip install cnapy```. Then, you can start CNApy in the cnapy-1.2.5 conda environment by running either ```cnapy``` or, if this doesn't work, ```python -m cnapy```. Note that the [cnapy conda package](https://anaconda.org/cnapy/cnapy) is currently *not* being updated due to licensing uncertainties. +3. If you already use conda or mamba (for mamba, just change the "conda" command to "mamba"), you can create a CNApy environment named ```cnapy-1.2.6``` as follows: 1) Run ```conda create --name cnapy-1.2.6 python=3.10 pip openjdk -c conda-forge```, 2) run ```conda activate cnapy-1.2.6```, 3) run ```pip install cnapy```. Then, you can start CNApy in the cnapy-1.2.6 conda environment by running either ```cnapy``` or, if this doesn't work, ```python -m cnapy```. Note that the [cnapy conda package](https://anaconda.org/cnapy/cnapy) is currently *not* being updated due to licensing uncertainties. 4. If you want to develop CNApy, follow the instruction for the cloning and setup of the CNApy repository using git and conda or mamba in section [Setup the CNApy development environment](#setup-the-cnapy-development-environment). ## Documentation and Tutorials @@ -56,18 +56,18 @@ This installer lets you create a local installation of CNApy under Windows, Linu *If you use Windows:* -- Download the Windows installer [from here](https://github.com/cnapy-org/CNApy/releases/download/v1.2.5/install_cnapy_here.bat) +- Download the Windows installer [from here](https://github.com/cnapy-org/CNApy/releases/download/v1.2.6/install_cnapy_here.bat) - Put this file into a folder where you want CNApy to be installed. - Double click on the file and let the CNApy installation run -- Afterwards, you can run CNApy by either double-clicking on the newly created CNApy desktop icon, or by double-clicking "RUN_CNApy.bat" in the newly created cnapy-1.2.5 subfolder. +- Afterwards, you can run CNApy by either double-clicking on the newly created CNApy desktop icon, or by double-clicking "RUN_CNApy.bat" in the newly created cnapy-1.2.6 subfolder. *If you use Linux or MacOS*: -- Download the Linux & MacOS installer [from here](https://github.com/cnapy-org/CNApy/releases/download/v1.2.5/install_cnapy_here.sh). +- Download the Linux & MacOS installer [from here](https://github.com/cnapy-org/CNApy/releases/download/v1.2.6/install_cnapy_here.sh). - Put this file into a folder where you want CNApy to be installed. - Make the script executable by opening your console in the folder and run ```chmod u+x ./install_cnapy_here.sh```. Alternatively, if supported on your system, right-click on the file, go the file's settings and mark it as executable. - Now, either run ```./install_cnapy_here.sh``` in your console or, if supported on your system, double-click on install_cnapy_here.sh. -- Finally, you can run CNApy by calling ```./run_cnapy.sh``` in your console (for this without another path beforehand, your console must point to the folder where run_cnapy.sh is located, e.g. if you are in the folder where install_cnapy_here.sh is located, through ```cd cnapy-1.2.5```). Alternatively, if supported by your system, double-click on "run_cnapy.sh" in the newly created cnapy-1.2.5 subfolder. +- Finally, you can run CNApy by calling ```./run_cnapy.sh``` in your console (for this without another path beforehand, your console must point to the folder where run_cnapy.sh is located, e.g. if you are in the folder where install_cnapy_here.sh is located, through ```cd cnapy-1.2.6```). Alternatively, if supported by your system, double-click on "run_cnapy.sh" in the newly created cnapy-1.2.6 subfolder. Technical side note: CNApy's installer is utilizing [micromamba](https://mamba.readthedocs.io/en/latest/installation/micromamba-installation.html). diff --git a/cnapy.py b/cnapy.py index 8d06a87d..4d8b5605 100644 --- a/cnapy.py +++ b/cnapy.py @@ -16,7 +16,6 @@ from cnapy.__main__ import main_cnapy from sys import argv -print(argv) main_cnapy( project_path=None if len(argv) < 2 else argv[1], scenario_path=None if len(argv) < 3 else argv[2], diff --git a/cnapy/__main__.py b/cnapy/__main__.py index 32abda8b..bb794d35 100644 --- a/cnapy/__main__.py +++ b/cnapy/__main__.py @@ -16,6 +16,7 @@ import os import site from jpype._jvmfinder import getDefaultJVMPath, JVMNotFoundException, JVMNotSupportedException + try: getDefaultJVMPath() except (JVMNotFoundException, JVMNotSupportedException): @@ -31,8 +32,8 @@ from cnapy.application import Application def main_cnapy( - project_path: None | str, - scenario_path: None | str, + project_path: None | str = None, + scenario_path: None | str = None, ): Application( project_path=project_path, diff --git a/cnapy/appdata.py b/cnapy/appdata.py index b674ce1a..9deead13 100644 --- a/cnapy/appdata.py +++ b/cnapy/appdata.py @@ -4,7 +4,7 @@ import gurobipy from configparser import ConfigParser import pathlib -import pkg_resources +import importlib.resources as resources from tempfile import TemporaryDirectory from typing import List, Set, Dict, Tuple from ast import literal_eval as make_tuple @@ -31,7 +31,7 @@ class AppData(QObject): def __init__(self): QObject.__init__(self) - self.version = "cnapy-1.2.5" + self.version = "cnapy-1.2.6" self.format_version = 2 self.unsaved = False self.project = ProjectData() @@ -513,8 +513,9 @@ def update_reaction_id_lists(self): # return hashlib.md5(pickle.dumps(sorted(self.scen_values.items()))).digest() def CnaMap(name): - background_svg = pkg_resources.resource_filename( - 'cnapy', 'data/default-bg.svg') + background_svg_path: str = resources.files("cnapy") / "data" / "default-bg.svg" + with resources.as_file(background_svg_path) as svg_file_path: + background_svg = str(svg_file_path) return {"name": name, "background": background_svg, "bg-size": 1, diff --git a/cnapy/gui_elements/escher_map_view.py b/cnapy/gui_elements/escher_map_view.py index a909ea54..ba87fef3 100644 --- a/cnapy/gui_elements/escher_map_view.py +++ b/cnapy/gui_elements/escher_map_view.py @@ -1,4 +1,4 @@ -from pkg_resources import resource_filename +import importlib.resources as resources import os from math import isclose from qtpy.QtCore import Signal, Slot, QUrl, QObject, Qt @@ -44,7 +44,8 @@ def __init__(self, central_widget, name: str): self.channel = QWebChannel() # reference to channel necessary on Python side for correct operation self.page().setWebChannel(self.channel) self.channel.registerObject("cnapy_bridge", self.cnapy_bridge) - self.load(QUrl.fromLocalFile(resource_filename("cnapy", r"data/escher_cnapy.html"))) + html_path = resources.files("cnapy") / "data" / "escher_cnapy.html" + self.load(QUrl.fromLocalFile(str(html_path))) self.name: str = name # map name for self.appdata.project.maps self.editing_enabled = False diff --git a/cnapy/gui_elements/map_view.py b/cnapy/gui_elements/map_view.py index 27a99556..6e1cd1af 100644 --- a/cnapy/gui_elements/map_view.py +++ b/cnapy/gui_elements/map_view.py @@ -2,7 +2,7 @@ import math from ast import literal_eval as make_tuple from math import isclose -import pkg_resources +import importlib.resources as resources from typing import Dict, Tuple from qtpy.QtCore import QMimeData, QRectF, Qt, Signal, Slot @@ -264,7 +264,8 @@ def rebuild_scene(self): self.background = None if (len(self.appdata.project.maps[self.name]["boxes"]) > 0) and self.appdata.project.maps[self.name]["background"].replace("\\", "/").endswith("/data/default-bg.svg"): - self.appdata.project.maps[self.name]["background"] = pkg_resources.resource_filename('cnapy', 'data/blank.svg') + with resources.as_file(resources.files("cnapy") / "data" / "blank.svg") as path: + self.appdata.project.maps[self.name]["background"] = str(path) self.set_background() diff --git a/cnapy/gui_elements/reactions_list.py b/cnapy/gui_elements/reactions_list.py index 063fe255..2953e213 100644 --- a/cnapy/gui_elements/reactions_list.py +++ b/cnapy/gui_elements/reactions_list.py @@ -882,7 +882,7 @@ def validate_equation(self): turn_red(self.equation) else: test_reaction.build_reaction_from_string(eqtxt) - turn_white(self.equation, self.appdata.is_in_dark_mode) + turn_white(self.equation, self.parent.appdata.is_in_dark_mode) ok = True except ValueError: turn_red(self.equation) @@ -925,7 +925,7 @@ def validate_lowerbound(self): turn_red(self.lower_bound) return False else: - turn_white(self.lower_bound, self.appdata.is_in_dark_mode) + turn_white(self.lower_bound, self.parent.appdata.is_in_dark_mode) return True def validate_upperbound(self): @@ -935,7 +935,7 @@ def validate_upperbound(self): turn_red(self.upper_bound) return False else: - turn_white(self.upper_bound, self.appdata.is_in_dark_mode) + turn_white(self.upper_bound, self.parent.appdata.is_in_dark_mode) return True def validate_coefficient(self): @@ -945,7 +945,7 @@ def validate_coefficient(self): turn_red(self.coefficent) return False else: - turn_white(self.coefficent, self.appdata.is_in_dark_mode) + turn_white(self.coefficent, self.parent.appdata.is_in_dark_mode) return True def validate_mask(self): diff --git a/docs/index.md b/docs/index.md index 9570af61..1f1f7977 100644 --- a/docs/index.md +++ b/docs/index.md @@ -61,13 +61,13 @@ Everyone is welcome to contribute to CNApy's development. [See our contribution 3. Create a conda environment with all dependencies ```sh - conda create -n cnapy-1.2.5 -c conda-forge -c cnapy cnapy=1.2.5 + conda create -n cnapy-1.2.6 -c conda-forge -c cnapy cnapy=1.2.6 ``` 4. Activate the cnapy conda environment ```sh - conda activate cnapy-1.2.5 + conda activate cnapy-1.2.6 ``` 5. Run CNApy within you activated conda environment diff --git a/installers/install_cnapy_here.bat b/installers/install_cnapy_here.bat index 79aa19f3..bc9ba287 100644 --- a/installers/install_cnapy_here.bat +++ b/installers/install_cnapy_here.bat @@ -7,7 +7,7 @@ set "psFile=install_cnapy.ps1" :: Write the PowerShell script to a file echo # Adapted from https://raw.githubusercontent.com/mamba-org/micromamba-releases/main/install.ps1 > "%psFile%" echo. >> "%psFile%" -echo $CNAPY_VERSION = "1.2.5" ^# Replace with the actual version if needed >> "%psFile%" +echo $CNAPY_VERSION = "1.2.6" ^# Replace with the actual version if needed >> "%psFile%" echo $RELEASE_URL="https://github.com/mamba-org/micromamba-releases/releases/latest/download/micromamba-win-64" >> "%psFile%" echo. >> "%psFile%" echo Write-Output "Downloading micromamba from $RELEASE_URL" >> "%psFile%" @@ -26,7 +26,7 @@ echo Move-Item -Force micromamba.exe $MAMBA_INSTALL_PATH ^| out-null >> "%psFile echo. >> "%psFile%" echo ^# Use ^& to execute the micromamba commands stored in the variable >> "%psFile%" echo ^& $MAMBA_INSTALL_PATH create -y -p "./cnapy-$CNAPY_VERSION/cnapy-environment" python=3.10 pip openjdk -r "./cnapy-$CNAPY_VERSION/" -c conda-forge >> "%psFile%" -echo Copy-Item -Path "cnapy-1.2.5/condabin/mamba.bat" -Destination "cnapy-1.2.5/condabin/micromamba.bat" >> "%psFile%" +echo Copy-Item -Path "cnapy-1.2.6/condabin/mamba.bat" -Destination "cnapy-1.2.6/condabin/micromamba.bat" >> "%psFile%" echo ^& $MAMBA_INSTALL_PATH run -p "./cnapy-$CNAPY_VERSION/cnapy-environment" -r "./cnapy-$CNAPY_VERSION/" pip install --no-cache-dir uv >> "%psFile%" echo ^& $MAMBA_INSTALL_PATH run -p "./cnapy-$CNAPY_VERSION/cnapy-environment" -r "./cnapy-$CNAPY_VERSION/" uv --no-cache pip install --no-cache-dir cnapy >> "%psFile%" echo. >> "%psFile%" @@ -68,9 +68,9 @@ if exist "%psFile%" ( :: Congratulate the user echo Congratulations! CNApy was successfully installed! - echo To run CNApy, double-click on the newly created CNApy-1.2.5 desktop icon or, - echo alternatively, double-click on the RUN_CNApy.bat file in the newly created cnapy-1.2.5 subfolder. - echo To deinstall CNApy later, simply delete the newly created cnapy-1.2.5 subfolder. + echo To run CNApy, double-click on the newly created CNApy-1.2.6 desktop icon or, + echo alternatively, double-click on the RUN_CNApy.bat file in the newly created cnapy-1.2.6 subfolder. + echo To deinstall CNApy later, simply delete the newly created cnapy-1.2.6 subfolder. pause ) else ( echo PowerShell script file not found: %psFile% diff --git a/installers/install_cnapy_here.sh b/installers/install_cnapy_here.sh index f6386ac2..d6a3674b 100755 --- a/installers/install_cnapy_here.sh +++ b/installers/install_cnapy_here.sh @@ -4,7 +4,7 @@ set -eu # CNApy version -CNAPY_VERSION="1.2.5" +CNAPY_VERSION="1.2.6" # Folders BIN_FOLDER="${BIN_FOLDER:-./cnapy-${CNAPY_VERSION}}" diff --git a/pyproject.toml b/pyproject.toml index 1f7ef32f..9923fd99 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "cnapy" -version = "1.2.5" +version = "1.2.6" authors = [ { name="Sven Thiele" }, { name="Axel von Kamp" }, @@ -27,7 +27,7 @@ dependencies = [ "pyqtwebengine>=5.15", "qtconsole==5.4", "gurobipy==11.*", - "cplex==22.1.1.2", # We use this specific version as it's the only one with support for ARM Macs + "cplex==22.1.2.0", # We use this specific version as it's currently the last one with support for ARM CPUs "numpy==1.23", "scipy==1.12", "openpyxl",