Skip to content

Commit

Permalink
Merge pull request #269 from pypdfium2-team/conda_ci
Browse files Browse the repository at this point in the history
Conda CI
  • Loading branch information
mara004 authored Oct 31, 2023
2 parents 1565920 + 5227e2b commit 7431eca
Show file tree
Hide file tree
Showing 11 changed files with 242 additions and 30 deletions.
149 changes: 149 additions & 0 deletions .github/workflows/conda.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# SPDX-FileCopyrightText: 2023 geisserml <[email protected]>
# SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause

name: Conda packaging
on:
workflow_dispatch:
inputs:
package:
type: choice
default: raw
options:
- raw
- helpers
test:
default: true
type: boolean
publish:
default: false
type: boolean
py_version:
default: '3.11'
type: string

# This is required for setup-miniconda / conda init
# see https://github.com/conda-incubator/setup-miniconda#important
defaults:
run:
shell: bash -el {0}

jobs:

build:

runs-on: ubuntu-latest
steps:

- name: Check out repository
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}
fetch-depth: 0

- name: Miniconda setup
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ inputs.py_version }}
channels: bblanchon,pypdfium2-team
channel-priority: strict

- name: Prepare
run: |
python -VV
conda install -y conda-build conda-verify
git config --global user.email "[email protected]"
git config --global user.name "geisserml"
python -m pip install -U -r req/setup.txt
- name: Build package
run: ./run craft conda_${{ inputs.package }}

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: conda_package
path: conda/${{ inputs.package }}/out/

test:

if: ${{ inputs.test }}
needs: build

strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'macos-latest', 'windows-latest']
py: ['3.8', '3.9', '3.10', '3.11']

runs-on: ${{ matrix.os }}

steps:

- name: Check out repository
uses: actions/checkout@v4
with:
repository: ${{ github.repository }}

- name: Miniconda setup
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.py }}
channels: bblanchon,pypdfium2-team
channel-priority: strict

- name: Download artifact
uses: actions/download-artifact@v3
with:
name: conda_package
path: conda_dist/

- name: Prepare
run: |
python -VV
ls -l conda_dist/
conda install -y pypdfium2_${{ inputs.package }} -c bblanchon -c pypdfium2-team -c ./conda_dist/
- name: Test raw package
if: inputs.package == 'raw'
run: python conda/raw/minitest.py

- name: Test helpers package
if: inputs.package == 'helpers'
run: |
conda install -y pytest pillow numpy
./run test
publish:

if: ${{ inputs.publish }}
needs: [build, test]
runs-on: ubuntu-latest

steps:

- name: Miniconda setup
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: ${{ matrix.py }}
channels: bblanchon,pypdfium2-team
channel-priority: strict

- name: Install deps
run: conda install -y anaconda-client

- name: Download artifact
uses: actions/download-artifact@v3
with:
name: conda_package
path: conda_dist/

- name: Upload to Anaconda
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_API_TOKEN }}
run: |
ARTIFACT_PATH=conda_dist/noarch/pypdfium2_${{ inputs.package }}-*.tar.bz2
file $ARTIFACT_PATH
anaconda upload $ARTIFACT_PATH
4 changes: 0 additions & 4 deletions .github/workflows/gh_pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ concurrency:
group: "pages"
cancel-in-progress: true

defaults:
run:
shell: bash

jobs:

build:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2023 geisserml <[email protected]>
# SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause

name: Build Packages
name: Main packaging
on:
workflow_dispatch:
inputs:
Expand All @@ -14,6 +14,9 @@ on:
publish:
default: false
type: boolean
conda:
default: false
type: boolean
py_version:
default: '3.10'
type: string
Expand Down Expand Up @@ -232,10 +235,27 @@ jobs:
with:
workflow: gh_pages.yaml # takes no inputs

conda_trigger:
needs: [build, test, publish]
if: ${{ inputs.conda && !cancelled() && !contains(needs.*.result, 'failure') }}
runs-on: ${{ inputs.runner }}

steps:
- name: Trigger conda pypdfium2_helpers build
uses: benc-uk/workflow-dispatch@v1
with:
workflow: conda.yaml
inputs: |
{
"package": "helpers",
"test": "true",
"publish": "${{ inputs.publish }}",
"py_version": "3.11"
}
cleanup:
needs: [build, test, publish]
if: always()
needs: [build, test, publish, conda_trigger]
if: ${{ !cancelled() }}
runs-on: ${{ inputs.runner }}

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_release.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2023 geisserml <[email protected]>
# SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause

name: Test Release
name: Test PyPI Release
on:
workflow_dispatch:
inputs:
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/trigger_conda_raw.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SPDX-FileCopyrightText: 2023 geisserml <[email protected]>
# SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause

