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

feature(installer): update installer version and improve desktop version launcher #2157

Merged
merged 45 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
cf4d0f9
update installer to v0.3.3
sylvlecl Sep 25, 2024
85899f4
build desktop
sylvlecl Sep 25, 2024
531de20
test fixes
sylvlecl Sep 25, 2024
1f61684
update installer
sylvlecl Sep 25, 2024
b9ed900
update installer
sylvlecl Sep 25, 2024
82dcfd9
update installer
sylvlecl Sep 25, 2024
e2c9606
update installer
sylvlecl Sep 26, 2024
ddcabd2
update installer
sylvlecl Sep 26, 2024
fad5312
fix: alembic files added as data to the package, not as script
sylvlecl Sep 27, 2024
eb510e7
fix syntax
sylvlecl Sep 27, 2024
dffd049
fix syntax
sylvlecl Sep 27, 2024
07bd40e
update installer
sylvlecl Sep 27, 2024
cd05210
update installer
sylvlecl Sep 27, 2024
9c34f70
update installer
sylvlecl Sep 27, 2024
1d802f8
update installer
sylvlecl Sep 27, 2024
6786b64
update installer
sylvlecl Sep 27, 2024
601b456
update installer
sylvlecl Sep 27, 2024
d6cb772
improve GUI code organization, add notification
sylvlecl Sep 30, 2024
f53e676
update installer
sylvlecl Sep 30, 2024
cb7b55b
try fixing systray disparition
sylvlecl Sep 30, 2024
ea8ec2c
fix: attache systray icon to application
sylvlecl Sep 30, 2024
f77e700
fix: keep system tray menu alive
sylvlecl Sep 30, 2024
afe6c78
update installer
sylvlecl Sep 30, 2024
a643ac4
fix: keep alive tray
sylvlecl Sep 30, 2024
bb04028
fix: show context menu on left click, open app on double click
sylvlecl Sep 30, 2024
a067642
fix: add a check that the server is started before trying to start it
sylvlecl Sep 30, 2024
a0e1268
feature: try more modern toast lib
sylvlecl Sep 30, 2024
92c76ce
fix: fix behaviour when server already running
sylvlecl Oct 1, 2024
609cf9a
fix: remove double click, does not work
sylvlecl Oct 1, 2024
4fe01b8
fix: update installer for v2.18 config
sylvlecl Oct 1, 2024
b2246f1
fix: update installer
sylvlecl Oct 1, 2024
d8e9654
Merge remote-tracking branch 'origin/dev' into feature/update-installer
sylvlecl Oct 1, 2024
42e6574
fix: update installer
sylvlecl Oct 2, 2024
ca61bea
fix: speedup startup when getting version
sylvlecl Oct 2, 2024
2efdeb6
fix: remove unwanted log
sylvlecl Oct 2, 2024
a4c3790
fix: update installer
sylvlecl Oct 7, 2024
55af4ba
fix: fix healthcheck URL
sylvlecl Oct 8, 2024
7cb6225
fix: update installer to not throw when target dir does not exit
sylvlecl Oct 8, 2024
1a02de5
doc: add some docstrings
sylvlecl Oct 9, 2024
b796a9a
update installer for logs
sylvlecl Oct 10, 2024
df27b63
update installer for windows proxy
sylvlecl Oct 11, 2024
ccbae1e
update installer to main branch
sylvlecl Oct 11, 2024
d454c68
Merge remote-tracking branch 'origin/dev' into feature/update-installer
sylvlecl Oct 11, 2024
d1951e4
fix: copyright headers
sylvlecl Oct 11, 2024
fba79d3
fix: revert change to deploy.yaml
sylvlecl Oct 11, 2024
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
27 changes: 17 additions & 10 deletions AntaresWebLinux.spec
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
# -*- mode: python ; coding: utf-8 -*-
from pathlib import Path
from PyInstaller.utils.hooks import collect_dynamic_libs

