Skip to main content

scikit-build project with CMake for compiling libmagic

Project description

A lightweight, minimal python package that ships magic libraries using automake, CMake, scikit-build, and cibuildwheel.

Actions Status Cirrus Status Documentation Status Code style: black

PyPI version PyPI platforms

GitHub Discussion Gitter

Why?

If you use python-magic, you typically get an error like this

>>> import magic
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/kratsg/.pyenv/versions/venv/lib/python3.7/site-packages/magic/__init__.py", line 209, in <module>
    libmagic = loader.load_lib()
  File "/Users/kratsg/.pyenv/versions/venv/lib/python3.7/site-packages/magic/loader.py", line 49, in load_lib
    raise ImportError('failed to find libmagic.  Check your installation')
ImportError: failed to find libmagic.  Check your installation

which is frustrating because they don’t ship shared lib with their python distribution. pylibmagic helps fill in the missing gap by shipping the required magic library and adding it to your path, so you can just do:

>>> import pylibmagic
>>> import magic

and be on your way. pylibmagic is designed to be very minimal and lightweight.

Compiling

$ docker run -it --rm -v $PWD:/home/root -w /home/root ubuntu
# apt install cmake autoconf automake libtool build-essential git python3-dev python3-pip
# cmake -S . -B build
# cmake --build build

Installing

$ python3 -m pip install pylibmagic

and the libraries are installed at

$ python -c "import pylibmagic; print(pylibmagic.data)"

Releasing

To release, due to concurrency issues, we need to push the tag after Cirrus CI finishes with the building for pushing to the main branch. So the order is typically:

tbump 0.5.0 --no-tag-push
# wait until Cirrus CI finishes
git push origin v0.5.0
# wait until Cirrus CI finishes
gh release create

See [cirruslabs/cirrus-ci-docs#1167](https://github.com/cirruslabs/cirrus-ci-docs/issues/1167) for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pylibmagic-0.5.0.tar.gz (13.9 kB view hashes)

Uploaded Source

Built Distributions

pylibmagic-0.5.0-py3-none-musllinux_1_1_x86_64.whl (658.3 kB view hashes)

Uploaded Python 3 musllinux: musl 1.1+ x86-64

pylibmagic-0.5.0-py3-none-musllinux_1_1_aarch64.whl (652.9 kB view hashes)

Uploaded Python 3 musllinux: musl 1.1+ ARM64

pylibmagic-0.5.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (619.4 kB view hashes)

Uploaded Python 3 manylinux: glibc 2.17+ x86-64

pylibmagic-0.5.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (617.4 kB view hashes)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

pylibmagic-0.5.0-py3-none-macosx_11_0_arm64.whl (697.6 kB view hashes)

Uploaded Python 3 macOS 11.0+ ARM64

pylibmagic-0.5.0-py3-none-macosx_10_9_x86_64.whl (697.0 kB view hashes)

Uploaded Python 3 macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page