Skip to content

Commit

Permalink
Major cleanup (new library loader, rm multilib, rm stdcall)
Browse files Browse the repository at this point in the history
This removes support for multiple different libraries in one file, which
IOHO was an inherent design mistake messing up the code - pypdfium2
ctypesgen is now single-lib.

We also replace the old, bloated library loader with a new lean one.
In the future, we may want an option to plug in a custom library loader
so we can import config from pypdfium2.

This also removes support for the windows-only stdcall convention
because it's not needed for pypdfium2 and probably an edge case.
It would cause some additional complexity and we're not sure what would
be the cleanest way to integrate it, so this can wait.

Fun fact:
It seems like ctypesgen prior to this change added the complie_libdirs
to the runtime library loader. Further, relative paths (I think) were
never correctly interpreted relative to the file's directory, but to the
user's CWD, which is useless and could even cause unexpected behavior.
So runtime_libdirs = ["."] didn't work, but the fallback below "then we
search the directory where the generated python interface is stored"
captured.
  • Loading branch information
mara004 committed Sep 28, 2023
1 parent 9f490ba commit 569dc4b
Show file tree
Hide file tree
Showing 6 changed files with 171 additions and 590 deletions.
19 changes: 9 additions & 10 deletions ctypesgen/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,20 @@ def main(givenargs=None):
nargs="+",
help="Sequence of header files",
)
parser.add_argument(
"-o",
"--output",
metavar="FILE",
help="write wrapper to FILE [default stdout]",
)
parser.add_argument(
"-l",
"--libraries",
nargs="+",
"--library",
required=True,
default=[],
metavar="LIBRARY",
help="link to LIBRARY",
)
parser.add_argument(
"-o",
"--output",
metavar="FILE",
help="write wrapper to FILE [default stdout]",
)
parser.add_argument(
"--other-headers",
nargs="+",
Expand Down Expand Up @@ -322,8 +322,7 @@ def main(givenargs=None):
# Figure out what names will be defined by imported Python modules
args.other_known_names = find_names_in_modules(args.modules)

if len(args.libraries) == 0:
msgs.warning_message("No libraries specified", cls="usage")
assert args.library

# Fetch printer for the requested output language
if args.output_language == "py":
Expand Down
Loading

0 comments on commit 569dc4b

Please sign in to comment.