Skip to content

Commit

Permalink
scripts/: minor improvements to venv and use on OpenBSD
Browse files Browse the repository at this point in the history
Fixes to work on OpenBSD with system libclang. And always upgrade pip when
creating venv.
  • Loading branch information
julian-smith-artifex-com committed Nov 16, 2023
1 parent ee359b3 commit bed43ac
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
9 changes: 7 additions & 2 deletions scripts/gh_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,15 +403,20 @@ def venv( command=None, packages=None):
ssp = ''
if platform.system() == 'OpenBSD':
# libclang not available from pypi.org, but system py3-llvm package
# works.
# works. `pip install` should be run with --no-build-isolation and
# explicit `pip install swig setuptools psutil`.
ssp = ' --system-site-packages'
log(f'OpenBSD: libclang not available from pypi.org.')
log(f'OpenBSD: system package `py3-llvm` must be installed.')
log(f'OpenBSD: creating venv with --system-site-packages.')
log(f'OpenBSD: `pip install .../PyMuPDF` must be preceded by install of swig etc.')
command2 += f'{sys.executable} -m venv{ssp} {venv_name}'
if platform.system() == 'Windows':
command2 += f' && {venv_name}\\Scripts\\activate'
else:
command2 += f' && . {venv_name}/bin/activate'
command2 += ' && python -m pip install --upgrade pip'
if packages:
command2 += ' && python -m pip install --upgrade pip'
if isinstance(packages, str):
packages = packages.split(',')
command2 += ' && pip install ' + ' '.join(packages)
Expand Down
19 changes: 17 additions & 2 deletions scripts/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import gh_release

import os
import platform
import sys


Expand Down Expand Up @@ -82,12 +83,26 @@ def main(argv):


def build():
gh_release.run(f'pip install -vv {pymupdf_dir}')
nbi = ''
if platform.system() == 'OpenBSD':
# libclang not available on pypi.org, so we need to force use of system
# package py3-llvm with --no-build-isolation, manually installing other
# required packages.
gh_release.run(f'pip install swig setuptools psutil')
gh_release.run(f'pip install --no-build-isolation -vv {pymupdf_dir}')
else:
gh_release.run(f'pip install{nbi} -vv {pymupdf_dir}')


def test():
gh_release.run(f'pip install pytest fontTools psutil')
gh_release.run(f'{sys.executable} {pymupdf_dir}/tests/run_compound.py pytest -s {pymupdf_dir}')
if platform.system() == 'OpenBSD':
# On OpenBSD `pip install pytest` doesn't seem to install the pytest
# command, so we use `python -m pytest ...`. (This doesn't work on
# Windows for some reason so we don't use it all the time.)
gh_release.run(f'{sys.executable} {pymupdf_dir}/tests/run_compound.py python -m pytest -s {pymupdf_dir}')
else:
gh_release.run(f'{sys.executable} {pymupdf_dir}/tests/run_compound.py pytest -s {pymupdf_dir}')


if __name__ == '__main__':
Expand Down

0 comments on commit bed43ac

Please sign in to comment.