name: Trigger conda_raw release
on:
schedule:
# 1 day after pdfium-binaries
- cron: '0 4 * * 2'
workflow_dispatch:

jobs:

trigger:
runs-on: ubuntu-latest

steps:
- name: Trigger
uses: benc-uk/workflow-dispatch@v1
with:
workflow: conda.yaml
inputs: |
{
"package": "raw",
"test": "true",
"publish": "true",
"py_version": "3.11"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# Separate trigger workflow because we can't configure inputs for scheduled workflow runs (and don't want publish enabled by default in the main workflow)

name: Trigger Release
name: Trigger main release
on:
# https://github.com/bblanchon/pdfium-binaries/blob/master/.github/workflows/trigger.yml
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule
Expand All @@ -13,17 +13,13 @@ on:
# - cron: '0 4 * * 2' # old weekly schedule
workflow_dispatch:

defaults:
run:
shell: bash

jobs:

release:
trigger:
runs-on: ubuntu-latest

steps:
- name: Trigger Release
- name: Trigger
uses: benc-uk/workflow-dispatch@v1
with:
workflow: build_packages.yaml
Expand All @@ -32,6 +28,7 @@ jobs:
"pre_test": "false",
"test": "true",
"publish": "true",
"conda": "true",
"py_version": "3.10",
"runner": "ubuntu-latest"
}
37 changes: 31 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,43 @@ pypdfium2 includes helpers to simplify common use cases, while the raw PDFium/ct

## Installation

<!-- TODO use linkable sub-sections? -->

* From PyPI (recommended)
```bash
python3 -m pip install -U pypdfium2
```
This will use a pre-built wheel package, the easiest way of installing pypdfium2.


* From Conda

**Beware:** There have been some third-party attempts to conda package pypdfium2 and pdfium-binaries. **Any recipes/packages that might be provided by other distributors, including `anaconda/main` or `conda-forge`, are unofficial!** See below for more info.

To install the official package:
```bash
conda config --add channels bblanchon
conda config --add channels pypdfium2-team
conda config --set channel_priority strict
conda install pypdfium2-team::pypdfium2_helpers -c bblanchon -c pypdfium2-team
```
You may add `--env` to the `conda config` calls for environment-local config.

To check if the channels are correct:
```bash
conda list --show-channel-urls "pypdfium2|pdfium-binaries"
conda config --show-sources
```

To depend on pypdfium2 in a recipe:
```yaml
requirements:
run:
- pypdfium2-team::pypdfium2_helpers
```
You'll want to have downstream callers add the channels as shown above.
* From source
* Dependencies:
Expand Down Expand Up @@ -63,12 +94,6 @@ pypdfium2 includes helpers to simplify common use cases, while the raw PDFium/ct

[^pdfium_buildsystem]: This means pdfium may not compile on arbitrary hosts. The script is limited to build hosts supported by Google's toolchain. Ideally, we'd need an alternative build system that runs with system packages instead.

* Conda
pypdfium2 will soon provide official conda packages in a custom channel.
The main packaging code is merged, only CI integration / docs are not done yet.
**Beware:** There have been some third-party attempts to conda package pypdfium2/pdfium-binaries. **Any recipes/packages that might be provided by other distributors, including `anaconda/main` or `conda-forge`, are unofficial!**

* Unofficial packages

Expand Down
2 changes: 0 additions & 2 deletions conda/bundle/recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

{% set helpers_ver = environ["M_HELPERS_VER"] %}
{% set git_depth = environ["M_GIT_DEPTH"] %}
{% set pl_spec = environ["IN_PDFIUM_PLATFORM"] %}
# {% set setup_cfg = load_file_data("setup.cfg") %}

Expand All @@ -18,7 +17,6 @@ package:

source:
git_url: ../../..
git_depth: {{ git_depth }}

build:
number: 0
Expand Down
4 changes: 1 addition & 3 deletions conda/helpers/recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@

{% set pdfium_max = environ["PDFIUM_MAX"] %}
{% set helpers_ver = environ["M_HELPERS_VER"] %}
{% set git_depth = environ["M_GIT_DEPTH"] %}

package:
name: pypdfium2
name: pypdfium2_helpers
version: {{ helpers_ver }}

source:
git_url: ../../..
git_depth: {{ git_depth }}

build:
number: 0
Expand Down
2 changes: 0 additions & 2 deletions conda/raw/recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@

{% set pdfium_short = environ["PDFIUM_SHORT"] %}
{% set pdfium_full = environ["PDFIUM_FULL"] %}
{% set git_depth = environ["M_GIT_DEPTH"] %}

package:
name: pypdfium2_raw
version: {{ pdfium_short }}

source:
git_url: ../../..
git_depth: {{ git_depth }}

build:
number: 0
Expand Down
Loading

0 comments on commit 7431eca

Please sign in to comment.