diff --git a/.github/workflows/build-updater.yml b/.github/workflows/build-updater.yml new file mode 100644 index 0000000..b9badc9 --- /dev/null +++ b/.github/workflows/build-updater.yml @@ -0,0 +1,122 @@ +name: Updater Release + +on: + pull_request: + branches: + - main + + release: + types: + - created + + workflow_dispatch: + inputs: + pre: + description: 'Build as release candidate' + required: false + default: true + type: boolean + ssh: + # github_cli: gh workflow run updater-release.yml --repo spyder-ide/spyder-updater --ref -f ssh=true + description: 'Enable ssh debugging' + required: false + default: false + type: boolean + +concurrency: + group: updater-release-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + name: Build conda package + runs-on: ubuntu-latest + defaults: + run: + shell: bash -le {0} + + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Remote SSH Connection + if: inputs.ssh + uses: mxschmitt/action-tmate@v3 + timeout-minutes: 60 + with: + detached: true + + - name: Setup Build Environment + uses: mamba-org/setup-micromamba@v1 + with: + condarc: | + conda_build: + pkg_format: '2' + zstd_compression_level: '19' + channels: + - conda-forge + environment-name: build + create-args: >- + python=3.11 + conda-build + conda-lock + cache-downloads: true + cache-environment: true + + - name: Environment Variables + run: | + export DISTDIR=${GITHUB_WORKSPACE}/dist + echo "DISTDIR=$DISTDIR" >> $GITHUB_ENV + mkdir -p $DISTDIR + + export CONDA_BLD_PATH=${RUNNER_TEMP}/conda-bld + echo "CONDA_BLD_PATH=$CONDA_BLD_PATH" >> $GITHUB_ENV + mkdir -p $CONDA_BLD_PATH + + conda config --set bld_path $CONDA_BLD_PATH + conda config --set conda_build.root-dir $CONDA_BLD_PATH + + env | sort + + - name: Build spyder-updater Conda Package + run: | + conda build --no-anaconda-upload recipe + + - name: Create Conda Lock Files + run: | + conda-lock lock -c conda-forge --kind explicit --file pyproject.toml --filename-template $DISTDIR/conda-updater-{platform}.lock + + - name: Create Distribution File + working-directory: ${{ env.DISTDIR }} + run: | + mv $CONDA_BLD_PATH/noarch/*.conda . + zip -mT spyder-updater *.lock *.conda + + - name: Create Checksums + working-directory: ${{ env.DISTDIR }} + run: | + sha256sum spyder-updater.zip > Spyder-Updater-checksums.txt + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + path: ${{ env.DISTDIR }} + name: spyder-updater-artifact + + - name: Get Release + if: github.event_name == 'release' + uses: bruceadams/get-release@v1.3.2 + id: get_release + env: + GITHUB_TOKEN: ${{ github.token }} + + - name: Upload Release Asset + if: github.event_name == 'release' + uses: shogo82148/actions-upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ github.token }} + with: + upload_url: ${{ steps.get_release.outputs.upload_url }} + asset_path: ${{ env.DISTDIR }}/*.* diff --git a/pyproject.toml b/pyproject.toml index b28b394..3a16481 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,3 +39,10 @@ Source = "https://github.com/spyder-ide/spyder-updater" [tool.setuptools.dynamic] version = {attr = "spyder_updater.__version__"} + +[tool.setuptools.package-data] +"spyder_updater.scripts" = ["*.bat", "*.sh"] +"spyder_updater.gui.assets" = ["*.json", "*.svg"] + +[project.scripts] +spyder-updater = "spyder_updater.start:main" diff --git a/recipe/bld.bat b/recipe/bld.bat new file mode 100644 index 0000000..0562735 --- /dev/null +++ b/recipe/bld.bat @@ -0,0 +1,4 @@ +setlocal ENABLEDELAYEDEXPANSION + +%PYTHON% -m pip install . --no-deps --ignore-installed --no-cache-dir -vvv +if errorlevel 1 exit 1 diff --git a/recipe/build.sh b/recipe/build.sh new file mode 100644 index 0000000..e3e89f6 --- /dev/null +++ b/recipe/build.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +$PYTHON -m pip install . --no-deps --ignore-installed --no-cache-dir -vvv diff --git a/recipe/meta.yaml b/recipe/meta.yaml new file mode 100644 index 0000000..edd4d87 --- /dev/null +++ b/recipe/meta.yaml @@ -0,0 +1,54 @@ +{% set version = "0.1.0.dev0" %} +{% set python_min = "3.9" %} +{% set build = 0 %} + +package: + name: spyder-updater + version: {{ version }} + +source: + path: ../ + +build: + number: {{ build }} + entry_points: + - spyder-updater = spyder_updater.start:main + noarch: python + +requirements: + build: + - python >={{ python_min }} + host: + - python {{ python_min }} + - pip + - setuptools + - packaging + run: + - python >={{ python_min }} + - jsonschema + - pyqt + - qdarkstyle + - qstylizer + - qtawesome + - qtpy + - superqt + +test: + requires: + - pip + commands: + - spyder-updater -h + - python -m pip check + imports: + - spyder_updater + +about: + home: https://www.spyder-ide.org/ + license: MIT + license_file: LICENSE.txt + summary: Updater for the Spyder standalone installers + description: | + It provides a graphical interface and the necessary scripts to perform the + update in a separate environment. + doc_url: https://docs.spyder-ide.org/ + dev_url: https://github.com/spyder-ide/spyder-updater diff --git a/spyder_updater/__init__.py b/src/spyder_updater/__init__.py similarity index 100% rename from spyder_updater/__init__.py rename to src/spyder_updater/__init__.py diff --git a/spyder_updater/gui/__init__.py b/src/spyder_updater/gui/__init__.py similarity index 100% rename from spyder_updater/gui/__init__.py rename to src/spyder_updater/gui/__init__.py diff --git a/spyder_updater/gui/assets/info-schema.json b/src/spyder_updater/gui/assets/info-schema.json similarity index 100% rename from spyder_updater/gui/assets/info-schema.json rename to src/spyder_updater/gui/assets/info-schema.json diff --git a/spyder_updater/gui/assets/spyder-light.svg b/src/spyder_updater/gui/assets/spyder-light.svg similarity index 100% rename from spyder_updater/gui/assets/spyder-light.svg rename to src/spyder_updater/gui/assets/spyder-light.svg diff --git a/spyder_updater/gui/assets/spyder.svg b/src/spyder_updater/gui/assets/spyder.svg similarity index 100% rename from spyder_updater/gui/assets/spyder.svg rename to src/spyder_updater/gui/assets/spyder.svg diff --git a/spyder_updater/gui/updater.py b/src/spyder_updater/gui/updater.py similarity index 99% rename from spyder_updater/gui/updater.py rename to src/spyder_updater/gui/updater.py index 6ee0ed1..1bcb70a 100644 --- a/spyder_updater/gui/updater.py +++ b/src/spyder_updater/gui/updater.py @@ -392,7 +392,9 @@ def _handle_error(self, error): def start_install(self): # Install script script_name = 'install.' + ('bat' if os.name == 'nt' else 'sh') - script_path = str(Path(__file__).parent / 'scripts' / script_name) + script_path = str( + Path(__file__).parent.parent / 'scripts' / script_name + ) # Sub command if self._update_info.get("installation_script") is None: diff --git a/spyder_updater/gui/utils.py b/src/spyder_updater/gui/utils.py similarity index 100% rename from spyder_updater/gui/utils.py rename to src/spyder_updater/gui/utils.py diff --git a/spyder_updater/scripts/install.bat b/src/spyder_updater/scripts/install.bat similarity index 93% rename from spyder_updater/scripts/install.bat rename to src/spyder_updater/scripts/install.bat index 9587d0c..9fe4080 100644 --- a/spyder_updater/scripts/install.bat +++ b/src/spyder_updater/scripts/install.bat @@ -19,9 +19,6 @@ chcp 65001>nul echo. echo ========================================================= echo Updating Spyder -echo --------------- -echo. -echo IMPORTANT: Do not close this window until it has finished echo ========================================================= echo. @@ -29,18 +26,17 @@ call :wait_for_spyder_quit IF exist "%conda%" IF exist "%prefix%" ( call :update_subroutine - set /P =Press return to exit and launch Spyder... call :launch_spyder - goto exit + goto :exit ) IF exist "%install_file%" ( call :install_subroutine - goto exit + goto :exit ) :exit -exit %ERRORLEVEL% + exit %ERRORLEVEL% :wait_for_spyder_quit echo Waiting for Spyder to quit... diff --git a/spyder_updater/scripts/install.sh b/src/spyder_updater/scripts/install.sh similarity index 85% rename from spyder_updater/scripts/install.sh rename to src/spyder_updater/scripts/install.sh index f06024e..f354cdf 100755 --- a/spyder_updater/scripts/install.sh +++ b/src/spyder_updater/scripts/install.sh @@ -1,6 +1,4 @@ -#!/bin/bash -i - -unset HISTFILE # Do not write to history with interactive shell +#!/bin/bash while getopts "i:c:p:r" option; do case "$option" in @@ -72,9 +70,6 @@ install_spyder(){ cat <