From 1962456821008fe1cab9a4a6dfda1164c6e9dbec Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Sat, 28 Mar 2020 13:32:21 -0300 Subject: [PATCH 01/10] Set to checks.yml install and import anki wheels # Conflicts: # .github/workflows/checks.yml --- .github/workflows/checks.yml | 50 ++++++++++++++++++++++-------------- qt/setup.py | 2 ++ 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index b8f28f0c5..0906312e0 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -97,23 +97,14 @@ jobs: uses: actions/cache@v1 with: path: ${{ github.workspace }}${{ matrix.SEP }}pyenv - key: | - ${{ runner.os }}-pyenv- - ${{ hashFiles('**/requirements.*') }}- - ${{ hashFiles('**/setup.py') }}- - ${{ hashFiles('**/Makefile') }}-14- + key: ${{ runner.os }}-pyenv-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/setup.py') }}-${{ hashFiles('**/Makefile') }}-14- - # Disabling these caches for now because they do not seem to be used/help - # https://github.com/ankitects/anki/pull/528 - # - name: Cache pip wheels - # if: matrix.BUILD_TYPE == 'build' - # uses: actions/cache@v1 - # with: - # path: ${{ matrix.PIP_WHEELS_DIR }} - # key: | - # ${{ runner.os }}-pip-wheels- - # ${{ hashFiles('**/requirements.txt') }}- - # ${{ hashFiles('**/setup.py') }}-14- + - name: Cache pip wheels + if: matrix.BUILD_TYPE == 'build' + uses: actions/cache@v1 + with: + path: ${{ matrix.PIP_WHEELS_DIR }} + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/setup.py') }}-14- - name: Cache cargo index uses: actions/cache@v1 @@ -237,6 +228,7 @@ jobs: - name: Set up Ubuntu ripgrep, pyaudio, gettext, rename if: matrix.os == 'ubuntu-latest' run: | + set -x sudo apt update sudo apt install portaudio19-dev gettext rename sudo snap install ripgrep --classic @@ -244,6 +236,7 @@ jobs: - name: Set up brew ripgrep, pyaudio, gettext, rename if: matrix.os == 'macos-latest' run: | + set -x brew install portaudio protobuf gettext rename ripgrep make brew link gettext --force @@ -263,16 +256,35 @@ jobs: node-version: 12 - run: make develop - if: matrix.BUILD_TYPE != 'check' + if: matrix.BUILD_TYPE == 'build' - run: make build - if: matrix.BUILD_TYPE != 'check' + if: matrix.BUILD_TYPE == 'build' + + - name: Check Windows wheels + if: matrix.BUILD_TYPE == 'build' && matrix.os == 'windows-latest' + shell: cmd + run: | + echo on + copy %pyaudio% dist + python -m pip install %pyaudio% + cd dist + cmd /C for /R %%i in (*.whl) DO python -m pip install "%%i" + python -c "import aqt; # aqt.run()" + + - name: Check Linux/Mac OS wheels + if: matrix.BUILD_TYPE == 'build' && ( matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' ) + run: | + set -x + cd dist + python -m pip install * + python -c "import aqt; # aqt.run()" - run: make check if: matrix.BUILD_TYPE == 'check' - name: Upload python wheels - if: matrix.BUILD_TYPE != 'check' + if: matrix.BUILD_TYPE == 'build' uses: actions/upload-artifact@v1 with: name: ${{ matrix.ANKI_PYTHON_WHEELS }} diff --git a/qt/setup.py b/qt/setup.py index b941c01e2..7b1a56f21 100644 --- a/qt/setup.py +++ b/qt/setup.py @@ -44,6 +44,8 @@ setuptools.setup( "pyaudio", "markdown", "jsonschema", + "pyqt5", + "pyqtwebengine", 'psutil; sys.platform == "win32"', 'pywin32; sys.platform == "win32"', 'darkdetect; sys.platform == "darwin"', From 000c4c64286a4cd23c955514182e0d828e4783cd Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Fri, 27 Mar 2020 17:13:24 -0300 Subject: [PATCH 02/10] Fixed checks.yml hashFiles not using the correct glob pattern This project requirements files are named .txt and .dev --- .github/workflows/checks.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 0906312e0..c00b1b809 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -97,7 +97,7 @@ jobs: uses: actions/cache@v1 with: path: ${{ github.workspace }}${{ matrix.SEP }}pyenv - key: ${{ runner.os }}-pyenv-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/setup.py') }}-${{ hashFiles('**/Makefile') }}-14- + key: ${{ runner.os }}-pyenv-${{ hashFiles('**/requirements.*') }}-${{ hashFiles('**/setup.py') }}-${{ hashFiles('**/Makefile') }}-14- - name: Cache pip wheels if: matrix.BUILD_TYPE == 'build' From 3dd474288d5866c58b3f66bbea9e82f419f74c74 Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Fri, 27 Mar 2020 19:12:07 -0300 Subject: [PATCH 03/10] Set to Windows build check to pass all wheels to pip at once --- .github/workflows/checks.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index c00b1b809..13cefdeda 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -104,7 +104,7 @@ jobs: uses: actions/cache@v1 with: path: ${{ matrix.PIP_WHEELS_DIR }} - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/setup.py') }}-14- + key: ${{ runner.os }}-pip-wheels-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/setup.py') }}-14- - name: Cache cargo index uses: actions/cache@v1 @@ -267,9 +267,10 @@ jobs: run: | echo on copy %pyaudio% dist - python -m pip install %pyaudio% cd dist - cmd /C for /R %%i in (*.whl) DO python -m pip install "%%i" + setlocal EnableDelayedExpansion + cmd /C set "wheels=" && for /f "delims=" %%i in ('dir /b *.whl') DO set "wheels="%%i" !wheels!" + python -m pip install %wheels% python -c "import aqt; # aqt.run()" - name: Check Linux/Mac OS wheels @@ -277,7 +278,7 @@ jobs: run: | set -x cd dist - python -m pip install * + python -m pip install *.whl python -c "import aqt; # aqt.run()" - run: make check From eb4b77728bf5dcfc1418f9522972dd825da1971d Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Mon, 30 Mar 2020 19:57:05 -0300 Subject: [PATCH 04/10] Fixed setup.py installing pyqtwebengine on older versions of pyqt --- qt/setup.py | 48 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/qt/setup.py b/qt/setup.py index 7b1a56f21..30780189a 100644 --- a/qt/setup.py +++ b/qt/setup.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- import os +from distutils.version import LooseVersion import setuptools @@ -23,6 +24,39 @@ if pyonly: else: extra_files = package_files("aqt_data") +install_requires = [ + "beautifulsoup4", + "requests", + "send2trash", + "pyaudio", + "markdown", + "jsonschema", + 'psutil; sys.platform == "win32"', + 'pywin32; sys.platform == "win32"', + 'darkdetect; sys.platform == "darwin"', +] + + +try: + import PyQt5 as IS_PYQT_INSTALLED + +except (ImportError, ValueError): + IS_PYQT_INSTALLED = None + +try: + from PyQt5.Qt import PYQT_VERSION_STR + +except (ImportError, ValueError): + PYQT_VERSION_STR = None + +# https://github.com/ankitects/anki/pull/530 +if not IS_PYQT_INSTALLED or ( + PYQT_VERSION_STR and LooseVersion(PYQT_VERSION_STR) >= LooseVersion("5.12") +): + install_requires.append("pyqt5") + install_requires.append("pyqtwebengine") + + setuptools.setup( name="aqt", version=version, @@ -37,17 +71,5 @@ setuptools.setup( classifiers=[], python_requires=">=3.7", package_data={"aqt": ["py.typed"]}, - install_requires=[ - "beautifulsoup4", - "requests", - "send2trash", - "pyaudio", - "markdown", - "jsonschema", - "pyqt5", - "pyqtwebengine", - 'psutil; sys.platform == "win32"', - 'pywin32; sys.platform == "win32"', - 'darkdetect; sys.platform == "darwin"', - ], + install_requires=install_requires, ) From 50e9780e661d2befd00022a9166ad782c5fdb7c1 Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Tue, 31 Mar 2020 00:26:53 -0300 Subject: [PATCH 05/10] Set to build a source distribution instead of build distribution for aqt on qt/Makefile, because .whl files are just zip simple zip files and do not support dynamic versioning. Also, there is no restriction for aqt to be shipped as source tarball because it does not ship any binaries. --- .github/workflows/checks.yml | 4 ++-- qt/Makefile | 12 +++++++++--- qt/pyproject.toml | 4 ++++ qt/setup.py | 5 +---- 4 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 qt/pyproject.toml diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 13cefdeda..3405b57df 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -269,7 +269,7 @@ jobs: copy %pyaudio% dist cd dist setlocal EnableDelayedExpansion - cmd /C set "wheels=" && for /f "delims=" %%i in ('dir /b *.whl') DO set "wheels="%%i" !wheels!" + cmd /C set "wheels=" && for /f "delims=" %%i in ('dir /b *.*') DO set "wheels="%%i" !wheels!" python -m pip install %wheels% python -c "import aqt; # aqt.run()" @@ -278,7 +278,7 @@ jobs: run: | set -x cd dist - python -m pip install *.whl + python -m pip install *.* python -c "import aqt; # aqt.run()" - run: make check diff --git a/qt/Makefile b/qt/Makefile index 4fef3e92b..c27741da0 100644 --- a/qt/Makefile +++ b/qt/Makefile @@ -64,7 +64,7 @@ TSDEPS := $(wildcard ts/src/*.ts) $(wildcard ts/scss/*.scss) python -m black aqt/gui_hooks.py @touch $@ -BUILD_STEPS := .build/run-deps .build/dev-deps .build/js .build/ui aqt/buildinfo.py .build/hooks .build/i18n +BUILD_STEPS := .build/vernum .build/run-deps .build/dev-deps .build/js .build/ui aqt/buildinfo.py .build/hooks .build/i18n # Checking ###################### @@ -129,8 +129,8 @@ CHECKDEPS := $(shell ${FIND} aqt tests -name '*.py' | grep -v buildinfo.py) .PHONY: build build: $(BUILD_STEPS) rm -rf dist build - python setup.py -q bdist_wheel - rsync -a dist/*.whl ../dist/ + python setup.py -q sdist + rsync -a dist/*.tar.gz ../dist/ .PHONY: develop develop: $(BUILD_STEPS) @@ -138,3 +138,9 @@ develop: $(BUILD_STEPS) aqt/buildinfo.py: ../meta/version ../meta/buildhash echo "buildhash='$$(cat ../meta/buildhash)'" > $@ echo "version='$$(cat ../meta/version)'" >> $@ + +VER := $(shell cat ../meta/version) +.build/vernum: ../meta/version + sed -i.bak 's/.*automatically updated.*/ version="$(VER)", # automatically updated/' setup.py + rm setup.py.bak + @touch $@ diff --git a/qt/pyproject.toml b/qt/pyproject.toml new file mode 100644 index 000000000..754ed04e1 --- /dev/null +++ b/qt/pyproject.toml @@ -0,0 +1,4 @@ +[build-system] +# Minimum requirements for the build system to execute. +# https://stackoverflow.com/questions/48048745/setup-py-require-a-recent-version-of-setuptools-before-trying-to-install +requires = ["setuptools", "wheel"] diff --git a/qt/setup.py b/qt/setup.py index 30780189a..3a8f205ac 100644 --- a/qt/setup.py +++ b/qt/setup.py @@ -5,9 +5,6 @@ from distutils.version import LooseVersion import setuptools -with open("../meta/version") as fh: - version = fh.read().strip() - def package_files(directory): entries = [] @@ -59,7 +56,7 @@ if not IS_PYQT_INSTALLED or ( setuptools.setup( name="aqt", - version=version, + version="2.1.24", # automatically updated author="Ankitects Pty Ltd", description="Anki's Qt GUI code", long_description="Anki's QT GUI code", From 2f9979bd300a4814786d104d6388c14773674128 Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Tue, 31 Mar 2020 21:10:41 -0300 Subject: [PATCH 06/10] Fixed main make add-buildhash not renaming pip sdist packages --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c6fddd168..3ebd8156a 100644 --- a/Makefile +++ b/Makefile @@ -181,7 +181,7 @@ add-buildhash: fi; \ ver="$$(cat meta/version)"; \ hash="$$(cat meta/buildhash)"; \ - ${RENAME_BIN} "s/-$${ver}-/-$${ver}+$${hash}-/" dist/*-"$${ver}"-* + ${RENAME_BIN} "s/-$${ver}(\.|-)/-$${ver}+$${hash}\$$1/" dist/*-"$${ver}"* .PHONY: pull-i18n From 274944e678da549f4ea6b0422ddf043cf5ab700e Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Tue, 31 Mar 2020 22:07:47 -0300 Subject: [PATCH 07/10] Set the minimum python version required by anki on qt/setup.py --- qt/setup.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/qt/setup.py b/qt/setup.py index 3a8f205ac..f77b796f8 100644 --- a/qt/setup.py +++ b/qt/setup.py @@ -1,6 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- import os +import sys from distutils.version import LooseVersion import setuptools @@ -15,6 +16,7 @@ def package_files(directory): # just the Python files for type hints? pyonly = os.getenv("PYFILESONLY") +minimum_python_version = (3, 7) if pyonly: extra_files = [] @@ -33,6 +35,11 @@ install_requires = [ 'darkdetect; sys.platform == "darwin"', ] +if sys.version_info < minimum_python_version: + raise RuntimeError( + "The minimum Python interpreter version required for Anki is '%s' " + "and version '%s' was found!" % (minimum_python_version, sys.version_info) + ) try: import PyQt5 as IS_PYQT_INSTALLED From efe319ec957f3118fb6c31f52cd730f695a3f0d4 Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Wed, 1 Apr 2020 21:27:52 -0300 Subject: [PATCH 08/10] Deprecated sdist wheels and pyqtwebengine as dependency --- .github/workflows/checks.yml | 4 ++-- qt/Makefile | 4 ++-- qt/setup.py | 21 +-------------------- 3 files changed, 5 insertions(+), 24 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 3405b57df..7c6f02e68 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -270,7 +270,7 @@ jobs: cd dist setlocal EnableDelayedExpansion cmd /C set "wheels=" && for /f "delims=" %%i in ('dir /b *.*') DO set "wheels="%%i" !wheels!" - python -m pip install %wheels% + python -m pip install pyqtwebengine %wheels% python -c "import aqt; # aqt.run()" - name: Check Linux/Mac OS wheels @@ -278,7 +278,7 @@ jobs: run: | set -x cd dist - python -m pip install *.* + python -m pip install pyqtwebengine *.* python -c "import aqt; # aqt.run()" - run: make check diff --git a/qt/Makefile b/qt/Makefile index c27741da0..6c1de33df 100644 --- a/qt/Makefile +++ b/qt/Makefile @@ -129,8 +129,8 @@ CHECKDEPS := $(shell ${FIND} aqt tests -name '*.py' | grep -v buildinfo.py) .PHONY: build build: $(BUILD_STEPS) rm -rf dist build - python setup.py -q sdist - rsync -a dist/*.tar.gz ../dist/ + python setup.py -q bdist_wheel + rsync -a dist/*.whl ../dist/ .PHONY: develop develop: $(BUILD_STEPS) diff --git a/qt/setup.py b/qt/setup.py index f77b796f8..2c7217e43 100644 --- a/qt/setup.py +++ b/qt/setup.py @@ -2,7 +2,6 @@ # -*- coding: utf-8 -*- import os import sys -from distutils.version import LooseVersion import setuptools @@ -30,6 +29,7 @@ install_requires = [ "pyaudio", "markdown", "jsonschema", + "pyqt5>=5.9", 'psutil; sys.platform == "win32"', 'pywin32; sys.platform == "win32"', 'darkdetect; sys.platform == "darwin"', @@ -41,25 +41,6 @@ if sys.version_info < minimum_python_version: "and version '%s' was found!" % (minimum_python_version, sys.version_info) ) -try: - import PyQt5 as IS_PYQT_INSTALLED - -except (ImportError, ValueError): - IS_PYQT_INSTALLED = None - -try: - from PyQt5.Qt import PYQT_VERSION_STR - -except (ImportError, ValueError): - PYQT_VERSION_STR = None - -# https://github.com/ankitects/anki/pull/530 -if not IS_PYQT_INSTALLED or ( - PYQT_VERSION_STR and LooseVersion(PYQT_VERSION_STR) >= LooseVersion("5.12") -): - install_requires.append("pyqt5") - install_requires.append("pyqtwebengine") - setuptools.setup( name="aqt", From 4ad03fe4bacac1885c069e6adc744f3a7c6b5531 Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Thu, 2 Apr 2020 12:29:56 -0300 Subject: [PATCH 09/10] Fixed double python version check for python_requires=">=3.7" --- qt/setup.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/qt/setup.py b/qt/setup.py index 2c7217e43..98d207714 100644 --- a/qt/setup.py +++ b/qt/setup.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- import os -import sys import setuptools @@ -15,7 +14,6 @@ def package_files(directory): # just the Python files for type hints? pyonly = os.getenv("PYFILESONLY") -minimum_python_version = (3, 7) if pyonly: extra_files = [] @@ -35,12 +33,6 @@ install_requires = [ 'darkdetect; sys.platform == "darwin"', ] -if sys.version_info < minimum_python_version: - raise RuntimeError( - "The minimum Python interpreter version required for Anki is '%s' " - "and version '%s' was found!" % (minimum_python_version, sys.version_info) - ) - setuptools.setup( name="aqt", From e1cb04c45d94a7a5ea0bc496280960399822649f Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Thu, 2 Apr 2020 22:58:24 -0300 Subject: [PATCH 10/10] Set checks.yml pyenv and pip wheels cache keys as multiline strings --- .github/workflows/checks.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 7c6f02e68..d30dff9ae 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -97,14 +97,21 @@ jobs: uses: actions/cache@v1 with: path: ${{ github.workspace }}${{ matrix.SEP }}pyenv - key: ${{ runner.os }}-pyenv-${{ hashFiles('**/requirements.*') }}-${{ hashFiles('**/setup.py') }}-${{ hashFiles('**/Makefile') }}-14- + key: | + ${{ runner.os }}-pyenv- + ${{ hashFiles('**/requirements.*') }}- + ${{ hashFiles('**/setup.py') }}- + ${{ hashFiles('**/Makefile') }}-14- - name: Cache pip wheels if: matrix.BUILD_TYPE == 'build' uses: actions/cache@v1 with: path: ${{ matrix.PIP_WHEELS_DIR }} - key: ${{ runner.os }}-pip-wheels-${{ hashFiles('**/requirements.txt') }}-${{ hashFiles('**/setup.py') }}-14- + key: | + ${{ runner.os }}-pip-wheels- + ${{ hashFiles('**/requirements.txt') }}- + ${{ hashFiles('**/setup.py') }}-14- - name: Cache cargo index uses: actions/cache@v1