Skip to content

Commit

Permalink
use conda's json option
Browse files Browse the repository at this point in the history
  • Loading branch information
mara004 committed Nov 22, 2023
1 parent 4fbd7c4 commit 3456cdb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
14 changes: 9 additions & 5 deletions .github/workflows/conda.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,16 @@ jobs:
git config --global user.name "geisserml"
python -m pip install -U -r req/setup.txt
# this is used to automatically manage build number for rebuilds of the raw package
- name: Autorelease (raw package)
run: python setupsrc/pypdfium2_setup/autorelease_conda_raw.py --pdfium-ver ${{ inputs.raw_version }}
# the script is used to automatically manage build number for rebuilds of the raw package
- name: Build raw package
if: inputs.package == 'raw'
run: |
python setupsrc/pypdfium2_setup/autorelease_conda_raw.py --pdfium-ver ${{ inputs.raw_version }}
./run craft conda_raw --pdfium-ver ${{ inputs.raw_version }}
- name: Build package
run: ./run craft conda_${{ inputs.package }}
- name: Build helpers package
if: inputs.package == 'helpers'
run: ./run craft conda_helpers

- name: Upload artifact
uses: actions/upload-artifact@v3
Expand Down
13 changes: 5 additions & 8 deletions setupsrc/pypdfium2_setup/autorelease_conda_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# SPDX-FileCopyrightText: 2023 geisserml <[email protected]>
# SPDX-License-Identifier: Apache-2.0 OR BSD-3-Clause

import re
import sys
import json
import argparse
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parents[1]))
Expand All @@ -21,15 +21,12 @@ def main():
args.pdfium_ver = int(args.pdfium_ver)

# parse existing releases to automatically handle arbitrary version builds
search = run_cmd(["conda", "search", "pypdfium2_raw", "--override-channels", "-c", "pypdfium2-team"], cwd=None, capture=True)
print(search, file=sys.stderr)

search = [(int(v), int(b.split("_")[1])) for (v, b) in [re.split(r"\s+", l)[1:3] for l in reversed(search.split("\n")[2:])]]
print(search, file=sys.stderr)
search = run_cmd(["conda", "search", "--json", "pypdfium2_raw", "--override-channels", "-c", "pypdfium2-team"], cwd=None, capture=True)
search = reversed(json.loads(search)["pypdfium2_raw"])

# determine build number
# TODO `search` is ordered descendingly, so we could break the iteration when we find a match. though for a new version, we have to traverse the full list anyway...
build = max([b for v, b in search if v == args.pdfium_ver], default=None)
# TODO `search` is ordered descendingly, so we could break the iteration when we find a matching version. though for a new version, we have to traverse the full list anyway...
build = max([d["build_number"] for d in search if int(d["version"]) == args.pdfium_ver], default=None)
build = 0 if build is None else build+1
print(build, file=sys.stderr)

Expand Down

0 comments on commit 3456cdb

Please sign in to comment.