From 069cc11a86cb1b8c9230a47bf187835fdc75ff8d Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Wed, 1 Apr 2020 23:01:48 -0300 Subject: [PATCH 1/3] Created the GitHub Actions step Upload to PyPi to run only on tagged releases of anki: https://anki.tenderapp.com/discussions/ankidesktop/40025-anki-in-python-package-index --- .github/workflows/checks.yml | 22 ++++++++++++++++++++++ pylib/Makefile | 8 +++++++- pylib/pyproject.toml | 4 ++++ pylib/setup.py | 36 ++++++++++++++++++++++++------------ qt/setup.py | 2 ++ rslib/Cargo.toml | 6 ++++-- rslib/Makefile | 2 +- rslib/README.md | 3 +++ rspy/Cargo.toml | 7 +++++-- rspy/Makefile | 2 +- rspy/README.md | 3 +++ 11 files changed, 76 insertions(+), 19 deletions(-) create mode 100644 pylib/pyproject.toml create mode 100644 rslib/README.md create mode 100644 rspy/README.md diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index cf8e02be120..bf34903226c 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -239,3 +239,25 @@ jobs: with: name: ${{ matrix.ANKI_PYTHON_WHEELS }} path: dist + + - name: Upload to PyPi Windows + if: matrix.BUILD_TYPE == 'build' && startsWith(github.ref, 'refs/tags/') && matrix.os == 'windows-latest' + shell: cmd + env: + TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} + TWINE_USERNAME: __token__ + run: | + echo on + rm -f "dist/%pyaudio%" + python -m pip install twine + twine upload --non-interactive --skip-existing --verbose dist/* + + - name: Upload to PyPi Linux/Mac OS + if: matrix.BUILD_TYPE == 'build' && startsWith(github.ref, 'refs/tags/') && ( matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest' ) + env: + TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }} + TWINE_USERNAME: __token__ + run: | + set -x + python -m pip install twine + twine upload --non-interactive --skip-existing --verbose dist/* diff --git a/pylib/Makefile b/pylib/Makefile index 9727fc921a2..dba14b0c822 100644 --- a/pylib/Makefile +++ b/pylib/Makefile @@ -52,7 +52,7 @@ PROTODEPS := $(wildcard ../proto/*.proto) python -m black anki/hooks.py @touch $@ -BUILD_STEPS := .build/run-deps .build/dev-deps .build/py-proto anki/buildinfo.py .build/hooks +BUILD_STEPS := .build/vernum .build/run-deps .build/dev-deps .build/py-proto anki/buildinfo.py .build/hooks # Checking ###################### @@ -111,3 +111,9 @@ develop: $(BUILD_STEPS) anki/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/pylib/pyproject.toml b/pylib/pyproject.toml new file mode 100644 index 00000000000..754ed04e148 --- /dev/null +++ b/pylib/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/pylib/setup.py b/pylib/setup.py index e42b783bff0..b87dc865c67 100644 --- a/pylib/setup.py +++ b/pylib/setup.py @@ -1,11 +1,31 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +import sys + import setuptools -with open("../meta/version") as fh: - version = fh.read().strip() +minimum_python_version = (3, 7) + +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) + ) + +install_requires = [ + "beautifulsoup4", + "requests", + "decorator", + "protobuf", + 'orjson; platform_machine == "x86_64"', + 'psutil; sys_platform == "win32"', + 'distro; sys_platform != "darwin" and sys_platform != "win32"', +] + setuptools.setup( name="anki", - version=version, + version="2.1.24", # automatically updated author="Ankitects Pty Ltd", description="Anki's library code", long_description="Anki's library code", @@ -16,13 +36,5 @@ package_data={"anki": ["py.typed"]}, classifiers=[], python_requires=">=3.7", - install_requires=[ - "beautifulsoup4", - "requests", - "decorator", - "protobuf", - 'orjson; platform_machine == "x86_64"', - 'psutil; sys_platform == "win32"', - 'distro; sys_platform != "darwin" and sys_platform != "win32"', - ], + install_requires=install_requires, ) diff --git a/qt/setup.py b/qt/setup.py index 6d4989942ce..b941c01e2ec 100644 --- a/qt/setup.py +++ b/qt/setup.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- import os import setuptools diff --git a/rslib/Cargo.toml b/rslib/Cargo.toml index 099a21e0c22..d90e0e9d7f5 100644 --- a/rslib/Cargo.toml +++ b/rslib/Cargo.toml @@ -1,9 +1,11 @@ [package] name = "anki" -version = "2.1.24" # automatically updated +version = "2.1.24" # automatically updated edition = "2018" -authors = ["Ankitects Pty Ltd and contributors"] +authors = ["Ankitects Pty Ltd and contributors "] license = "AGPL-3.0-or-later" +description = "Anki's Rust library code" +readme = "README.md" [dependencies] nom = "5.0.1" diff --git a/rslib/Makefile b/rslib/Makefile index 6551bbfe8d5..94bb7432d25 100644 --- a/rslib/Makefile +++ b/rslib/Makefile @@ -49,6 +49,6 @@ RUST_TOOLCHAIN := $(shell cat rust-toolchain) VER := $(shell cat ../meta/version) .build/vernum: ../meta/version - sed -i.bak 's/.*automatically updated.*/version = "$(VER)" # automatically updated/' Cargo.toml + sed -i.bak 's/.*automatically updated.*/version = "$(VER)" # automatically updated/' Cargo.toml rm Cargo.toml.bak @touch $@ diff --git a/rslib/README.md b/rslib/README.md new file mode 100644 index 00000000000..81402e41ad6 --- /dev/null +++ b/rslib/README.md @@ -0,0 +1,3 @@ +Anki's Rust library code + +https://anki.tenderapp.com/discussions/ankidesktop/40025-anki-in-python-package-index diff --git a/rspy/Cargo.toml b/rspy/Cargo.toml index 5b593acb299..0b9fa2f02b3 100644 --- a/rspy/Cargo.toml +++ b/rspy/Cargo.toml @@ -1,8 +1,11 @@ [package] name = "ankirspy" -version = "2.1.24" # automatically updated +version = "2.1.24" # automatically updated edition = "2018" -authors = ["Ankitects Pty Ltd and contributors"] +authors = ["Ankitects Pty Ltd and contributors "] +license = "AGPL-3.0-or-later" +description = "Anki's Rust library code Python bindings" +readme = "README.md" [dependencies] anki = { path = "../rslib" } diff --git a/rspy/Makefile b/rspy/Makefile index 20362e17013..8f962ca8e74 100644 --- a/rspy/Makefile +++ b/rspy/Makefile @@ -91,6 +91,6 @@ RUST_TOOLCHAIN := $(shell cat rust-toolchain) VER := $(shell cat ../meta/version) .build/vernum: ../meta/version - sed -i.bak 's/.*automatically updated.*/version = "$(VER)" # automatically updated/' Cargo.toml + sed -i.bak 's/.*automatically updated.*/version = "$(VER)" # automatically updated/' Cargo.toml rm Cargo.toml.bak @touch $@ diff --git a/rspy/README.md b/rspy/README.md new file mode 100644 index 00000000000..091c4688281 --- /dev/null +++ b/rspy/README.md @@ -0,0 +1,3 @@ +Anki's Rust library code Python bindings + +https://anki.tenderapp.com/discussions/ankidesktop/40025-anki-in-python-package-index From 28bb56744d3382dccb430fca146375fa08f64f5b Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Thu, 2 Apr 2020 12:29:05 -0300 Subject: [PATCH 2/3] Fixed double python version check for python_requires=">=3.7" --- pylib/setup.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/pylib/setup.py b/pylib/setup.py index b87dc865c67..904df94d38b 100644 --- a/pylib/setup.py +++ b/pylib/setup.py @@ -1,17 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -import sys - import setuptools -minimum_python_version = (3, 7) - -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) - ) - install_requires = [ "beautifulsoup4", "requests", From 58ba764cb6acb07b801aeeae7da8005f650e0299 Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Thu, 2 Apr 2020 14:24:53 -0300 Subject: [PATCH 3/3] Fixed old cache making build fail # Conflicts: # .github/workflows/checks.yml --- .github/workflows/checks.yml | 54 ++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index bf34903226c..b8f28f0c542 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -97,45 +97,81 @@ jobs: uses: actions/cache@v1 with: path: ${{ github.workspace }}${{ matrix.SEP }}pyenv - key: ${{ runner.os }}-pyenv-${{ hashFiles('**/Makefile') }}-${{ hashFiles('**/requirements.txt') }}-14- + key: | + ${{ runner.os }}-pyenv- + ${{ hashFiles('**/requirements.*') }}- + ${{ 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-${{ hashFiles('**/requirements.txt') }}-14- + # key: | + # ${{ runner.os }}-pip-wheels- + # ${{ hashFiles('**/requirements.txt') }}- + # ${{ hashFiles('**/setup.py') }}-14- - name: Cache cargo index uses: actions/cache@v1 with: path: ${{ matrix.CARGO_INDEX_DIR }} - key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.toml') }}-14- + key: | + ${{ runner.os }}-cargo-index- + ${{ hashFiles('**/requirements.*') }}- + ${{ hashFiles('**/setup.py') }}- + ${{ hashFiles('**/Makefile') }}- + ${{ hashFiles('**/Cargo.toml') }}-14- - name: Cache cargo registry uses: actions/cache@v1 with: path: ${{ matrix.CARGO_REGISTRY_DIR }} - key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-14- + key: | + ${{ runner.os }}-cargo-registry- + ${{ hashFiles('**/requirements.*') }}- + ${{ hashFiles('**/setup.py') }}- + ${{ hashFiles('**/Makefile') }}- + ${{ hashFiles('**/Cargo.toml') }}-14- - name: Cache cargo target uses: actions/cache@v1 with: path: ${{ github.workspace }}${{ matrix.SEP }}target - key: ${{ runner.os }}-cargo-target-${{ hashFiles('**/Cargo.toml') }}-${{ matrix.BUILD_TYPE }}-14- + key: | + ${{ runner.os }}-cargo-target- + ${{ hashFiles('**/requirements.*') }}- + ${{ hashFiles('**/setup.py') }}- + ${{ hashFiles('**/Makefile') }}- + ${{ hashFiles('**/Cargo.toml') }}- + ${{ matrix.BUILD_TYPE }}-14- - name: Cache cargo rslib uses: actions/cache@v1 with: path: ${{ github.workspace }}${{ matrix.SEP }}rslib${{ matrix.SEP }}target - key: ${{ runner.os }}-cargo-rslib-${{ hashFiles('**/Cargo.toml') }}-${{ matrix.BUILD_TYPE }}-14- + key: | + ${{ runner.os }}-cargo-rslib- + ${{ hashFiles('**/requirements.*') }}- + ${{ hashFiles('**/setup.py') }}- + ${{ hashFiles('**/Makefile') }}- + ${{ hashFiles('**/Cargo.toml') }}- + ${{ matrix.BUILD_TYPE }}-14- - name: Cache cargo rspy uses: actions/cache@v1 with: path: ${{ github.workspace }}${{ matrix.SEP }}rspy${{ matrix.SEP }}target - key: ${{ runner.os }}-cargo-rspy-${{ hashFiles('**/Cargo.toml') }}-${{ matrix.BUILD_TYPE }}-14- + key: | + ${{ runner.os }}-cargo-rspy- + ${{ hashFiles('**/requirements.*') }}- + ${{ hashFiles('**/setup.py') }}- + ${{ hashFiles('**/Makefile') }}- + ${{ hashFiles('**/Cargo.toml') }}- + ${{ matrix.BUILD_TYPE }}-14- - name: Cache pacman if: matrix.os == 'windows-latest' @@ -143,7 +179,9 @@ jobs: id: cache-pacman with: path: C:\Program Files\Git - key: ${{ runner.os }}-pacman-${{ hashFiles('**/checks.yml') }}-14- + key: | + ${{ runner.os }}-pacman- + ${{ hashFiles('**/checks.yml') }}-14- - name: Set up pacman, rsync if: matrix.os == 'windows-latest' && steps.cache-pacman.outputs.cache-hit != 'true'