Skip to content

Commit

Permalink
Rename craft_packages to craft_wheels
Browse files Browse the repository at this point in the history
and move artefact restoring logic into a class
  • Loading branch information
mara004 committed Sep 14, 2022
1 parent 05d5fb0 commit 4d564ff
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ update-all:
python3 ./setupsrc/pl_setup/update_pdfium.py

setup-all:
python3 ./setupsrc/pl_setup/craft_packages.py
python3 ./setupsrc/pl_setup/craft_wheels.py

packaging:
bash ./utilities/packaging.sh
Expand Down
2 changes: 1 addition & 1 deletion docs/devel/tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Also see the issues panel and inline `TODO` marks in source code.
* Consolidate and extend helper classes.

### Setup Infrastructure
* craft_packages: add means to skip platforms for which artefacts are missing.
* craft_wheels: add means to skip platforms for which artefacts are missing.
* update_pdfium: only generate the bindings file once for all platforms.
* update_pdfium: add option to download a custom pdfium-binaries release (i. e. not the latest).
* packaging_base: use a class for `VerNamespace` so it can be flushed more easily (?)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,30 @@
)


class ArtefactStash:

# Preserve in-tree aftefacts from editable install

def __init__(self):

self.tmp_dir = None
self.plfile_names = [BindingsFileName, LibnameForSystem[Host.system]]
self.plfile_paths = [join(ModuleDir, fn) for fn in self.plfile_names]

if not any(os.path.exists(fp) for fp in self.plfile_paths):
return
self.tmp_dir = tempfile.TemporaryDirectory(prefix="pypdfium2_artefact_stash_")
for fp in self.plfile_paths:
shutil.move(fp, self.tmp_dir.name)

def pop(self):
if self.tmp_dir is None:
return
for fn in self.plfile_names:
shutil.move(join(self.tmp_dir.name, fn), ModuleDir)
self.tmp_dir.cleanup()


def run_build(args):
run_cmd([sys.executable, "-m", "build", "--skip-dependency-check", "--no-isolation"] + args, cwd=SourceTree, env=os.environ)

Expand All @@ -38,18 +62,8 @@ def main():
)
args = parser.parse_args()

# Push possible in-tree artefacts from editable install to stash
tmp_dir = None
platfiles = (
join(ModuleDir, BindingsFileName),
join(ModuleDir, LibnameForSystem[Host.system]),
)
if any(os.path.exists(fp) for fp in platfiles):
tmp_dir = tempfile.TemporaryDirectory(prefix="pypdfium2_artefact_stash_")
for fp in platfiles:
shutil.move(fp, tmp_dir.name)
stash = ArtefactStash()

clean_artefacts()
os.environ[BinaryTargetVar] = BinaryTarget_None
run_build(["--sdist"])
clean_artefacts()
Expand All @@ -59,11 +73,7 @@ def main():
run_build(["--wheel"])
clean_artefacts()

# Pop stash
if tmp_dir is not None:
for fn in os.listdir(tmp_dir.name):
shutil.move(join(tmp_dir.name, fn), ModuleDir)
tmp_dir.cleanup()
stash.pop()


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion utilities/packaging.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ bash utilities/install.sh
python3 -m pytest tests/

python3 ./setupsrc/pl_setup/update_pdfium.py
python3 ./setupsrc/pl_setup/craft_packages.py
python3 ./setupsrc/pl_setup/craft_wheels.py

twine check dist/*
check-wheel-contents dist/*.whl

0 comments on commit 4d564ff

Please sign in to comment.