hybrid C++/Python package / Add Makefile

PYADPT-81
heck 3 years ago
parent 7ee3d324ee
commit 07d2130bf0

@ -0,0 +1,19 @@
PREFIX = /home/heck/local-default/
DEBUG = 0
BUILD_DIR = ./build
BUILD_EXT_OPTS = --prefix=$(PREFIX)
ifeq ($(DEBUG),1)
BUILD_EXT_OPTS+=--debug
endif
.PHONY: all build clean
all: build_ext
build_ext:
python3 setup.py build_ext $(BUILD_EXT_OPTS)
clean:
rm -r $(BUILD_DIR)

@ -18,18 +18,16 @@ from glob import glob
from setuptools.command.build_ext import build_ext
verboseLevel = 0
def pEpLog(*msg):
if verboseLevel > 0:
import inspect
msgstr = ''
separator = ' '
for m in msg:
msgstr += str(m)
msgstr += separator
func = inspect.currentframe().f_back.f_code
print(func.co_filename + " : " + func.co_name + " : " + msgstr)
import inspect
msgstr = ''
separator = ' '
for m in msg:
msgstr += str(m)
msgstr += separator
func = inspect.currentframe().f_back.f_code
print(func.co_filename + " : " + func.co_name + " : " + msgstr)
class BuildExtCommand(build_ext):
@ -39,13 +37,11 @@ class BuildExtCommand(build_ext):
]
def initialize_options(self):
pEpLog("called")
build_ext.initialize_options(self)
self.local = None != environ.get('PER_USER_DIRECTORY')
self.prefix = getattr(self, "prefix=", None)
def windowsGetInstallLocation(self):
pEpLog("called")
# Note: should be installed to 'C:\Program Files (x86)' while a 32-bit distro
# TODO: Try desktop adapter location first, then COM server
# FIXME: This is wrong, we should chase the COM server, not the Outlook Plugin (even if they're in the same place)
@ -138,17 +134,12 @@ class BuildExtCommand(build_ext):
return (home, sys_includes, sys_libdirs, libs)
def finalize_options(self):
pEpLog("called")
build_ext.finalize_options(self)
pEpLog("verbose: ", self.verbose)
pEpLog("local: ", self.local)
pEpLog("prefix: ", self.prefix)
pEpLog("sys.platform: ", sys.platform)
global verboseLevel
verboseLevel = self.verbose
# get build information for platform
if sys.platform == 'winnt':
build_info = self.get_build_info_winnt()
@ -220,14 +211,14 @@ if sys.version_info[0] < 3:
module_pEp = Extension(
'pEp',
'native_pEp',
sources = [
'src/pEpmodule.cc',
'src/basic_api.cc',
'src/identity.cc',
'src/message.cc',
'src/message_api.cc',
'src/str_attr.cc',
'src/pEp/native_pEp/pEpmodule.cc',
'src/pEp/native_pEp/basic_api.cc',
'src/pEp/native_pEp/identity.cc',
'src/pEp/native_pEp/message.cc',
'src/pEp/native_pEp/message_api.cc',
'src/pEp/native_pEp/str_attr.cc',
# 'src/user_interface.cc',
# 'src/adapter.cc'
],
@ -242,6 +233,7 @@ setup(
author_email="vb@pep-project.org",
maintainer="Heck",
maintainer_email="heck@pep.foundation",
package_dir='src',
ext_modules=[module_pEp],
cmdclass={
'build_ext': BuildExtCommand,

@ -0,0 +1,30 @@
# pEp package
# This file is being exectued upon 'import pEp'
#
# __all__ could be used to limit the symbols exported when using from <pkg> import *
# Import all symbols EXCEPT the ones beginning with underscore into the current namespace
from native_pEp import *
# import the module
import native_pEp
# Executed on module import
def init():
print("init() called")
# native_pEp._init()
# Executed when run as script
def main():
print("I am being run as a script")
# MAIN
if __name__ == "__main__":
main()
else:
init()

@ -140,7 +140,7 @@ namespace pEp {
}
}
BOOST_PYTHON_MODULE(pEp)
BOOST_PYTHON_MODULE(native_pEp)
{
using namespace boost::python;
using namespace boost::locale;

@ -0,0 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import pEp
pEp.is_sync_active()
Loading…
Cancel
Save