Skip to content

Commit

Permalink
Fix CI (#13)
Browse files Browse the repository at this point in the history
* Use the pypa/cibuildwheel GitHub Action rather than the lib manually.
* Shuffled things around in the YAML until it was finally working.
* Now the build uses defaults which Just Work.
* Upload artifacts, including to PyPi (test for now).
* Bump dependencies (or build would fail).
* Remove broken submodule.
* Python versions below 3.6 are not supported.
  • Loading branch information
Lonami authored Sep 26, 2021
1 parent 8482445 commit b105ae7
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 31 deletions.
54 changes: 35 additions & 19 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,52 @@ name: Build
on:
push:
tags:
- 'v*'
- 'v*'

jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04, windows-2019, macOS-10.15]

env:
CIBW_SKIP: ?p27-*
CIBW_BUILD_VERBOSITY: 3
BUILD_OUTPUT_PATH: wheelhouse
os: [ubuntu-20.04, windows-2019, macos-10.15]

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Install requirements
run: |
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=stable
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==1.10.0
- uses: pypa/[email protected]
env:
CIBW_BUILD_VERBOSITY: "1"
CIBW_BEFORE_ALL_LINUX: "curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y && yum install -y openssl-devel"
CIBW_ENVIRONMENT: 'PATH="$PATH:$HOME/.cargo/bin"'
CIBW_SKIP: "*-win32"

- name: Build wheels
run: python -m cibuildwheel --output-dir "$BUILD_OUTPUT_PATH"
- uses: actions/upload-artifact@v2
with:
path: ./wheelhouse/*.whl

build_sdist:
name: Build source distribution
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Build sdist
run: python -m pip install -r requirements.txt && python setup.py sdist
- uses: actions/upload-artifact@v2
with:
path: "./$BUILD_OUTPUT_PATH/*.whl"
path: dist/*.tar.gz

upload_pypi:
needs: [build_wheels, build_sdist]
runs-on: ubuntu-20.04
steps:
- uses: actions/download-artifact@v2
with:
name: artifact
path: dist

- uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.pypi_token }}
repository_url: https://test.pypi.org/legacy/
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ authors = ["Lonami Exo <[email protected]>"]
edition = "2018"

[dependencies]
grammers-crypto = "0.2.0"
pyo3 = { version = "0.13.2", features = ["extension-module"] }
grammers-crypto = "0.3.0"
pyo3 = { version = "0.14.4", features = ["extension-module"] }

[lib]
name = "cryptg"
Expand Down
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ cryptg
This is a small native extension for Python 3 to help libraries that want to
work with the Telegram API, which uses the uncommon AES-IGE mode for it.

Note that while this wrapper library is licensed under CC0, the Rust dependencies
have their own license.

.. |logo| image:: https://raw.githubusercontent.com/cher-nov/cryptg/master/logo.png
:target: https://github.com/cher-nov/cryptg
:alt: cryptg
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build-system]
requires = [
"setuptools-rust>=0.12.1",
"setuptools>=58.1.0",
"wheel>=0.37.0",
]
6 changes: 3 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
setuptools-rust
setuptools
wheel
setuptools-rust>=0.12.1
setuptools>=58.1.0
wheel>=0.37.0
9 changes: 5 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ def main(args):
"License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication",

"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6"
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
],
keywords="telegram crypto cryptography mtproto aes",

Expand Down
1 change: 0 additions & 1 deletion share/tiny-AES-c
Submodule tiny-AES-c deleted from 58cbfc
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use pyo3::{prelude::*, types::PyBytes, wrap_pyfunction};

/// Encrypts the input plain text with the 32 bytes key and IV.
#[pyfunction]
#[text_signature = "(plain, key, iv)"]
#[pyo3(text_signature = "(plain, key, iv)")]
fn encrypt_ige(plain: &[u8], key: &[u8], iv: &[u8]) -> PyResult<Py<PyBytes>> {
let mut key_array = [0; 32];
if key.len() != key_array.len() {
Expand All @@ -22,7 +22,7 @@ fn encrypt_ige(plain: &[u8], key: &[u8], iv: &[u8]) -> PyResult<Py<PyBytes>> {

/// Decrypts the input cipher text with the 32 bytes key and IV.
#[pyfunction]
#[text_signature = "(cipher, key, iv)"]
#[pyo3(text_signature = "(cipher, key, iv)")]
fn decrypt_ige(cipher: &[u8], key: &[u8], iv: &[u8]) -> PyResult<Py<PyBytes>> {
let mut key_array = [0; 32];
if key.len() != key_array.len() {
Expand Down

0 comments on commit b105ae7

Please sign in to comment.