-
Notifications
You must be signed in to change notification settings - Fork 6
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
Changes from all commits
cf4d0f9
85899f4
531de20
1f61684
b9ed900
82dcfd9
e2c9606
ddcabd2
fad5312
eb510e7
dffd049
07bd40e
cd05210
9c34f70
1d802f8
6786b64
601b456
d6cb772
f53e676
cb7b55b
ea8ec2c
f77e700
afe6c78
a643ac4
bb04028
a067642
a0e1268
92c76ce
609cf9a
4fe01b8
b2246f1
d8e9654
42e6574
ca61bea
2efdeb6
a4c3790
55af4ba
7cb6225
1a02de5
b796a9a
df27b63
ccbae1e
d454c68
d1951e4
fba79d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
# 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', './')], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Before we had this: 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={}, | ||
|
@@ -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, | ||
[], | ||
|
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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={}, | ||
|
@@ -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, | ||
[], | ||
|
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)) |
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: so we need