Skip to content

Commit

Permalink
vendor sqlcipher and build pysqlcipher3 amalgamation (#135)
Browse files Browse the repository at this point in the history
* move code into src

* matrixify py version

* add sqlcipher build script

* add build script

* vendor sqlcipher

* only one matrix build

* without cibuild

* fix rename

* fix upload path

* multi arch

* add setuptools

* failfast=false

* multi linux python

* single py version

* try again for mac

* cd

* remove Dockerfile

* pytest

* single cicd

* fix

* try this

* try this

* rename macos wheel

* add sdist

* add sqlcipher readme

* rename
  • Loading branch information
carderne authored Jul 31, 2024
1 parent 26b2d89 commit 83a4ed8
Show file tree
Hide file tree
Showing 26 changed files with 275,017 additions and 181 deletions.
12 changes: 0 additions & 12 deletions .dockerignore

This file was deleted.

30 changes: 0 additions & 30 deletions .github/workflows/build.yml

This file was deleted.

100 changes: 0 additions & 100 deletions .github/workflows/cicd.yml

This file was deleted.

97 changes: 97 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: release

on:
push:
tags:
- '*'
workflow_dispatch:

jobs:
build:
name: build ${{ matrix.os }} ${{ matrix.py }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest"]
fail-fast: false
steps:
- uses: actions/checkout@v4

- name: prep pysqlcipher3
run: |
git clone --depth=1 --branch=master https://github.com/rigglemania/pysqlcipher3.git
cd pysqlcipher3
mkdir amalgamation
cp ../sqlcipher/sqlite3.[ch] amalgamation
mkdir src/python3/sqlcipher
cp ../sqlcipher/sqlite3.[ch] src/python3/sqlcipher
pip install setuptools
- name: build pysqlcipher3 linux
if: matrix.os == 'ubuntu-latest'
run: |
cd pysqlcipher3
python setup.py build_amalgamation
python setup.py build
- name: build pysqlcipher3 macOS
if: matrix.os == 'macos-latest'
run: |
brew install openssl
export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib"
export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include"
cd pysqlcipher3
python setup.py build_amalgamation
python setup.py build
- name: post-build pysqlcipher3
run: |
mkdir src/pysqlcipher3
for f in pysqlcipher3/build/lib.*/pysqlcipher3/*.{py,so}; do cp $f src/pysqlcipher3/; done
- name: build
run: |
pip install build
python -m build
PLATFORM_TAG=$(python -c 'import sysconfig; print(sysconfig.get_platform().replace("-", "_").replace(".", "_"))')
cd dist
NEW_NAME=$(ls *.whl | sed "s/any.whl$/${PLATFORM_TAG}.whl/")
mv *.whl $NEW_NAME
echo "WHEEL_NAME=$(ls *.whl)" >> $GITHUB_ENV
echo "SDIST_NAME=$(ls *.tar.gz)" >> $GITHUB_ENV
- name: test
run: |
pip install dist/*.whl pytest
pytest
- uses: actions/upload-artifact@v4
with:
name: ${{ env.WHEEL_NAME }}
path: "dist/*.whl"

- uses: actions/upload-artifact@v4
# only do this once
if: matrix.os == 'ubuntu-latest'
with:
name: ${{ env.SDIST_NAME }}
path: "dist/*.tar.gz"

upload:
needs: [build]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4

- name: Copy artifacts to dist/ folder
run: |
mkdir -p dist/
find . -name '*.tar.gz' -exec mv '{}' dist/ \;
find . -name '*.whl' -exec mv '{}' dist/ \;
- name: Upload
uses: pypa/[email protected]
with:
password: ${{ secrets.PYPI_API_TOKEN }}
skip_existing: true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Custom
src/pysqlcipher3

# OS generated files
.DS_Store

Expand Down
25 changes: 0 additions & 25 deletions Dockerfile

This file was deleted.

15 changes: 5 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ dependencies = [
"emoji ~= 2.0",
"Markdown ~= 3.4",
"typer[all] ~= 0.7",
"pycryptodome~=3.20.0",
"pycryptodome ~= 3.20.0",
]

[tool.rye]
Expand All @@ -53,12 +53,6 @@ dev-dependencies = [
"types-emoji",
]

[project.optional-dependencies]
sql = [
'pysqlcipher3 == 1.1.0; python_version < "3.11"',
'pysqlcipher3 >= 1.2.0; python_version >= "3.11"',
]

[project.urls]
homepage = "https://github.com/carderne/signal-export"
repository = "https://github.com/carderne/signal-export"
Expand All @@ -71,14 +65,14 @@ requires = ["pdm-backend"]
build-backend = "pdm.backend"

[tool.pdm.build]
includes = ["sigexport/"]
includes = ["src/"]

[tool.pdm.version]
source = "scm"

[tool.ruff]
target-version = "py39"
exclude = ["tests"]
exclude = ["tests", "src/pysqlcipher3"]

[tool.ruff.lint]
select = [
Expand All @@ -101,7 +95,8 @@ known-first-party = ["sigexport"]
[tool.pyright]
venvPath = "."
venv = ".venv"
include = ["sigexport", "tests"]
include = ["src/sigexport", "tests"]
ignore = ["src/pysqlcipher3"]
reportMissingImports = true
reportMissingParameterType = true
reportUnnecessaryTypeIgnoreComment = true
Expand Down
2 changes: 0 additions & 2 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ pygments==2.17.2
pyproject-hooks==1.0.0
# via build
pyright==1.1.354
pysqlcipher3==1.2.0
# via signal-export
pytest==8.1.1
# via pytest-cov
pytest-cov==4.1.0
Expand Down
2 changes: 0 additions & 2 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ pycryptodome==3.20.0
# via signal-export
pygments==2.17.2
# via rich
pysqlcipher3==1.2.0
# via signal-export
rich==13.7.1
# via typer
shellingham==1.5.4
Expand Down
14 changes: 14 additions & 0 deletions sqlcipher/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# sqlcipher

Copyright belongs to [SQLite](https://www.sqlite.org/) and [Zetetic](https://github.com/sqlcipher/sqlcipher?tab=License-1-ov-file).

This is a vendored amalgamation build of SQLCipher, built as follows:
```bash
apt-get update
apt-get install -y git gcc libsqlite3-dev tclsh libssl-dev libc6-dev make

git clone --depth=1 --branch=master https://github.com/sqlcipher/sqlcipher.git
cd sqlcipher
./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="-lcrypto -lsqlite3"
make sqlite3.c
```
Loading

0 comments on commit 83a4ed8

Please sign in to comment.