Skip to content

Commit

Permalink
Inline build version handling in craft_packages
Browse files Browse the repository at this point in the history
  • Loading branch information
mara004 committed Nov 23, 2023
1 parent 3b418eb commit 9a1dcd3
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 56 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/conda.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,8 @@ jobs:
git config --global user.name "geisserml"
python -m pip install -U -r req/setup.txt
- name: Build raw package
if: inputs.package == 'raw'
run: |
python setupsrc/pypdfium2_setup/autorelease_conda_raw.py --pdfium-ver ${{ inputs.pdfium_ver }}
./run craft --pdfium-ver ${{ inputs.pdfium_ver }} conda_raw
- name: Build helpers package
if: inputs.package == 'helpers'
run: ./run craft --pdfium-ver ${{ inputs.pdfium_ver }} conda_helpers
- name: Build package
run: ./run craft --pdfium-ver "${{ inputs.pdfium_ver }}" conda_${{ inputs.package }}

- name: Upload artifact
uses: actions/upload-artifact@v3
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ jobs:
- name: Trigger conda pypdfium2_helpers build
uses: benc-uk/workflow-dispatch@v1
with:
# FIXME input not respected for py_version here
workflow: conda.yaml
inputs: |
{
Expand Down
43 changes: 0 additions & 43 deletions setupsrc/pypdfium2_setup/autorelease_conda_raw.py

This file was deleted.

24 changes: 20 additions & 4 deletions setupsrc/pypdfium2_setup/craft_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import os
import sys
import json
import shutil
import argparse
import tempfile
Expand Down Expand Up @@ -52,7 +53,8 @@ def parse_args():
)

args = root_parser.parse_args()
if not args.pdfium_ver or args.pdfium_ver == "latest":
args.is_literal_latest = args.pdfium_ver == "latest"
if not args.pdfium_ver or args.is_literal_latest:
args.pdfium_ver = PdfiumVer.get_latest()
else:
args.pdfium_ver = int(args.pdfium_ver)
Expand Down Expand Up @@ -164,12 +166,26 @@ def main_conda_bundle(args):
_run_conda_bundle(args, Host.platform, suffix, conda_args)


def _get_build_num(args):

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

if args.is_literal_latest:
assert args.pdfium_ver > max([int(d["version"]) for d in search]), "Literal latest must resolve to a new version. This is done to avoid rebuilds without new version in scheduled releases. If you want to rebuild, omit --pdfium-ver or pass the resolved value."

# determine build number
build_num = max([d["build_number"] for d in search if int(d["version"]) == args.pdfium_ver], default=None)
build_num = 0 if build_num is None else build_num+1

return build_num


def main_conda_raw(args):
os.environ["PDFIUM_SHORT"] = str(args.pdfium_ver)
os.environ["PDFIUM_FULL"] = ".".join([str(v) for v in PdfiumVer.to_full(args.pdfium_ver)])
assert CondaRaw_BuildNumF.exists(), "build number must be given explicitly through conda/raw/build_num.txt - run autorelease_conda_raw.py to create"
build_num = int(CondaRaw_BuildNumF.read_text().strip())
os.environ["BUILD_NUM"] = str(build_num)
os.environ["BUILD_NUM"] = str(_get_build_num(args))
emplace_func = partial(prepare_setup, ExtPlats.system, args.pdfium_ver, use_v8=None)
with CondaExtPlatfiles(emplace_func):
run_conda_build(CondaDir/"raw", CondaDir/"raw"/"out", args=["--override-channels", "-c", "bblanchon"])
Expand Down

0 comments on commit 9a1dcd3

Please sign in to comment.