diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5e31e6da..aa0f7cb6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,13 +15,10 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: "3.x" - - uses: conda-incubator/setup-miniconda@v2 - if: runner.os == 'Windows' - - name: install Microsoft Visual C++ (Windows) uses: ilammy/msvc-dev-cmd@v1 if: runner.os == 'Windows' @@ -58,7 +55,7 @@ jobs: - name: install Qt and Qt Creator shell: bash run: | - pip install pyyaml requests py7zr + pip install pyyaml requests py7zr tqdm_loggable python setup.py --export_variables cat env >> $GITHUB_ENV @@ -92,9 +89,9 @@ jobs: file ./build/ROSProjectManager-*-*-*.zip - name: upload artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: plugin_archive_artifact + name: plugin_archive_artifact_${{ matrix.config.name }} if-no-files-found: error path: | ./build/ROSProjectManager-*-*-*.zip @@ -106,9 +103,10 @@ jobs: needs: build steps: - name: download artifact - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: - name: plugin_archive_artifact + pattern: plugin_archive_artifact_* + merge-multiple: true path: ./ - name: create release diff --git a/setup.py b/setup.py index cb0ac94c..c16a8285 100755 --- a/setup.py +++ b/setup.py @@ -11,6 +11,8 @@ import py7zr import requests import yaml +from tqdm_loggable.auto import tqdm + url_repo_qtc_fmt = "https://download.qt.io/{release_type}_releases/qtcreator/{qtcv_maj}/{qtcv_full}/installer_source/{os}_{arch}/" @@ -34,18 +36,40 @@ "x64": "64"} def download_check_fail(url, expected_type): - response = requests.get(url, allow_redirects=True) + print("download URL:", url, flush=True) + response = requests.get(url, allow_redirects=True, timeout=1800) if not response.ok: raise RuntimeError("error retrieving "+response.url) if response.headers.get('content-type') != expected_type: print("Warning: invalid content type, expected '{}', got '{}'".format( - expected_type, response.headers.get('content-type'))) + expected_type, response.headers.get('content-type')), flush=True) return response def read_downloadable_archives(package): archive_names = io.StringIO(package.find("DownloadableArchives").text) return list(csv.reader(archive_names, delimiter=',', skipinitialspace=True))[0] +def extract_progress(archive_bytes, archive_name, destination_path): + class ExtractProgressBar(py7zr.callbacks.ExtractCallback, tqdm): + def __init__(self, *args, total_bytes, **kwargs): + super().__init__(self, *args, total=total_bytes, **kwargs) + def report_start_preparation(self): + pass + def report_start(self, processing_file_path, processing_bytes): + pass + def report_end(self, processing_file_path, wrote_bytes): + self.update(int(wrote_bytes)) + def report_postprocess(self): + self.update(int(self.total)) + def report_warning(self, message): + pass + + with py7zr.SevenZipFile(io.BytesIO(archive_bytes)) as zf: + with ExtractProgressBar(unit='B', unit_scale=True, miniters=1, + total_bytes=sum([f.uncompressed for f in zf.files]), + desc=archive_name) as cb_progress: + zf.extractall(path=destination_path, callback=cb_progress) + def qtc_download_check_extract(cfg, dir_install): # if the Qt Creator version contains '-beta' or '-rc' we have to # use the "development" repo, otherwise use the "official" repo @@ -86,14 +110,12 @@ def qtc_download_check_extract(cfg, dir_install): for archive_name in archive_names: url_archive = base_url+"/"+archive_name - print("download", url_archive) - content = download_check_fail(url_archive, "application/x-7z-compressed").content if md5sums[archive_name] != hashlib.md5(content).hexdigest(): raise RuntimeError(archive_name+" MD5 hash sum does not match") - py7zr.SevenZipFile(io.BytesIO(content)).extractall(dir_install_qt) + extract_progress(content, archive_name, dir_install_qt) if cfg['os'] == "Darwin": dir_install_qt = os.path.join(dir_install_qt, "Qt Creator.app", "Contents", "Resources") @@ -162,8 +184,6 @@ def qt_download_check_extract(cfg, dir_install): for package_name, package_version, archive_name in archives_match: url_archive = base_url+'/'+package_name+'/'+package_version+archive_name - print("download", url_archive) - content = download_check_fail(url_archive, "application/x-7z-compressed").content sha1sum = download_check_fail(url_archive+".sha1", "application/x-7z-compressed").text @@ -171,7 +191,7 @@ def qt_download_check_extract(cfg, dir_install): if sha1sum != hashlib.sha1(content).hexdigest(): raise RuntimeError(archive_name+" SHA1 hash sum does not match") - py7zr.SevenZipFile(io.BytesIO(content)).extractall(dir_install) + extract_progress(content, archive_name, dir_install) qt_path = os.path.join(dir_install, "{}.{}.0".format(ver_maj, ver_min)) qt_archs = os.listdir(qt_path)