]> git.ipfire.org Git - location/libloc.git/commitdiff
python: Move C module to make space for some native python code
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 12 May 2020 09:49:35 +0000 (09:49 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 12 May 2020 09:49:35 +0000 (09:49 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/python/__init__.py [new file with mode: 0644]
src/python/locationmodule.c

index 0da14165b393329e3e99e611b33fe1bd116e8917..f07d3e58b75607c20c31895e10d1df5843c10cda 100644 (file)
@@ -59,6 +59,13 @@ SED_PROCESS = \
 databasedir = $(localstatedir)/lib/location
 pkgconfigdir = $(libdir)/pkgconfig
 
+# XXX hardcode path for Debian
+pythondir = $(prefix)/lib/python3/dist-packages
+pyexecdir = $(prefix)/lib/python$(PYTHON_VERSION)/lib-dynload
+
+# Overwrite Python path
+pkgpythondir = $(pythondir)/location
+
 %: %.in Makefile
        $(SED_PROCESS)
 
@@ -145,10 +152,13 @@ EXTRA_DIST += \
 CLEANFILES += \
        src/libloc.pc
 
+dist_pkgpython_PYTHON = \
+       src/python/__init__.py
+
 pyexec_LTLIBRARIES = \
-       src/python/location.la
+       src/python/_location.la
 
-src_python_location_la_SOURCES = \
+src_python__location_la_SOURCES = \
        src/python/locationmodule.c \
        src/python/locationmodule.h \
        src/python/as.c \
@@ -162,17 +172,17 @@ src_python_location_la_SOURCES = \
        src/python/writer.c \
        src/python/writer.h
 
-src_python_location_la_CFLAGS = \
+src_python__location_la_CFLAGS = \
        $(AM_CFLAGS) \
        $(PYTHON_CFLAGS)
 
-src_python_location_la_LDFLAGS = \
+src_python__location_la_LDFLAGS = \
        $(AM_LDFLAGS) \
        -shared \
        -module \
        -avoid-version
 
-src_python_location_la_LIBADD = \
+src_python__location_la_LIBADD = \
        src/libloc.la \
        $(PYTHON_LIBS)
 
diff --git a/src/python/__init__.py b/src/python/__init__.py
new file mode 100644 (file)
index 0000000..d2a4678
--- /dev/null
@@ -0,0 +1,21 @@
+#!/usr/bin/python3
+###############################################################################
+#                                                                             #
+# libloc - A library to determine the location of someone on the Internet     #
+#                                                                             #
+# Copyright (C) 2020 IPFire Development Team <info@ipfire.org>                #
+#                                                                             #
+# This library is free software; you can redistribute it and/or               #
+# modify it under the terms of the GNU Lesser General Public                  #
+# License as published by the Free Software Foundation; either                #
+# version 2.1 of the License, or (at your option) any later version.          #
+#                                                                             #
+# This library is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU           #
+# Lesser General Public License for more details.                             #
+#                                                                             #
+###############################################################################
+
+# Import everything from the C module
+from _location import *
index 6e7269ba0aae84bc0c4a86c6d6019c6b17718606..c7f4cff93cf4051f60fca756ec08d7a7d4dd1b4e 100644 (file)
@@ -29,7 +29,7 @@
 /* Declare global context */
 struct loc_ctx* loc_ctx;
 
-PyMODINIT_FUNC PyInit_location(void);
+PyMODINIT_FUNC PyInit__location(void);
 
 static void location_free(void) {
        // Release context
@@ -101,14 +101,14 @@ static PyMethodDef location_module_methods[] = {
 
 static struct PyModuleDef location_module = {
        .m_base = PyModuleDef_HEAD_INIT,
-       .m_name = "location",
+       .m_name = "_location",
        .m_size = -1,
        .m_doc = "Python module for libloc",
        .m_methods = location_module_methods,
        .m_free = (freefunc)location_free,
 };
 
-PyMODINIT_FUNC PyInit_location(void) {
+PyMODINIT_FUNC PyInit__location(void) {
        // Initialise loc context
        int r = loc_new(&loc_ctx);
        if (r)