Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created the GitHub Actions step Upload to PyPi #535

Merged
merged 3 commits into from
Apr 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 68 additions & 8 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,53 +97,91 @@ 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'
uses: actions/cache@v1
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'
Expand Down Expand Up @@ -239,3 +277,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/*
8 changes: 7 additions & 1 deletion pylib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
######################
Expand Down Expand Up @@ -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 $@
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a change that was required for the sdist work you were doing, and should not be needed at the moment?

Copy link
Contributor Author

@evandrocoan evandrocoan Apr 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. This is only required if you try to build anki as sdist instead of bdist_wheel. But having this allow me to use sdist too and cargo already requires this make rule to update its version. So it is just something you have to do anyway (for cargo.toml).

4 changes: 4 additions & 0 deletions pylib/pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"]
26 changes: 14 additions & 12 deletions pylib/setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import setuptools

with open("../meta/version") as fh:
version = fh.read().strip()
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",
Expand All @@ -16,13 +26,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,
)
2 changes: 2 additions & 0 deletions qt/setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hasnt utf8 been the default for a long time now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import os

import setuptools
Expand Down
6 changes: 4 additions & 2 deletions rslib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this mail address here intended? I'd expect this to rather point to Anki support page

Copy link
Contributor Author

@evandrocoan evandrocoan Apr 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not know any anki support email and pypi is rejecting the wheel if there is no email.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dae, is there an email for support?

license = "AGPL-3.0-or-later"
description = "Anki's Rust library code"
readme = "README.md"

[dependencies]
nom = "5.0.1"
Expand Down
2 changes: 1 addition & 1 deletion rslib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 $@
3 changes: 3 additions & 0 deletions rslib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Anki's Rust library code

https://anki.tenderapp.com/discussions/ankidesktop/40025-anki-in-python-package-index
7 changes: 5 additions & 2 deletions rspy/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

license = "AGPL-3.0-or-later"
description = "Anki's Rust library code Python bindings"
readme = "README.md"

[dependencies]
anki = { path = "../rslib" }
Expand Down
2 changes: 1 addition & 1 deletion rspy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 $@
3 changes: 3 additions & 0 deletions rspy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Anki's Rust library code Python bindings

https://anki.tenderapp.com/discussions/ankidesktop/40025-anki-in-python-package-index