diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md index 9eb70e8..41eb3c9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +# Descripton of the repository +This repository migrates python-magic and libmagic to Bazel in a single Bazel workspace, allowing any other Bazel workspace to consume python-magic as is without needing to install libmagic on the host machine. + # python-magic [![PyPI version](https://badge.fury.io/py/python-magic.svg)](https://badge.fury.io/py/python-magic) [![Build Status](https://travis-ci.org/ahupp/python-magic.svg?branch=master)](https://travis-ci.org/ahupp/python-magic) [![Join the chat at https://gitter.im/ahupp/python-magic](https://badges.gitter.im/ahupp/python-magic.svg)](https://gitter.im/ahupp/python-magic?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 0000000..fd686ee --- /dev/null +++ b/WORKSPACE @@ -0,0 +1,24 @@ +load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") + +http_archive( + name = "libmagic", + sha256 = "09c588dac9cff4baa054f51a36141793bcf64926edc909594111ceae60fce4ee", + strip_prefix = "file-5.31", + urls = [ + "https://astron.com/pub/file/file-5.31.tar.gz", + ], + patch_cmds = [ + "./configure", + "make", + "make install", + "cp src/.libs/libmagic.dylib /usr/local/lib/libmagic.dylib", + ], + build_file_content = """ +cc_library( + name = 'libmagic', + srcs = ["src/.libs/libmagic.dylib"], + includes = ['.'], + linkstatic = 1, + visibility = ['//visibility:public'], +)""", +) \ No newline at end of file diff --git a/magic/BUILD.bazel b/magic/BUILD.bazel new file mode 100644 index 0000000..5e956a7 --- /dev/null +++ b/magic/BUILD.bazel @@ -0,0 +1,19 @@ +py_library( + name = "loader", + srcs = ["loader.py", "__init__.py"], + imports = [".."], + data = [ + "@libmagic//:libmagic", + ], + visibility = ["//visibility:public"], +) + +py_library( + name = "compat", + srcs = ["compat.py"], + imports = [".."], + data = [ + ":loader", + ], + visibility = ["//visibility:public"], +) \ No newline at end of file diff --git a/test/BUILD.bazel b/test/BUILD.bazel new file mode 100644 index 0000000..fe19b5c --- /dev/null +++ b/test/BUILD.bazel @@ -0,0 +1,21 @@ +py_test( + name = "libmagic_test", + srcs = ["libmagic_test.py"], + deps = [ + "//magic:compat", + ], + data = [ + "testdata" + ] +) + +py_test( + name = "python_magic_test", + srcs = ["python_magic_test.py"], + deps = [ + "//magic:compat", + ], + data = [ + "testdata" + ] +) \ No newline at end of file