block_cipher = None

# We need to analyze all alembic files to be sure the migration phase works fine
migrations_dir = Path('alembic/versions')
migration_files = [str(f) for f in migrations_dir.iterdir() if f.is_file() and f.suffix == '.py']
# We need to analyze all alembic files to be sure the migration phase works fine:
# alembic loads version files by their path, so we need to add them as "data" to the package,
# but all the dependencies they use need to be included also, wo we need to perform a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: so we need

# dedicated analyse for this.
versions_dir = Path('alembic/versions')
versions_files = [str(f) for f in versions_dir.iterdir() if f.is_file() and f.suffix == '.py']
alembic_analysis = Analysis(["alembic/env.py"] + versions_files)

binaries = [('./alembic.ini', './alembic.ini')] + collect_dynamic_libs('tables')

antares_web_server_a = Analysis(['antarest/gui.py', 'alembic/env.py'] + migration_files,
antares_web_server_a = Analysis(['antarest/gui.py'],
pathex=[],
binaries=binaries,
datas=[('./resources', './resources'), ('./alembic', './alembic')],
binaries=[],
datas=[('./resources', './resources'), ('./alembic', './alembic'), ('./alembic.ini', './')],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you add ./ ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before we had this: binaries = [('./alembic.ini', './alembic.ini')] which created a folder called "alembic.ini" in which the file was placed.

Now the file is correctly placed at the root

hiddenimports=[
'cmath',
'antarest.dbmodel',
'plyer.platforms.linux',
'plyer.platforms.linux.notification',
'pythonjsonlogger.jsonlogger',
'tables',
],
hookspath=['extra-hooks'],
hooksconfig={},
Expand All @@ -29,8 +31,13 @@ antares_web_server_a = Analysis(['antarest/gui.py', 'alembic/env.py'] + migratio
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
antares_web_server_pyz = PYZ(antares_web_server_a.pure, antares_web_server_a.zipped_data,

all_python = antares_web_server_a.pure + alembic_analysis.pure
all_zipped_data = antares_web_server_a.zipped_data + alembic_analysis.zipped_data

antares_web_server_pyz = PYZ(all_python, all_zipped_data,
cipher=block_cipher)

antares_web_server_exe = EXE(antares_web_server_pyz,
antares_web_server_a.scripts,
[],
Expand Down
27 changes: 17 additions & 10 deletions AntaresWebWin.spec
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
# -*- mode: python ; coding: utf-8 -*-
from pathlib import Path
from PyInstaller.utils.hooks import collect_dynamic_libs

block_cipher = None

# We need to analyze all alembic files to be sure the migration phase works fine
migrations_dir = Path('alembic/versions')
migration_files = [str(f) for f in migrations_dir.iterdir() if f.is_file() and f.suffix == '.py']
# We need to analyze all alembic files to be sure the migration phase works fine:
# alembic loads version files by their path, so we need to add them as "data" to the package,
# but all the dependencies they use need to be included also, wo we need to perform a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same typo

# dedicated analyse for this.
versions_dir = Path('alembic/versions')
versions_files = [str(f) for f in versions_dir.iterdir() if f.is_file() and f.suffix == '.py']
alembic_analysis = Analysis(["alembic/env.py"] + versions_files)

binaries = [('./alembic.ini', './alembic.ini')] + collect_dynamic_libs('tables')

antares_web_server_a = Analysis(['antarest/gui.py', 'alembic/env.py'] + migration_files,
antares_web_server_a = Analysis(['antarest/gui.py'],
pathex=[],
binaries=binaries,
datas=[('./resources', './resources'), ('./alembic', './alembic')],
binaries=[],
datas=[('./resources', './resources'), ('./alembic', './alembic'), ('./alembic.ini', './')],
hiddenimports=[
'cmath',
'antarest.dbmodel',
'plyer.platforms.win',
'plyer.platforms.win.notification',
'pythonjsonlogger.jsonlogger',
'tables',
],
hookspath=['extra-hooks'],
hooksconfig={},
Expand All @@ -29,8 +31,13 @@ antares_web_server_a = Analysis(['antarest/gui.py', 'alembic/env.py'] + migratio
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
antares_web_server_pyz = PYZ(antares_web_server_a.pure, antares_web_server_a.zipped_data,

all_python = antares_web_server_a.pure + alembic_analysis.pure
all_zipped_data = antares_web_server_a.zipped_data + alembic_analysis.zipped_data

antares_web_server_pyz = PYZ(all_python, all_zipped_data,
cipher=block_cipher)

antares_web_server_exe = EXE(antares_web_server_pyz,
antares_web_server_a.scripts,
[],
Expand Down
101 changes: 101 additions & 0 deletions antarest/core/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Copyright (c) 2024, RTE (https://www.rte-france.com)
#
# See AUTHORS.txt
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# SPDX-License-Identifier: MPL-2.0
#
# This file is part of the Antares project.

import argparse
from pathlib import Path


class PathType:
"""file or directory path type for `argparse` parser

The `PathType` class represents a type of argument that can be used
with the `argparse` library.
This class takes three boolean arguments, `exists`, `file_ok`, and `dir_ok`,
which specify whether the path argument must exist, whether it can be a file,
and whether it can be a directory, respectively.

Example Usage::

import argparse
from antarest.main import PathType

parser = argparse.ArgumentParser()
parser.add_argument("--input", type=PathType(file_ok=True, exists=True))
args = parser.parse_args()

print(args.input)

In the above example, `PathType` is used to specify the type of the `--input`
argument for the `argparse` parser. The argument must be an existing file path.
If the given path is not an existing file, the argparse library raises an error.
The Path object representing the given path is then printed to the console.
"""

def __init__(
self,
exists: bool = False,
file_ok: bool = False,
dir_ok: bool = False,
) -> None:
if not (file_ok or dir_ok):
msg = "Either `file_ok` or `dir_ok` must be set at a minimum."
raise ValueError(msg)
self.exists = exists
self.file_ok = file_ok
self.dir_ok = dir_ok

def __call__(self, string: str) -> Path:
"""
Check whether the given string represents a valid path.

If `exists` is `False`, the method simply returns the given path.
If `exists` is True, it checks whether the path exists and whether it is
a file or a directory, depending on the values of `file_ok` and `dir_ok`.
If the path exists and is of the correct type, the method returns the path;
otherwise, it raises an :class:`argparse.ArgumentTypeError` with an
appropriate error message.

Args:
string: file or directory path

Returns:
the file or directory path

Raises
argparse.ArgumentTypeError: if the path is invalid
"""
file_path = Path(string).expanduser()
if not self.exists:
return file_path
if self.file_ok and self.dir_ok:
if file_path.exists():
return file_path
msg = f"The file or directory path does not exist: '{file_path}'"
raise argparse.ArgumentTypeError(msg)
elif self.file_ok:
if file_path.is_file():
return file_path
elif file_path.exists():
msg = f"The path is not a regular file: '{file_path}'"
else:
msg = f"The file path does not exist: '{file_path}'"
raise argparse.ArgumentTypeError(msg)
elif self.dir_ok:
if file_path.is_dir():
return file_path
elif file_path.exists():
msg = f"The path is not a directory: '{file_path}'"
else:
msg = f"The directory path does not exist: '{file_path}'"
raise argparse.ArgumentTypeError(msg)
else: # pragma: no cover
raise NotImplementedError((self.file_ok, self.dir_ok))
11 changes: 11 additions & 0 deletions antarest/desktop/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Copyright (c) 2024, RTE (https://www.rte-france.com)
#
# See AUTHORS.txt
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# SPDX-License-Identifier: MPL-2.0
#
# This file is part of the Antares project.
Loading
Loading