Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/samples/story-write-stabilized-links.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def contentfn(positions):
ret += f" <li><a href=\"#{position.id}\">{text}</a>\n"
else:
ret += f" <li>{text}\n"
ret += f" <ul>\n"
ret += " <ul>\n"
ret += f" <li>page={position.page_num}\n"
ret += f" <li>depth={position.depth}\n"
ret += f" <li>heading={position.heading}\n"
Expand All @@ -51,12 +51,12 @@ def contentfn(positions):
ret += f" <li>rect={position.rect}\n"
ret += f" <li>text={text!r}\n"
ret += f" <li>open_close={position.open_close}\n"
ret += f" </ul>\n"
ret += " </ul>\n"

ret += '</ul>\n'

# Main content.
ret += textwrap.dedent(f'''
ret += textwrap.dedent('''

<h1>First section</h1>
<p>Contents of first section.
Expand Down
6 changes: 3 additions & 3 deletions docs/samples/story-write-stabilized.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def contentfn(positions):
ret += f" <li><a href=\"#{position.id}\">{text}</a>\n"
else:
ret += f" <li>{text}\n"
ret += f" <ul>\n"
ret += " <ul>\n"
ret += f" <li>page={position.page_num}\n"
ret += f" <li>depth={position.depth}\n"
ret += f" <li>heading={position.heading}\n"
Expand All @@ -55,12 +55,12 @@ def contentfn(positions):
ret += f" <li>rect={position.rect}\n"
ret += f" <li>text={text!r}\n"
ret += f" <li>open_close={position.open_close}\n"
ret += f" </ul>\n"
ret += " </ul>\n"

ret += '</ul>\n'

# Main content.
ret += textwrap.dedent(f'''
ret += textwrap.dedent('''

<h1>First section</h1>
<p>Contents of first section.
Expand Down
16 changes: 8 additions & 8 deletions pipcl.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ def add_str(content, to_):
log1( f'Have created wheel size={st.st_size}: {path}')
if g_verbose >= 2:
with zipfile.ZipFile(path, compression=self.wheel_compression) as z:
log2(f'Contents are:')
log2('Contents are:')
for zi in sorted(z.infolist(), key=lambda z: z.filename):
log2(f' {zi.file_size: 10d} {zi.filename}')

Expand Down Expand Up @@ -737,14 +737,14 @@ def add_string(text, name):
add(from_, to_rel)

if not found_pyproject_toml:
log0(f'Warning: no pyproject.toml specified.')
log0('Warning: no pyproject.toml specified.')

# Always add a PKG-INFO file.
add_string(self._metainfo(), 'PKG-INFO')

if self.license:
if 'COPYING' in names_in_tar:
log2(f'Not writing .license because file already in sdist: COPYING')
log2('Not writing .license because file already in sdist: COPYING')
else:
add_string(self.license, 'COPYING')

Expand Down Expand Up @@ -978,7 +978,7 @@ def add_str(content, to_abs, to_rel):
with open(record_path, 'w') as f:
f.write(record.get())

log2(f'Finished.')
log2('Finished.')


def _argv_dist_info(self, root):
Expand Down Expand Up @@ -1269,7 +1269,7 @@ def add(key, value):
# This is ok because we write `self.license` into
# *.dist-info/COPYING.
#
log1( f'Omitting license because contains newline(s).')
log1( 'Omitting license because contains newline(s).')
return
assert '\n' not in value, f'key={key} value contains newline: {value!r}'
if key == 'Project-URL':
Expand Down Expand Up @@ -2040,7 +2040,7 @@ def __init__(self):
#
python_config = None
for pc in (
f'python3-config',
'python3-config',
f'{sys.executable} {sysconfig.get_config_var("srcdir")}/python-config.py',
f'{python_exe}-config',
):
Expand All @@ -2054,7 +2054,7 @@ def __init__(self):
log2(f'{e=} from {pc!r}.')
if e == 0:
python_config = pc
assert python_config, f'Cannot find python-config'
assert python_config, 'Cannot find python-config'
else:
python_config = f'{python_exe}-config'
log2(f'Using {python_config=}.')
Expand Down Expand Up @@ -2254,7 +2254,7 @@ def run_if( command, out, *prerequisites):
if cmd is None:
doit = 'No previous command stored'
else:
doit = f'Command has changed'
doit = 'Command has changed'
if 0:
doit += f': {cmd!r} => {command!r}'

Expand Down
32 changes: 16 additions & 16 deletions scripts/gh_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def make_string(*items):
),
)
if env_extra.get('CIBW_ARCHS_LINUX') == '':
log(f'Not running cibuildwheel because CIBW_ARCHS_LINUX is empty string.')
log('Not running cibuildwheel because CIBW_ARCHS_LINUX is empty string.')
return

if platform.system() == 'Windows':
Expand All @@ -324,7 +324,7 @@ def make_string(*items):
),
)
if env_extra.get('CIBW_ARCHS_WINDOWS') == '':
log(f'Not running cibuildwheel because CIBW_ARCHS_WINDOWS is empty string.')
log('Not running cibuildwheel because CIBW_ARCHS_WINDOWS is empty string.')
return

