Skip to content

Commit

Permalink
Vendor libmaxminddb
Browse files Browse the repository at this point in the history
  • Loading branch information
oschwald committed Nov 1, 2023
1 parent c37a359 commit d87c105
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "tests/data"]
path = tests/data
url = https://github.com/maxmind/MaxMind-DB
[submodule "extension/libmaxminddb"]
path = extension/libmaxminddb
url = [email protected]:maxmind/libmaxminddb.git
1 change: 1 addition & 0 deletions extension/libmaxminddb
Submodule libmaxminddb added at ac4d0d
2 changes: 1 addition & 1 deletion extension/maxminddb.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <arpa/inet.h>
#include <maxminddb.h>
#include "libmaxminddb/include/maxminddb.h"
#include <netinet/in.h>
#include <structmember.h>
#include <sys/socket.h>
Expand Down
6 changes: 0 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,3 @@ Documentation = "https://maxminddb.readthedocs.org/"
# src is showing up in our GitHub linting builds. It seems to
# contain deps.
extend-exclude = '^/src/'

[tool.cibuildwheel.linux]
before-all = "apt install libmaxminddb-dev"

[tool.cibuildwheel.macos]
before-all = "brew install libmaxminddb"
20 changes: 17 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,25 @@
PYPY = hasattr(sys, "pypy_version_info")
JYTHON = sys.platform.startswith("java")

compile_args = ["-Wall", "-Wextra"]
compile_args = ["-Wall", "-Wextra", "-Wno-unknown-pragmas"]

ext_module = [
Extension(
"maxminddb.extension",
libraries=["maxminddb"],
sources=["extension/maxminddb.c"],
sources=[
"extension/maxminddb.c",
"extension/libmaxminddb/src/data-pool.c",
"extension/libmaxminddb/src/maxminddb.c",
],
define_macros=[
# XXX - maybe we should get this from python somehow
("MMDB_LITTLE_ENDIAN", 1),
("PACKAGE_VERSION", '"maxminddb-python"'),
],
include_dirs=[
"extension/libmaxminddb/include",
"extension/libmaxminddb/src",
],
extra_compile_args=compile_args,
)
]
Expand Down Expand Up @@ -116,6 +128,8 @@ def run_setup(with_cext):
try:
run_setup(True)
except BuildFailed as exc:
if os.environ['MAXMINDDB_REQUIRE_EXTENSION']:
raise exc
status_msgs(
exc.cause,
"WARNING: The C extension could not be compiled, "
Expand Down

0 comments on commit d87c105

Please sign in to comment.