Skip to main content

MSL-LoadLib

CI Status Docs Status PyPI - Version PyPI - Python Versions

This package loads a library in Python. It is basically just a thin wrapper around ctypes (for libraries that use the __cdecl or __stdcall calling convention), Python.NET (for libraries that use Microsoft .NET, CLR), Py4J (for Java .jar or .class files) and comtypes (for libraries that use the Component Object Model or ActiveX).

However, the primary advantage is that it is possible to communicate with a 32-bit library from 64-bit Python.

msl-loadlib is a pure-python package, but Python.NET depends on the .NET Common Language Runtime (CLR) on Windows and Mono Runtime on Linux/macOS, and Py4J depends on having a Java Virtual Machine installed.

Install

msl-loadlib is available for installation via the Python Package Index

pip install msl-loadlib

Optional dependencies:

To set up your environment on Linux, please follow the instructions on the prerequisites section of the documentation.

Examples

If you are loading a 64-bit library in 64-bit Python (or a 32-bit library in 32-bit Python), then you can directly load the library using LoadLibrary.

The following examples load a 64-bit library in a 64-bit Python interpreter. If you are using a 32-bit Python interpreter replace 64 with 32 in the filename.

Import the LoadLibrary class and the directory where the example libraries are located

>>> from msl.loadlib import LoadLibrary
>>> from msl.examples.loadlib import EXAMPLES_DIR

If the file extension is not included then a default extension, .dll (Windows), .so (Linux) or .dylib (macOS), is used.

Load the example C++ library and call the add function

>>> cpp = LoadLibrary(EXAMPLES_DIR / "cpp_lib64")
>>> cpp.lib.add(1, 2)
3

Load the example FORTRAN library and call the factorial function

>>> fortran = LoadLibrary(EXAMPLES_DIR / "fortran_lib64")

With a FORTRAN library you must pass values by reference using ctypes, and, since the returned value is not of type c_int we must configure ctypes for a value of type c_double to be returned

>>> from ctypes import byref, c_int, c_double
>>> fortran.lib.factorial.restype = c_double
>>> fortran.lib.factorial(byref(c_int(37)))
1.3763753091226343e+43

Load the example Java byte code and call the cos function

>>> java = LoadLibrary(EXAMPLES_DIR / "Trig.class")
>>> java.lib.Trig.cos(1.234)
0.33046510807172985

Python interacts with the Java Virtual Machine via a local network socket and therefore the connection must be closed when you are done using the Java library

>>> java.gateway.shutdown()

Load the example .NET library and call the reverse_string function, we must specify that the library type is a .NET library by including the "net" argument

>>> net = LoadLibrary(EXAMPLES_DIR / "dotnet_lib64.dll", "net")
>>> net.lib.StringManipulation().reverse_string("abcdefghijklmnopqrstuvwxyz")
'zyxwvutsrqponmlkjihgfedcba'

To load a Component Object Model (COM) library pass in the library's Program ID. NOTE: This example will only work on Windows.

Here we load the FileSystemObject library and include the "com" argument to indicate that it is a COM library.

>>> com = LoadLibrary("Scripting.FileSystemObject", "com")

We then use the library to create, edit and close a text file

>>> f = com.lib.CreateTextFile("a_new_file.txt")
>>> f.WriteLine("This is a test")
0
>>> f.Close()
0

Inter-process communication is used to access a 32-bit library from a module that is running within a 64-bit Python interpreter. The procedure uses a client-server protocol where the client is a subclass of msl.loadlib.Client64 and the server is a subclass of msl.loadlib.Server32. See the examples for examples on how to implement Inter-process communication.

Documentation

The documentation for msl-loadlib can be found here.

