mirror of
https://github.com/miurahr/aqtinstall.git
synced 2025-12-18 05:04:38 +03:00
Add build for standalone Windows binary
- Add batch script to build standalone Windows binary - Change `exit(1)` to `sys.exit(1)` throughout installer to prevent errors in standalone binaries - Add `freeze_support()` in __init__.py for standalone binary
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -2,6 +2,7 @@ build
|
|||||||
aqt/version.py
|
aqt/version.py
|
||||||
dist
|
dist
|
||||||
venv
|
venv
|
||||||
|
build_venv
|
||||||
*.pyc
|
*.pyc
|
||||||
*.egg-info
|
*.egg-info
|
||||||
__pycache__
|
__pycache__
|
||||||
@@ -13,3 +14,5 @@ ci/*.matrix.gen.yml
|
|||||||
docs/_build
|
docs/_build
|
||||||
aqtinstall.log
|
aqtinstall.log
|
||||||
Qt/
|
Qt/
|
||||||
|
.gravitybee
|
||||||
|
.eggs
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
from multiprocessing import freeze_support
|
||||||
|
|
||||||
if sys.version_info.major == 2:
|
if sys.version_info.major == 2:
|
||||||
print("aqtinstall requires python 3!")
|
print("aqtinstall requires python 3!")
|
||||||
@@ -33,5 +34,7 @@ __all__ = ["__version__"]
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
# For Windows standalone binaries, this is a noop on all other environments.
|
||||||
|
freeze_support()
|
||||||
cli = Cli()
|
cli = Cli()
|
||||||
return cli.run()
|
return cli.run()
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import platform
|
|||||||
import random
|
import random
|
||||||
import signal
|
import signal
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import sys
|
||||||
import time
|
import time
|
||||||
from logging import getLogger
|
from logging import getLogger
|
||||||
from logging.handlers import QueueHandler
|
from logging.handlers import QueueHandler
|
||||||
@@ -137,11 +138,11 @@ class Cli:
|
|||||||
else:
|
else:
|
||||||
print("Please supply a target architecture.")
|
print("Please supply a target architecture.")
|
||||||
self.show_help(args)
|
self.show_help(args)
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
if arch == "":
|
if arch == "":
|
||||||
print("Please supply a target architecture.")
|
print("Please supply a target architecture.")
|
||||||
self.show_help(args)
|
self.show_help(args)
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
return arch
|
return arch
|
||||||
|
|
||||||
def _check_mirror(self, mirror):
|
def _check_mirror(self, mirror):
|
||||||
@@ -173,7 +174,7 @@ class Cli:
|
|||||||
qt_version = args.qt_version
|
qt_version = args.qt_version
|
||||||
if not Cli._is_valid_version_str(qt_version):
|
if not Cli._is_valid_version_str(qt_version):
|
||||||
self.logger.error("Invalid version: '{}'! Please use the form '5.X.Y'.".format(qt_version))
|
self.logger.error("Invalid version: '{}'! Please use the form '5.X.Y'.".format(qt_version))
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
keep = args.keep
|
keep = args.keep
|
||||||
output_dir = args.outputdir
|
output_dir = args.outputdir
|
||||||
if output_dir is None:
|
if output_dir is None:
|
||||||
@@ -193,7 +194,7 @@ class Cli:
|
|||||||
if args.base is not None:
|
if args.base is not None:
|
||||||
if not self._check_mirror(args.base):
|
if not self._check_mirror(args.base):
|
||||||
self.show_help()
|
self.show_help()
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
base = args.base
|
base = args.base
|
||||||
else:
|
else:
|
||||||
base = Settings.baseurl
|
base = Settings.baseurl
|
||||||
@@ -201,10 +202,10 @@ class Cli:
|
|||||||
if args.noarchives:
|
if args.noarchives:
|
||||||
if modules is None:
|
if modules is None:
|
||||||
print("When specified option --no-archives, an option --modules is mandatory.")
|
print("When specified option --no-archives, an option --modules is mandatory.")
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
if archives is not None:
|
if archives is not None:
|
||||||
print("Option --archives and --no-archives are conflicted. Aborting...")
|
print("Option --archives and --no-archives are conflicted. Aborting...")
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
archives = modules
|
archives = modules
|
||||||
else:
|
else:
|
||||||
@@ -248,13 +249,13 @@ class Cli:
|
|||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
self.logger.error("Connection to the download site failed. Aborted...")
|
self.logger.error("Connection to the download site failed. Aborted...")
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
except (ArchiveDownloadError, ArchiveListError, NoPackageFound):
|
except (ArchiveDownloadError, ArchiveListError, NoPackageFound):
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
target_config = qt_archives.get_target_config()
|
target_config = qt_archives.get_target_config()
|
||||||
result = run_installer(qt_archives.get_packages(), base_dir, sevenzip, keep)
|
result = run_installer(qt_archives.get_packages(), base_dir, sevenzip, keep)
|
||||||
if not result:
|
if not result:
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
if not nopatch:
|
if not nopatch:
|
||||||
Updater.update(target_config, base_dir)
|
Updater.update(target_config, base_dir)
|
||||||
self.logger.info("Finished installation")
|
self.logger.info("Finished installation")
|
||||||
@@ -272,7 +273,7 @@ class Cli:
|
|||||||
qt_version = args.qt_version
|
qt_version = args.qt_version
|
||||||
if not Cli._is_valid_version_str(qt_version):
|
if not Cli._is_valid_version_str(qt_version):
|
||||||
self.logger.error("Invalid version: '{}'! Please use the form '5.X.Y'.".format(qt_version))
|
self.logger.error("Invalid version: '{}'! Please use the form '5.X.Y'.".format(qt_version))
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
output_dir = args.outputdir
|
output_dir = args.outputdir
|
||||||
if output_dir is None:
|
if output_dir is None:
|
||||||
base_dir = os.getcwd()
|
base_dir = os.getcwd()
|
||||||
@@ -324,21 +325,21 @@ class Cli:
|
|||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
self.logger.error("Connection to the download site failed. Aborted...")
|
self.logger.error("Connection to the download site failed. Aborted...")
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
except (ArchiveDownloadError, ArchiveListError, NoPackageFound):
|
except (ArchiveDownloadError, ArchiveListError, NoPackageFound):
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
result = run_installer(srcdocexamples_archives.get_packages(), base_dir, sevenzip, keep)
|
result = run_installer(srcdocexamples_archives.get_packages(), base_dir, sevenzip, keep)
|
||||||
if result:
|
if result:
|
||||||
self.logger.info("Finished installation")
|
self.logger.info("Finished installation")
|
||||||
else:
|
else:
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def run_install_src(self, args):
|
def run_install_src(self, args):
|
||||||
"""Run src subcommand"""
|
"""Run src subcommand"""
|
||||||
if args.kde:
|
if args.kde:
|
||||||
if args.qt_version != "5.15.2":
|
if args.qt_version != "5.15.2":
|
||||||
print("KDE patch: unsupported version!!")
|
print("KDE patch: unsupported version!!")
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
start_time = time.perf_counter()
|
start_time = time.perf_counter()
|
||||||
self._run_src_doc_examples("src", args)
|
self._run_src_doc_examples("src", args)
|
||||||
if args.kde:
|
if args.kde:
|
||||||
@@ -426,11 +427,11 @@ class Cli:
|
|||||||
)
|
)
|
||||||
except Exception:
|
except Exception:
|
||||||
self.logger.error("Connection to the download site failed. Aborted...")
|
self.logger.error("Connection to the download site failed. Aborted...")
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
except (ArchiveDownloadError, ArchiveListError, NoPackageFound):
|
except (ArchiveDownloadError, ArchiveListError, NoPackageFound):
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
if not run_installer(tool_archives.get_packages(), base_dir, sevenzip, keep):
|
if not run_installer(tool_archives.get_packages(), base_dir, sevenzip, keep):
|
||||||
exit(1)
|
sys.exit(1)
|
||||||
self.logger.info("Finished installation")
|
self.logger.info("Finished installation")
|
||||||
self.logger.info("Time elapsed: {time:.8f} second".format(time=time.perf_counter() - start_time))
|
self.logger.info("Time elapsed: {time:.8f} second".format(time=time.perf_counter() - start_time))
|
||||||
|
|
||||||
@@ -447,7 +448,7 @@ class Cli:
|
|||||||
for version_str in (args.modules, args.extensions, args.arch):
|
for version_str in (args.modules, args.extensions, args.arch):
|
||||||
if not Cli._is_valid_version_str(version_str, allow_latest=True, allow_empty=True):
|
if not Cli._is_valid_version_str(version_str, allow_latest=True, allow_empty=True):
|
||||||
self.logger.error("Invalid version: '{}'! Please use the form '5.X.Y'.".format(version_str))
|
self.logger.error("Invalid version: '{}'! Please use the form '5.X.Y'.".format(version_str))
|
||||||
exit(1) # TODO: maybe return 1 instead?
|
sys.exit(1) # TODO: maybe return 1 instead?
|
||||||
|
|
||||||
spec = None
|
spec = None
|
||||||
try:
|
try:
|
||||||
|
|||||||
8
ci/build_standalone.bat
Normal file
8
ci/build_standalone.bat
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
pip install virtualenv
|
||||||
|
virtualenv build_venv
|
||||||
|
call build_venv\Scripts\activate.bat
|
||||||
|
pip install -e .[test,docs,check]
|
||||||
|
pip install gravitybee
|
||||||
|
gravitybee --with-latest
|
||||||
|
call build_venv\Scripts\deactivate.bat
|
||||||
|
move .gravitybee\dist\latest\aqtinstall-*.exe .gravitybee\dist\latest\aqt.exe
|
||||||
Reference in New Issue
Block a user