Skip to content

Commit 4fb332c

Browse files
committed
minor cleanups
1 parent 74a0680 commit 4fb332c

File tree

5 files changed

+13
-16
lines changed

5 files changed

+13
-16
lines changed

conda/raw/recipe/meta.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ about:
5151
summary: Python bindings to PDFium (raw, external binary)
5252
description: |
5353
This package provides raw ctypes bindings to pdfium.
54-
Note, dependants should not pin this package to an exact version, as pypdfium2_raw itself pins pdfium-binaries to achieve ABI safety.
54+
Note, dependants should not pin this package to an exact version, as pypdfium2_raw itself pins pdfium-binaries for ABI safety reasons.
5555
In general, pypdfium2_helpers is the canonical package (i.e. roughly equivalent to pypdfium2 on PyPI), so it is recommended to depend on that rather than on pypdfium2_raw directly.
5656
license: BSD-3-Clause, Apache-2.0
5757
license_file:

setupsrc/pypdfium2_setup/autorelease.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def run_local(*args, **kws):
2323
def update_refbindings(version):
2424

2525
# We endeavor to make the reference bindings as universal and robust as possible, thus the symbol guards, flags, runtime libdir ["."] + system search.
26-
# Also, skip symbol source info to make for cleaner diffs, so one can see pdfium API changes at a glance.
26+
# Also, skip symbol source info for cleaner diffs, so one can see pdfium API changes at a glance.
2727

2828
# REFBINDINGS_FLAGS:
2929
# Given the symbol guards, we can define all standalone feature flags.
@@ -44,7 +44,6 @@ def do_versioning(config, record, prev_helpers, new_pdfium):
4444
if prev_helpers["dirty"]:
4545
print("Warning: dirty state. This should not happen in CI.", file=sys.stderr)
4646

47-
# TODO actually, we care only about updates to src/
4847
py_updates = prev_helpers["n_commits"] > 0
4948
c_updates = record["pdfium"] < new_pdfium
5049

setupsrc/pypdfium2_setup/base.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def parse_given_tag(full_tag):
207207

208208
info = dict()
209209

210-
# NOTE `git describe --dirty` does not account for new unregistered files
210+
# note, git describe --dirty ignores new unregistered files
211211
tag = full_tag
212212
dirty = tag.endswith("-dirty")
213213
if dirty:
@@ -237,7 +237,7 @@ def parse_git_tag():
237237

238238
def merge_tag(info, mode):
239239

240-
# FIXME some duplication with src/pypdfium2/version.py
240+
# some duplication with src/pypdfium2/version.py ...
241241

242242
tag = ".".join([str(info[k]) for k in ("major", "minor", "patch")])
243243
if info['beta'] is not None:
@@ -264,13 +264,13 @@ def plat_to_system(pl_name):
264264
if pl_name == ExtPlats.sourcebuild:
265265
# FIXME If doing a sourcebuild on an unknown host system, this returns None, which will cause binary detection code to fail (we need to know the platform-specific binary name) - handle this downsteam with fallback value?
266266
return Host.system
267-
# NOTE other ExtPlats not supported here
267+
# other ExtPlats intentionally not handled here
268268
return getattr(SysNames, pl_name.split("_", maxsplit=1)[0])
269269

270270

271271
# platform.libc_ver() currently returns an empty string for musl, so use the packaging module to confirm.
272272
# See https://github.com/python/cpython/issues/87414 and https://github.com/pypa/packaging/blob/f13c298f0a623f3f7e01cc8395956b718d21503a/src/packaging/_musllinux.py#L32
273-
# NOTE could consider packaging.tags.sys_tags() as a possible public-API alternative - see https://packaging.pypa.io/en/stable/tags.html#packaging.tags.sys_tags or https://stackoverflow.com/a/75172415/15547292
273+
# (could consider packaging.tags.sys_tags() as a possible public-API alternative - see https://packaging.pypa.io/en/stable/tags.html#packaging.tags.sys_tags or https://stackoverflow.com/a/75172415/15547292)
274274

