Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prepare the installer for AntaresWeb 2.19 #9

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ "3.8", "3.12" ]
python-version: [ "3.11", "3.12" ]
os: [ windows-latest, ubuntu-20.04, ubuntu-22.04 ]

steps:
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
fail-fast: false
matrix:
os: [ windows-latest ]
python-version: [ "3.8" ]
python-version: [ "3.11" ]

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -97,7 +97,7 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-20.04, ubuntu-22.04 ]
python-version: [ "3.8" ]
python-version: [ "3.11" ]

steps:
- uses: actions/checkout@v4
Expand Down
7 changes: 2 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "antares-web-installer"
dynamic = ["version"]
description = 'Installation application for Antares Web Desktop'
readme = "README.md"
requires-python = ">=3.8"
requires-python = ">=3.11"
license = "MIT"
keywords = ["antares", "installation", "web", "desktop", "setup", "windows", "ubuntu"]
authors = [
Expand All @@ -17,9 +17,6 @@ authors = [
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: CPython",
Expand Down Expand Up @@ -70,7 +67,7 @@ cov = [
]

[[tool.hatch.envs.all.matrix]]
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]
python = ["3.11", "3.12"]

[tool.hatch.envs.types]
dependencies = [
Expand Down
54 changes: 34 additions & 20 deletions src/antares_web_installer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,21 @@
from antares_web_installer.shortcuts import create_shortcut, get_desktop

# List of files and directories to exclude during installation
COMMON_EXCLUDED_FILES = {"config.yaml", "archives", "internal_studies", "studies", "logs", "matrices", "tmp", "*.zip"}
POSIX_EXCLUDED_FILES = COMMON_EXCLUDED_FILES | {"AntaresWebWorker"}
WINDOWS_EXCLUDED_FILES = COMMON_EXCLUDED_FILES | {"AntaresWebWorker.exe"}
EXCLUDED_FILES = POSIX_EXCLUDED_FILES if os.name == "posix" else WINDOWS_EXCLUDED_FILES
COMMON_EXCLUDED_RESOURCES = {
Path("config.yaml"),
Path("archives"),
Path("internal_studies"),
Path("studies"),
Path("logs"),
Path("matrices"),
Path("tmp"),
Path("local_workspace"),
}

POSIX_EXCLUDED_FILES = COMMON_EXCLUDED_RESOURCES | {Path("AntaresWebInstallerCLI")}
WINDOWS_EXCLUDED_FILES = COMMON_EXCLUDED_RESOURCES | {Path("AntaresWebInstaller.exe")}
EXCLUDED_ROOT_RESOURCES = POSIX_EXCLUDED_FILES if os.name == "posix" else WINDOWS_EXCLUDED_FILES


SERVER_NAMES = {"posix": "AntaresWebServer", "nt": "AntaresWebServer.exe"}
SHORTCUT_NAMES = {"posix": "AntaresWebServer.desktop", "nt": "AntaresWebServer.lnk"}
Expand Down Expand Up @@ -182,25 +193,28 @@ def copy_files(self):
write or if self.target_dir already exists.
"""
src_dir_content = list(self.source_dir.iterdir())
src_dir_content_length = len(src_dir_content)
dirs_to_copy = []
for root_dir in src_dir_content:
if root_dir.relative_to(self.source_dir) not in EXCLUDED_ROOT_RESOURCES:
dirs_to_copy.append(root_dir)
src_dir_content_length = len(dirs_to_copy)

initial_value = self.progress

for index, elt_path in enumerate(src_dir_content):
if elt_path.name not in EXCLUDED_FILES and not elt_path.name.lower().startswith("antareswebinstaller"):
logger.info(f"Copying '{elt_path}'")
try:
if elt_path.is_file():
copy2(elt_path, self.target_dir)
else:
# copy new directory
copytree(elt_path, self.target_dir.joinpath(elt_path.name), dirs_exist_ok=True)
# handle permission errors
except PermissionError as e: # pragma: no cover
relpath = elt_path.relative_to(self.source_dir).as_posix()
raise InstallError(f"Error: Cannot write '{relpath}' in {self.target_dir}: {e}")

self.update_progress(initial_value + (index + 1) * 100 / src_dir_content_length)
for index, elt_path in enumerate(dirs_to_copy):
logger.info(f"Copying '{elt_path}'")
try:
if elt_path.is_file():
copy2(elt_path, self.target_dir)
else:
# copy new directory
copytree(elt_path, self.target_dir.joinpath(elt_path.name), dirs_exist_ok=True)
# handle permission errors
except PermissionError as e: # pragma: no cover
relpath = elt_path.relative_to(self.source_dir).as_posix()
raise InstallError(f"Error: Cannot write '{relpath}' in {self.target_dir}: {e}")

self.update_progress(initial_value + (index + 1) * 100 / src_dir_content_length)
logger.info("File copy completed.")

def check_version(self) -> str:
Expand Down
21 changes: 7 additions & 14 deletions src/antares_web_installer/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,24 @@

import yaml

from .config_2_15 import update_to_2_15
from antares_web_installer.config.config_2_19 import update_to_2_19


def update_config(source_path: Path, target_path: Path, version: str) -> None:
def update_config(source_path: Path, target_config_path: Path, version: str) -> None:
"""
Update the configuration file to the latest version.

:param source_path: source configuration file.
:param target_path: target configuration file (if different from source).
:param version: the current version of the application (e.g. "2.15").
:param target_config_path: target configuration file
:param version: the current version of the application (e.g. "2.19").
"""

with source_path.open(mode="r") as f:
config = yaml.safe_load(f)

version_info = tuple(map(int, version.split(".")))
if version_info < (2, 15):
try:
update_to_2_15(config)
except AttributeError:
with target_path.open("r") as f:
config = yaml.safe_load(f)
if version_info < (2, 19):
update_to_2_19(config)

if version_info < (2, 18):
update_to_2_15(config)

with source_path.open(mode="w") as f:
with target_config_path.open(mode="w") as f:
yaml.dump(config, f)
31 changes: 0 additions & 31 deletions src/antares_web_installer/config/config_2_15.py

This file was deleted.

10 changes: 0 additions & 10 deletions src/antares_web_installer/config/config_2_18.py

This file was deleted.

14 changes: 14 additions & 0 deletions src/antares_web_installer/config/config_2_19.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import typing as t


def update_to_2_19(config: t.MutableMapping[str, t.Any]) -> None:
"""
Update the configuration file to version 2.19 in-place.

:param config: actual configuration
"""

config.setdefault("launcher", {})
if "local" in config["launcher"]:
config["launcher"]["local"]["local_workspace"] = "./local_workspace"
# Don't need to create the folder as it will be created at the local_launcher instantiation inside AntaresWeb
19 changes: 0 additions & 19 deletions tests/config/test_config_2_15.py

This file was deleted.

61 changes: 0 additions & 61 deletions tests/config/test_config_2_15/application-2.14.both.yaml

This file was deleted.

41 changes: 0 additions & 41 deletions tests/config/test_config_2_15/application-2.14.local.yaml

This file was deleted.

Loading