Release files for msl-loadlib 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for msl-loadlib 1.1.0
File Size Uploaded
msl_loadlib-1.1.0.tar.gz 45.2 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for msl-loadlib 1.1.0
File
msl_loadlib-1.1.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
msl_loadlib-1.1.0-py3-none-win32.whl Python 3 none Windows x86-32 Details
msl_loadlib-1.1.0-py3-none-musllinux_1_1_x86_64.whl Python 3 none Linux musl 1.1+ x86-64 Details
msl_loadlib-1.1.0-py3-none-musllinux_1_1_aarch64.whl Python 3 none Linux musl 1.1+ ARM64 Details
msl_loadlib-1.1.0-py3-none-manylinux2014_armv7l.manylinux_2_17_armv7l.whl Python 3 none Linux glibc 2.17+ ARMv7l Details
msl_loadlib-1.1.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details
msl_loadlib-1.1.0-py3-none-manylinux1_x86_64.whl Python 3 none Linux glibc 2.5+ x86-64 Details
msl_loadlib-1.1.0-py3-none-manylinux1_i686.whl Python 3 none Linux glibc 2.5+ x86-32 Details
msl_loadlib-1.1.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
msl_loadlib-1.1.0-py3-none-macosx_10_6_x86_64.whl Python 3 none macOS 10.6+ x86-64 Details

Total release size: 136.0 MB

Release files / msl_loadlib-1.1.0.tar.gz

Download URL msl_loadlib-1.1.0.tar.gz
Size 45.2 MB
Tags Source
SHA-256 checksum
How to use checksums
bf3f2afc7feb799c1230ebc6dae489a19e3142a21ec7e65be1c71426cba6174d
BLAKE2b-256 checksum
How to use checksums
a1b53bab891ab3f4fe139bbb9644bd29f8e166b014ed5ac32a347c35d5f5d0c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 30, 2026.

Transparency log

Release files / msl_loadlib-1.1.0-py3-none-win_amd64.whl

Download URL msl_loadlib-1.1.0-py3-none-win_amd64.whl
Size 15.3 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
122d4c7439260f5aa2b014ff6dfedf1eebedf1d4e8e40237cd383fefcd5e1e05
BLAKE2b-256 checksum
How to use checksums
b1c297ab904f648cfe418a293c93f0cb9ff6942e6d9cb63d35710b62005cd576
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 30, 2026.

Transparency log

Release files / msl_loadlib-1.1.0-py3-none-win32.whl

Download URL msl_loadlib-1.1.0-py3-none-win32.whl
Size 15.3 MB
Tags Python 3 Windows x86-32
SHA-256 checksum
How to use checksums
1646032f560ff91e1b0b76c53ec3b2cebad784b320a6beffa47d67d2640dfb0d
BLAKE2b-256 checksum
How to use checksums
6f595fdd390ef4174e8d983bdecf7296d6ec9825c108df8b07a7fe58ac64c911
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 30, 2026.

Transparency log

Release files / msl_loadlib-1.1.0-py3-none-musllinux_1_1_x86_64.whl

Download URL msl_loadlib-1.1.0-py3-none-musllinux_1_1_x86_64.whl
Size 77.0 kB
Tags Linux musl 1.1+ x86-64 Python 3
SHA-256 checksum
How to use checksums
366416fd84d4065ab96e88ae3c9bb1125592eed9f7da30166507df289d6ffbae
BLAKE2b-256 checksum
How to use checksums
c294c840c77384e41abc31007c99a9e9ae8b31af2a00957042510b9ac9e3df96
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 30, 2026.

Transparency log

Release files / msl_loadlib-1.1.0-py3-none-musllinux_1_1_aarch64.whl

Download URL msl_loadlib-1.1.0-py3-none-musllinux_1_1_aarch64.whl
Size 77.0 kB
Tags Linux musl 1.1+ ARM64 Python 3
SHA-256 checksum
How to use checksums
957fc44889454201559c56b44490f4d4d539fa6dd0ef99cd29bf01ef77e6c407
BLAKE2b-256 checksum
How to use checksums
884cf10088e0970e2f1043bfcf42be2e58f48608e3da7a4823fce45cb5ae7874
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 30, 2026.

