-
Notifications
You must be signed in to change notification settings - Fork 4
Melhora a obtenção das informações do sistema em que o executável foi feito. #19
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
Open
samuelveigarangel
wants to merge
6
commits into
main
Choose a base branch
from
fix/build_metadata
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fd934cc
fix script build linux
samuelveigarangel 39d3bce
Add funções para obter informações do sistema em que foi executado
samuelveigarangel 698e8d6
remove
samuelveigarangel cab6202
add testes
samuelveigarangel ca93290
- Add spec
samuelveigarangel 4c361e8
Merge branch 'fix/build_linux' of https://github.com/scieloorg/spsval…
samuelveigarangel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,63 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import platform | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| from spsvalidator import build_info | ||
|
|
||
| def _linux_distro_name() -> str: | ||
| os_release = Path("/etc/os-release") | ||
| if not os_release.is_file(): | ||
| return "Linux" | ||
|
|
||
| def get_footer_build_label(language: str, translations: dict[str, str]) -> str: | ||
| if ( | ||
| build_info.BUILD_MACOS_VERSION != "development" | ||
| and build_info.BUILD_PLATFORM == "macOS" | ||
| ): | ||
| return translations["footer_built_for_macos"].format( | ||
| version=build_info.BUILD_MACOS_VERSION | ||
| ) | ||
| runtime_platform = platform.system() | ||
| if runtime_platform == "Darwin": | ||
| values: dict[str, str] = {} | ||
| for line in os_release.read_text(encoding="utf-8").splitlines(): | ||
| if "=" not in line: | ||
| continue | ||
| key, _, value = line.partition("=") | ||
| values[key] = value.strip().strip('"') | ||
|
|
||
| return values.get("PRETTY_NAME") or values.get("NAME") or "Linux" | ||
|
|
||
|
|
||
| def _runtime_platform_label() -> str: | ||
| system = platform.system() | ||
| if system == "Darwin": | ||
| return "macOS" | ||
| if system == "Windows": | ||
| return "Windows" | ||
| if system == "Linux": | ||
| return "Linux" | ||
| return system | ||
|
|
||
|
|
||
| def _runtime_version_label() -> str: | ||
| system = platform.system() | ||
| if system == "Darwin": | ||
| mac_version = platform.mac_ver()[0] | ||
| build_number = platform.mac_ver()[2] | ||
| version_label = mac_version | ||
| if build_number: | ||
| version_label = f"{mac_version} ({build_number})" | ||
| return translations["footer_built_for_macos"].format(version=version_label) | ||
| return translations["footer_dev_build"].format(platform=runtime_platform) | ||
| return f"{mac_version} ({build_number})" | ||
| return mac_version or "unknown" | ||
|
|
||
| if system == "Windows": | ||
| version, _, build, _ = platform.win32_ver() | ||
| label = version or platform.release() | ||
| if build: | ||
| return f"{label} (build {build})" | ||
| return label or "unknown" | ||
|
|
||
| if system == "Linux": | ||
| return f"{_linux_distro_name()} (kernel {platform.release()})" | ||
|
|
||
| return platform.platform() | ||
|
|
||
|
|
||
| def get_footer_build_label(language: str, translations: dict[str, str]) -> str: | ||
| platform_label = _runtime_platform_label() | ||
| if getattr(sys, "frozen", False): | ||
| return translations["footer_built_for"].format( | ||
| platform=platform_label, | ||
| version=_runtime_version_label(), | ||
| ) | ||
| return translations["footer_dev_build"].format(platform=platform_label) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| # -*- mode: python ; coding: utf-8 -*- | ||
| import os | ||
|
|
||
| from PyInstaller.utils.hooks import collect_all, collect_data_files, copy_metadata | ||
|
|
||
| project_root = os.path.abspath(os.path.join(SPECPATH, "..", "..")) | ||
| main_script = os.path.join(project_root, "src", "spsvalidator", "main.py") | ||
| src_path = os.path.join(project_root, "src") | ||
| icon_path = os.path.join( | ||
| project_root, "src", "spsvalidator", "web", "static", "img", "icon.png" | ||
| ) | ||
|
|
||
| datas = [] | ||
| binaries = [] | ||
| hiddenimports = [ | ||
| "pkg_resources", | ||
| "requests", | ||
| "tenacity", | ||
| "langdetect", | ||
| "gi", | ||
| "gi.repository", | ||
| "gi.repository.Gtk", | ||
| "gi.repository.WebKit2", | ||
| "webview.platforms.gtk", | ||
| "webview.platforms.qt", | ||
| ] | ||
| datas += collect_data_files("packtools") | ||
| datas += collect_data_files("spsvalidator") | ||
| datas += copy_metadata("setuptools") | ||
| tmp_ret = collect_all("webview") | ||
| datas += tmp_ret[0] | ||
| binaries += tmp_ret[1] | ||
| hiddenimports += tmp_ret[2] | ||
|
|
||
| a = Analysis( | ||
| [main_script], | ||
| pathex=[src_path], | ||
| binaries=binaries, | ||
| datas=datas, | ||
| hiddenimports=hiddenimports, | ||
| hookspath=[], | ||
| hooksconfig={ | ||
| "gi": { | ||
| "icons": ["hicolor"], | ||
| "themes": [], | ||
| } | ||
| }, | ||
| runtime_hooks=[], | ||
| excludes=[ | ||
| "webview.platforms.android", | ||
| "webview.platforms.cocoa", | ||
| "webview.platforms.winforms", | ||
| "webview.platforms.edgechromium", | ||
| "black", | ||
| "pytest", | ||
| "isort", | ||
| ], | ||
| noarchive=False, | ||
| optimize=0, | ||
| ) | ||
| pyz = PYZ(a.pure) | ||
|
|
||
| exe = EXE( | ||
| pyz, | ||
| a.scripts, | ||
| a.binaries, | ||
| a.datas, | ||
| [], | ||
| name="spsvalidator", | ||
| debug=False, | ||
| bootloader_ignore_signals=False, | ||
| strip=False, | ||
| upx=True, | ||
| upx_exclude=[], | ||
| runtime_tmpdir=None, | ||
| console=False, | ||
| disable_windowed_traceback=False, | ||
| argv_emulation=False, | ||
| target_arch=None, | ||
| codesign_identity=None, | ||
| entitlements_file=None, | ||
| icon=[icon_path], | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
É realmente necessário informar o usuário sobre isso de converter para AppImage?
No futuro pode ser interessante adotarmos o AppImage para disponibilizar os executáveis.