if platform.system() == 'Darwin':
Expand All @@ -336,7 +336,7 @@ def make_string(*items):
),
)
if env_extra.get('CIBW_ARCHS_MACOS') == '':
log(f'Not running cibuildwheel because CIBW_ARCHS_MACOS is empty string.')
log('Not running cibuildwheel because CIBW_ARCHS_MACOS is empty string.')
return

def env_pass(name):
Expand Down Expand Up @@ -401,7 +401,7 @@ def set_cibuild_test():
assert CIBW_BUILD_old is not None
cp = cps.split()[0]
env_set('CIBW_BUILD', cp)
log(f'Building single wheel.')
log('Building single wheel.')
run( f'cibuildwheel{platform_arg}', env_extra=env_extra)

# Fake-build with all python versions, using the wheel we have
Expand All @@ -411,7 +411,7 @@ def set_cibuild_test():
# wheels having extra platform tags (from cibuildwheel's use of
# auditwheel).
#
env_set('PYMUPDF_SETUP_URL_WHEEL', f'file://wheelhouse/', pass_=True)
env_set('PYMUPDF_SETUP_URL_WHEEL', 'file://wheelhouse/', pass_=True)

set_cibuild_test()
env_set('CIBW_BUILD', CIBW_BUILD_old)
Expand All @@ -425,15 +425,15 @@ def set_cibuild_test():
env_set('CIBW_REPAIR_WHEEL_COMMAND', '')

if platform.system() == 'Linux' and env_extra.get('CIBW_ARCHS_LINUX') == 'aarch64':
log(f'Testing all Python versions on linux-aarch64 is too slow and is killed by github after 6h.')
log(f'Testing on restricted python versions using wheels in wheelhouse/.')
log('Testing all Python versions on linux-aarch64 is too slow and is killed by github after 6h.')
log('Testing on restricted python versions using wheels in wheelhouse/.')
# Testing only on first and last python versions.
cp1 = cps.split()[0]
cp2 = cps.split()[-1]
cp = cp1 if cp1 == cp2 else f'{cp1} {cp2}'
env_set('CIBW_BUILD', cp)
else:
log(f'Testing on all python versions using wheels in wheelhouse/.')
log('Testing on all python versions using wheels in wheelhouse/.')
run( f'cibuildwheel{platform_arg}', env_extra=env_extra)

elif inputs_flavours:
Expand Down Expand Up @@ -475,7 +475,7 @@ def set_cibuild_test():
# careful to avoid incompatible wheels, e.g. 32 vs 64-bit wheels
# coexist during Windows builds.
#
env_set('CIBW_BEFORE_TEST', f'python scripts/gh_release.py pip_install wheelhouse/pymupdfb')
env_set('CIBW_BEFORE_TEST', 'python scripts/gh_release.py pip_install wheelhouse/pymupdfb')

set_cibuild_test()

Expand Down Expand Up @@ -526,10 +526,10 @@ def venv( command=None, packages=None, quick=False, system_site_packages=False):
# explicit `pip install swig psutil`.
system_site_packages = True
#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.')
log('OpenBSD: libclang not available from pypi.org.')
log('OpenBSD: system package `py3-llvm` must be installed.')
log('OpenBSD: creating venv with --system-site-packages.')
log('OpenBSD: `pip install .../PyMuPDF` must be preceded by install of swig etc.')
ssp = ' --system-site-packages' if system_site_packages else ''
if quick and os.path.isdir(venv_name):
log(f'{quick=}: Not creating venv because directory already exists: {venv_name}')
Expand Down Expand Up @@ -564,9 +564,9 @@ def test( project, package, valgrind):
run(f'pip install {test_packages}')
if valgrind:
log('Installing valgrind.')
run(f'sudo apt update')
run(f'sudo apt install valgrind')
run(f'valgrind --version')
run('sudo apt update')
run('sudo apt install valgrind')
run('valgrind --version')

log('Running PyMuPDF tests under valgrind.')
# We ignore memory leaks.
Expand Down
50 changes: 25 additions & 25 deletions scripts/sysinstall.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,10 @@ def main():
log(f'{os.environ.get("PYMUDF_SCRIPTS_SYSINSTALL_ARGS_POST")=}')
log(f'{sys.argv=}')
log(f'{sysconfig.get_path("platlib")=}')
run_command(f'python -V', check=0)
run_command(f'python3 -V', check=0)
run_command(f'sudo python -V', check=0)
run_command(f'sudo python3 -V', check=0)
run_command('python -V', check=0)
run_command('python3 -V', check=0)
run_command('sudo python -V', check=0)
run_command('sudo python3 -V', check=0)
run_command(f'sudo PATH={os.environ["PATH"]} python -V', check=0)
run_command(f'sudo PATH={os.environ["PATH"]} python3 -V', check=0)