275275
def _get_libc_info():
276276

@@ -296,10 +296,9 @@ def __init__(self):
296296
self._system_name = platform.system().lower()
297297
self._machine_name = platform.machine().lower()
298298

299-
# If we are on Linux, check if we have glibc or musl
299+
# If we are on Linux, check which libc we have
300300
self._libc_name, self._libc_ver = _get_libc_info()
301301

302-
# TODO consider cached property for platform and system?
303302
try:
304303
self.platform = self._get_platform()
305304
except Exception as e:
@@ -362,7 +361,7 @@ def _get_platform(self):
362361
elif self._machine_name == "i686":
363362
return PlatNames.android_x86
364363
elif self._system_name in ("iOS", "iPadOS"): # PEP 730
365-
# NOTE iOS detection is untested. We don't have access to an iOS device, so this is basically guessed from what the PEP mentions.
364+
# This is currently untested. We don't have access to an iOS device, so this is basically guessed from what the PEP mentions.
366365
ios_ver = platform.ios_ver()
367366
if self._machine_name == "arm64":
368367
return PlatNames.ios_arm64_simu if ios_ver.is_simulator else PlatNames.ios_arm64_dev
@@ -420,7 +419,7 @@ def get_wheel_tag(pl_name):
420419
elif pl_name == PlatNames.android_x86:
421420
return "android_21_x86"
422421
# iOS - see PEP 730 # Packaging
423-
# We do not currently build wheels for iOS, but again, add the handlers so it could be done on demand. Bear in mind that iOS is currently completely untested. In particular, the PEP says
422+
# We do not currently build wheels for iOS, but again, add the handlers so it could be done on demand. Bear in mind that the resulting iOS packages are currently completely untested. In particular, the PEP says
424423
# "These wheels can include binary modules in-situ (i.e., co-located with the Python source, in the same way as wheels for a desktop platform); however, they will need to be post-processed as binary modules need to be moved into the “Frameworks” location for distribution. This can be automated with an Xcode build step."
425424
# I take it this means you may need to change the library search path to that Frameworks location.
426425
elif pl_name == PlatNames.ios_arm64_dev:
@@ -605,7 +604,7 @@ def clean_platfiles():
605604

606605
def get_helpers_info():
607606

608-
# TODO consider adding some checks against record
607+
# TODO add some checks against record?
609608

610609
have_git_describe = False
611610
if HAVE_GIT_REPO:

setupsrc/pypdfium2_setup/emplace.py

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ def _repr_info(version, flags):
1717

1818
def _get_pdfium_with_cache(pl_name, req_ver, req_flags, use_v8):
1919

20-
# TODO inline binary cache logic into update.py ?
21-
2220
system = plat_to_system(pl_name)
2321
pl_dir = DataDir / pl_name
2422
binary = pl_dir / libname_for_system(system)

setupsrc/pypdfium2_setup/update.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ def main(platforms, version=None, robust=False, max_workers=None, use_v8=False):
9898
# low-level CLI interface for testing - users should go with higher-level emplace.py or setup.py
9999

100100
def parse_args(argv):
101+
platform_choices = list(PdfiumBinariesMap.keys())
101102
parser = argparse.ArgumentParser(
102103
description = "Download pre-built PDFium packages.",
103104
)
@@ -106,8 +107,8 @@ def parse_args(argv):
106107
"--platforms", "-p",
107108
nargs = "+",
108109
metavar = "ID",
109-
choices = list(PdfiumBinariesMap.keys()),
110-
help = f"The platform(s) to include. Defaults to the platforms we build wheels for. Choices: {list(PdfiumBinariesMap.keys())}",
110+
choices = platform_choices,
111+
help = f"The platform(s) to include. Defaults to the platforms we build wheels for. Choices: {platform_choices}",
111112
)
112113
parser.add_argument(
113114
"--use-v8",

0 commit comments

Comments
 (0)