From cce08ef46e965880e03df9ebdecb708dc6e29f70 Mon Sep 17 00:00:00 2001 From: Ryan Clary <9618975+mrclary@users.noreply.github.com> Date: Fri, 21 Mar 2025 17:53:12 -0700 Subject: [PATCH 01/10] Remove interactivity from scripts --- spyder_updater/scripts/install.bat | 10 +++------- spyder_updater/scripts/install.sh | 13 +------------ 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/spyder_updater/scripts/install.bat b/spyder_updater/scripts/install.bat index 9587d0c..9fe4080 100644 --- a/spyder_updater/scripts/install.bat +++ b/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/spyder_updater/scripts/install.sh index f06024e..f354cdf 100755 --- a/spyder_updater/scripts/install.sh +++ b/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 < Date: Sat, 22 Mar 2025 13:00:47 -0700 Subject: [PATCH 02/10] Rename start-update.py -> start.py This will be more conducive to executable script --- spyder_updater/{start-update.py => start.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename spyder_updater/{start-update.py => start.py} (100%) diff --git a/spyder_updater/start-update.py b/spyder_updater/start.py similarity index 100% rename from spyder_updater/start-update.py rename to spyder_updater/start.py From c116426841bbe71b8667a3981c5460aff0d0c573 Mon Sep 17 00:00:00 2001 From: Ryan Clary <9618975+mrclary@users.noreply.github.com> Date: Mon, 24 Mar 2025 10:27:24 -0700 Subject: [PATCH 03/10] Add executable script at install --- pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index b28b394..3ada4bc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -39,3 +39,6 @@ Source = "https://github.com/spyder-ide/spyder-updater" [tool.setuptools.dynamic] version = {attr = "spyder_updater.__version__"} + +[project.scripts] +spyder-updater = "spyder_updater.start:main" From b5d3361079719fcfa2ea294791e5cc8e6bf4165a Mon Sep 17 00:00:00 2001 From: Ryan Clary <9618975+mrclary@users.noreply.github.com> Date: Sat, 22 Mar 2025 15:51:55 -0700 Subject: [PATCH 04/10] Use absolute imports. Note: argv removed from main call signature to be compatible with executable script created at install. argparser should handle sys.argv automatically. --- spyder_updater/start.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/spyder_updater/start.py b/spyder_updater/start.py index 4d5e6f4..03426e7 100644 --- a/spyder_updater/start.py +++ b/spyder_updater/start.py @@ -14,12 +14,12 @@ from qtpy.QtGui import QIcon # Local imports -# TODO: Use absolute imports here +from spyder_updater import __version__ from spyder_updater.gui.updater import Updater from spyder_updater.gui.utils import UpdaterApplication, validate_schema -def main(argv): +def main(): """Run updater.""" # Parser instance parser = argparse.ArgumentParser(usage="update-spyder [options]") @@ -34,7 +34,6 @@ def main(argv): ) # Get info from update file - args = parser.parse_args(argv[1:]) update_info = json.loads(args.file.read()) # Validate that info conforms to our schema @@ -65,4 +64,4 @@ def main(argv): if __name__ == '__main__': - main(sys.argv) + main() From 80290e5b4b1ef7ac491bd569f52a62f063192437 Mon Sep 17 00:00:00 2001 From: Ryan Clary <9618975+mrclary@users.noreply.github.com> Date: Sat, 22 Mar 2025 15:52:46 -0700 Subject: [PATCH 05/10] Add --version CLI option --- spyder_updater/start.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spyder_updater/start.py b/spyder_updater/start.py index 03426e7..c7cc635 100644 --- a/spyder_updater/start.py +++ b/spyder_updater/start.py @@ -32,6 +32,17 @@ def main(): type=argparse.FileType(), help="Path to file that has the info to update Spyder" ) + parser.add_argument( + "--version", + action="store_true", + help="Return spyder-updater version and exit." + ) + + args = parser.parse_args() + + if args.version: + sys.stdout.write(__version__ + "\n") + return # Get info from update file update_info = json.loads(args.file.read()) From 38f4b61328d8ffb1cf79fa3cd801bad0469f5c55 Mon Sep 17 00:00:00 2001 From: Ryan Clary <9618975+mrclary@users.noreply.github.com> Date: Mon, 24 Mar 2025 10:34:35 -0700 Subject: [PATCH 06/10] Move spyder_updater and tests to src directory. This is compatible with recipe directory in repository. --- {spyder_updater => src/spyder_updater}/__init__.py | 0 {spyder_updater => src/spyder_updater}/gui/__init__.py | 0 .../spyder_updater}/gui/assets/info-schema.json | 0 .../spyder_updater}/gui/assets/spyder-light.svg | 0 {spyder_updater => src/spyder_updater}/gui/assets/spyder.svg | 0 {spyder_updater => src/spyder_updater}/gui/updater.py | 4 +++- {spyder_updater => src/spyder_updater}/gui/utils.py | 0 {spyder_updater => src/spyder_updater}/scripts/install.bat | 0 {spyder_updater => src/spyder_updater}/scripts/install.sh | 0 {spyder_updater => src/spyder_updater}/start.py | 0 {tests => src/tests}/failure.sh | 0 {tests => src/tests}/info-error.json | 0 {tests => src/tests}/info-failure.json | 0 {tests => src/tests}/info-success.json | 0 {tests => src/tests}/success.sh | 0 15 files changed, 3 insertions(+), 1 deletion(-) rename {spyder_updater => src/spyder_updater}/__init__.py (100%) rename {spyder_updater => src/spyder_updater}/gui/__init__.py (100%) rename {spyder_updater => src/spyder_updater}/gui/assets/info-schema.json (100%) rename {spyder_updater => src/spyder_updater}/gui/assets/spyder-light.svg (100%) rename {spyder_updater => src/spyder_updater}/gui/assets/spyder.svg (100%) rename {spyder_updater => src/spyder_updater}/gui/updater.py (99%) rename {spyder_updater => src/spyder_updater}/gui/utils.py (100%) rename {spyder_updater => src/spyder_updater}/scripts/install.bat (100%) rename {spyder_updater => src/spyder_updater}/scripts/install.sh (100%) rename {spyder_updater => src/spyder_updater}/start.py (100%) rename {tests => src/tests}/failure.sh (100%) rename {tests => src/tests}/info-error.json (100%) rename {tests => src/tests}/info-failure.json (100%) rename {tests => src/tests}/info-success.json (100%) rename {tests => src/tests}/success.sh (100%) 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 100% rename from spyder_updater/scripts/install.bat rename to src/spyder_updater/scripts/install.bat diff --git a/spyder_updater/scripts/install.sh b/src/spyder_updater/scripts/install.sh similarity index 100% rename from spyder_updater/scripts/install.sh rename to src/spyder_updater/scripts/install.sh diff --git a/spyder_updater/start.py b/src/spyder_updater/start.py similarity index 100% rename from spyder_updater/start.py rename to src/spyder_updater/start.py diff --git a/tests/failure.sh b/src/tests/failure.sh similarity index 100% rename from tests/failure.sh rename to src/tests/failure.sh diff --git a/tests/info-error.json b/src/tests/info-error.json similarity index 100% rename from tests/info-error.json rename to src/tests/info-error.json diff --git a/tests/info-failure.json b/src/tests/info-failure.json similarity index 100% rename from tests/info-failure.json rename to src/tests/info-failure.json diff --git a/tests/info-success.json b/src/tests/info-success.json similarity index 100% rename from tests/info-success.json rename to src/tests/info-success.json diff --git a/tests/success.sh b/src/tests/success.sh similarity index 100% rename from tests/success.sh rename to src/tests/success.sh From bfae39dbf7d1d62ce8957127249b600361de1a58 Mon Sep 17 00:00:00 2001 From: Ryan Clary <9618975+mrclary@users.noreply.github.com> Date: Mon, 24 Mar 2025 10:42:30 -0700 Subject: [PATCH 07/10] Add conda recipe --- recipe/bld.bat | 5 ++++ recipe/build.sh | 4 +++ recipe/meta.yaml | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 78 insertions(+) create mode 100644 recipe/bld.bat create mode 100644 recipe/build.sh create mode 100644 recipe/meta.yaml diff --git a/recipe/bld.bat b/recipe/bld.bat new file mode 100644 index 0000000..dc3d3f4 --- /dev/null +++ b/recipe/bld.bat @@ -0,0 +1,5 @@ +setlocal ENABLEDELAYEDEXPANSION + +set SPYDER_QT_BINDING=conda-forge +%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..ba57919 --- /dev/null +++ b/recipe/build.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +export SPYDER_QT_BINDING=conda-forge +$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..24ec432 --- /dev/null +++ b/recipe/meta.yaml @@ -0,0 +1,69 @@ +{% 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 }} # [unix and (build_platform != target_platform)] + - python # [win and (build_platform != target_platform)] + host: + - python {{ python_min }} # [unix] + - python # [win] + - pip + - setuptools + - packaging + run: + - python >={{ python_min }} # [unix] + - python # [win] + - 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: The Scientific Python Development Environment + description: | + Spyder is a powerful scientific environment written in Python, for Python, + and designed by and for scientists, engineers and data analysts. + It features a unique combination of the advanced editing, analysis, + debugging and profiling functionality of a comprehensive development tool + with the data exploration, interactive execution, deep inspection and + beautiful visualization capabilities of a scientific package.\n + Furthermore, Spyder offers built-in integration with many popular + scientific packages, including NumPy, SciPy, Pandas, IPython, QtConsole, + Matplotlib, SymPy, and more.\n + Beyond its many built-in features, Spyder can be extended even further via + third-party plugins.\n + Spyder can also be used as a PyQt5 extension library, allowing you to build + upon its functionality and embed its components, such as the interactive + console or advanced editor, in your own software. + doc_url: https://docs.spyder-ide.org/ + dev_url: https://github.com/spyder-ide/spyder From 984f2975b7ad5ea3e54c079825dd64183859e3f9 Mon Sep 17 00:00:00 2001 From: Ryan Clary <9618975+mrclary@users.noreply.github.com> Date: Fri, 28 Mar 2025 07:35:29 -0700 Subject: [PATCH 08/10] Add workflow --- .github/workflows/build-updater.yml | 122 ++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 .github/workflows/build-updater.yml 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 }}/*.* From bbd9fc715c307f3722df06fb7dfd2e943008f076 Mon Sep 17 00:00:00 2001 From: Ryan Clary <9618975+mrclary@users.noreply.github.com> Date: Fri, 4 Apr 2025 20:57:42 -0700 Subject: [PATCH 09/10] Include data files in package build --- pyproject.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 3ada4bc..3a16481 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,5 +40,9 @@ 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" From 028f65349e951a00ade1dd6e0bfb0eaf460c542c Mon Sep 17 00:00:00 2001 From: Ryan Clary <9618975+mrclary@users.noreply.github.com> Date: Sat, 5 Apr 2025 13:56:13 -0700 Subject: [PATCH 10/10] Apply suggestions from code review Co-authored-by: Carlos Cordoba --- recipe/bld.bat | 1 - recipe/build.sh | 1 - recipe/meta.yaml | 29 +++++++---------------------- 3 files changed, 7 insertions(+), 24 deletions(-) diff --git a/recipe/bld.bat b/recipe/bld.bat index dc3d3f4..0562735 100644 --- a/recipe/bld.bat +++ b/recipe/bld.bat @@ -1,5 +1,4 @@ setlocal ENABLEDELAYEDEXPANSION -set SPYDER_QT_BINDING=conda-forge %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 index ba57919..e3e89f6 100644 --- a/recipe/build.sh +++ b/recipe/build.sh @@ -1,4 +1,3 @@ #!/bin/bash -export SPYDER_QT_BINDING=conda-forge $PYTHON -m pip install . --no-deps --ignore-installed --no-cache-dir -vvv diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 24ec432..edd4d87 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -17,17 +17,14 @@ build: requirements: build: - - python >={{ python_min }} # [unix and (build_platform != target_platform)] - - python # [win and (build_platform != target_platform)] + - python >={{ python_min }} host: - - python {{ python_min }} # [unix] - - python # [win] + - python {{ python_min }} - pip - setuptools - packaging run: - - python >={{ python_min }} # [unix] - - python # [win] + - python >={{ python_min }} - jsonschema - pyqt - qdarkstyle @@ -49,21 +46,9 @@ about: home: https://www.spyder-ide.org/ license: MIT license_file: LICENSE.txt - summary: The Scientific Python Development Environment + summary: Updater for the Spyder standalone installers description: | - Spyder is a powerful scientific environment written in Python, for Python, - and designed by and for scientists, engineers and data analysts. - It features a unique combination of the advanced editing, analysis, - debugging and profiling functionality of a comprehensive development tool - with the data exploration, interactive execution, deep inspection and - beautiful visualization capabilities of a scientific package.\n - Furthermore, Spyder offers built-in integration with many popular - scientific packages, including NumPy, SciPy, Pandas, IPython, QtConsole, - Matplotlib, SymPy, and more.\n - Beyond its many built-in features, Spyder can be extended even further via - third-party plugins.\n - Spyder can also be used as a PyQt5 extension library, allowing you to build - upon its functionality and embed its components, such as the interactive - console or advanced editor, in your own software. + 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 + dev_url: https://github.com/spyder-ide/spyder-updater