Expand Down Expand Up @@ -215,12 +215,12 @@ def run(command, env_extra=None):
# Install required system packages. We assume a Debian package system.
#
log('## Install system packages required by MuPDF.')
run(f'sudo apt update')
run('sudo apt update')
run(f'sudo apt install {" ".join(g_sys_packages)}')
# Ubuntu-22.04 has freeglut3-dev, not libglut-dev.
run(f'sudo apt install libglut-dev | sudo apt install freeglut3-dev')
run('sudo apt install libglut-dev | sudo apt install freeglut3-dev')
if tesseract5:
log(f'## Force installation of libtesseract-dev version 5.')
log('## Force installation of libtesseract-dev version 5.')
# https://stackoverflow.com/questions/76834972/how-can-i-run-pytesseract-python-library-in-ubuntu-22-04
#
run('sudo apt install -y software-properties-common')
Expand All @@ -244,20 +244,20 @@ def run(command, env_extra=None):
command += f' -j {multiprocessing.cpu_count()}'
#command += f' EXE_LDFLAGS=-Wl,--trace' # Makes linker generate diagnostics as it runs.
command += f' DESTDIR={root}'
command += f' HAVE_LEPTONICA=yes'
command += f' HAVE_TESSERACT=yes'
command += f' USE_SYSTEM_LIBS=yes'
command += ' HAVE_LEPTONICA=yes'
command += ' HAVE_TESSERACT=yes'
command += ' USE_SYSTEM_LIBS=yes'
# We need latest zxingcpp so system version not ok.
command += f' USE_SYSTEM_ZXINGCPP=no'
command += f' barcode=yes'
command += ' USE_SYSTEM_ZXINGCPP=no'
command += ' barcode=yes'
command += f' VENV_FLAG={"--venv" if pip == "venv" else ""}'
if mupdf_so_mode:
command += f' SO_INSTALL_MODE={mupdf_so_mode}'
command += f' build_prefix=system-libs-'
command += ' build_prefix=system-libs-'
command += f' prefix={prefix}'
command += f' verbose=yes'
command += f' install-shared-python'
command += f' INSTALL_MODE=755'
command += ' verbose=yes'
command += ' install-shared-python'
command += ' INSTALL_MODE=755'
run( command)

# Build+install PyMuPDF.
Expand All @@ -272,28 +272,28 @@ def run(command):
env += f'CFLAGS="{compile_flags}" '
env += f'CXXFLAGS="{compile_flags}" '
env += f'LDFLAGS="-L {root}/{prefix}/lib" '
env += f'PYMUPDF_SETUP_MUPDF_BUILD= ' # Use system MuPDF.
env += 'PYMUPDF_SETUP_MUPDF_BUILD= ' # Use system MuPDF.
if use_installer:
log(f'## Building wheel.')
log('## Building wheel.')
if pip == 'venv':
venv_name = 'venv-pymupdf-sysinstall'
run(f'pwd')
run(f'rm dist/* || true')
run('pwd')
run('rm dist/* || true')
if pip == 'venv':
run(f'{sys.executable} -m venv {venv_name}')
run(f'. {venv_name}/bin/activate && pip install --upgrade pip')
run(f'. {venv_name}/bin/activate && pip install --upgrade installer')
run(f'{env} {venv_name}/bin/python -m pip wheel -vv -w dist {os.path.abspath(pymupdf_dir)}')
elif pip == 'sudo':
#run(f'sudo pip install --upgrade pip') # Breaks on Github see: https://github.com/pypa/get-pip/issues/226.
run(f'sudo pip install installer')
run('sudo pip install installer')
run(f'{env} pip wheel -vv -w dist {os.path.abspath(pymupdf_dir)}')
else:
log(f'Not installing "installer" because {pip=}.')
wheel = glob.glob(f'dist/*')
wheel = glob.glob('dist/*')
assert len(wheel) == 1, f'{wheel=}'
wheel = wheel[0]
log(f'## Installing wheel using `installer`.')
log('## Installing wheel using `installer`.')
pv = '.'.join(platform.python_version_tuple()[:2])
p = f'{root_prefix}/lib/python{pv}'
# `python -m installer` fails to overwrite existing files.
Expand Down Expand Up @@ -352,7 +352,7 @@ def run(command, env_extra=None):
run(f'{sys.executable} -m venv {test_venv}')
# Install required packages.
command = f'. {test_venv}/bin/activate'
command += f' && pip install --upgrade pip'
command += ' && pip install --upgrade pip'
command += f' && pip install --upgrade {gh_release.test_packages}'
run(command)
elif pip == 'sudo':
Expand All @@ -374,7 +374,7 @@ def run(command, env_extra=None):
command += f' {pymupdf_dir}/scripts/test.py'
if gdb:
command += ' --gdb 1'
command += f' -v 0'
command += ' -v 0'
if pytest_name is None:
excluded_tests = (
'test_color_count',
Expand Down
Loading
Loading