Transparency log

Release files / msl_loadlib-1.1.0-py3-none-manylinux2014_armv7l.manylinux_2_17_armv7l.whl

Download URL msl_loadlib-1.1.0-py3-none-manylinux2014_armv7l.manylinux_2_17_armv7l.whl
Size 77.1 kB
Tags Linux glibc 2.17+ ARMv7l Python 3
SHA-256 checksum
How to use checksums
7d3049f902d95e38a475532031c42c512a91d7a397d11c6c5001c7b9956b925b
BLAKE2b-256 checksum
How to use checksums
370ec9a06da220900a0e26a2988acca9db9e153aff3bf999e3a5d9cd7fa8f95c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 30, 2026.

Transparency log

Release files / msl_loadlib-1.1.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL msl_loadlib-1.1.0-py3-none-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 90.6 kB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
86413d568ed43f97688f7bd59a1fe70b44061588ce318398cf01e0d410d178fd
BLAKE2b-256 checksum
How to use checksums
da8431b3f96f26c00b8b3b7629817fdd3163b1aadb4688bf2298156e826c6853
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 30, 2026.

Transparency log

Release files / msl_loadlib-1.1.0-py3-none-manylinux1_x86_64.whl

Download URL msl_loadlib-1.1.0-py3-none-manylinux1_x86_64.whl
Size 29.8 MB
Tags Linux glibc 2.5+ x86-64 Python 3
SHA-256 checksum
How to use checksums
c058194e86b463023be24d749e7773e68b5e724f224081d195a096fc59659d6e
BLAKE2b-256 checksum
How to use checksums
f385e81df8bf6aadc59940584273ec9b5076fc37c8bd894d2c4ac90b5ff3c564
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 30, 2026.

Transparency log

Release files / msl_loadlib-1.1.0-py3-none-manylinux1_i686.whl

Download URL msl_loadlib-1.1.0-py3-none-manylinux1_i686.whl
Size 29.8 MB
Tags Linux glibc 2.5+ x86-32 Python 3
SHA-256 checksum
How to use checksums
6c4042ac1706157a14ff0ba85771fb43cc8c21f7eac6ff3b2f291b1b5a921445
BLAKE2b-256 checksum
How to use checksums
ba188d750e82fd6788014c03e5864c95e8cf54ff3b4e89e2cc9b5b46f5837d14
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 30, 2026.

Transparency log

Release files / msl_loadlib-1.1.0-py3-none-macosx_11_0_arm64.whl

Download URL msl_loadlib-1.1.0-py3-none-macosx_11_0_arm64.whl
Size 82.4 kB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2d87b095b2046b11de119968cb63679d6396ede76ceeff469b31556b80f0afd6
BLAKE2b-256 checksum
How to use checksums
c71da718e93cd197b4158bc949ca904190e0699a72ed06d380bb4314534a6a56
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 30, 2026.

Transparency log

Release files / msl_loadlib-1.1.0-py3-none-macosx_10_6_x86_64.whl

Download URL msl_loadlib-1.1.0-py3-none-macosx_10_6_x86_64.whl
Size 273.9 kB
Tags Python 3 macOS 10.6+ x86-64
SHA-256 checksum
How to use checksums
f04f5a17101ea6487a4b98b856566b64404424c9979d21c78d0c32e8ab023151
BLAKE2b-256 checksum
How to use checksums
539c53d93c6fe407a1d3059b729c9ce9a3d9631625c9c687b0827788a2dea6c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jun 30, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.1.0 This release

11 release files

1.0.0

9 release files

0.10.0

5 release files

0.9.0

5 release files

0.8.0

5 release files

0.7.0

5 release files

0.6.0

5 release files

0.5.0

3 release files

0.4.1

3 release files

0.4.0

3 release files

0.3.2

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page