Browse Source

hybrid C++/Python package / Add Makefile

PYADPT-81
heck 2 years ago
parent
commit
07d2130bf0
21 changed files with 72 additions and 25 deletions
  1. +19
    -0
      Makefile
  2. +16
    -24
      setup.py
  3. +30
    -0
      src/pEp/__init__.py
  4. +0
    -0
      src/pEp/native_pEp/adapter.cc
  5. +0
    -0
      src/pEp/native_pEp/adapter.hh
  6. +0
    -0
      src/pEp/native_pEp/basic_api.cc
  7. +0
    -0
      src/pEp/native_pEp/basic_api.hh
  8. +0
    -0
      src/pEp/native_pEp/identity.cc
  9. +0
    -0
      src/pEp/native_pEp/identity.hh
  10. +0
    -0
      src/pEp/native_pEp/locked_queue.hh
  11. +0
    -0
      src/pEp/native_pEp/message.cc
  12. +0
    -0
      src/pEp/native_pEp/message.hh
  13. +0
    -0
      src/pEp/native_pEp/message_api.cc
  14. +0
    -0
      src/pEp/native_pEp/message_api.hh
  15. +1
    -1
      src/pEp/native_pEp/pEpmodule.cc
  16. +0
    -0
      src/pEp/native_pEp/pEpmodule.hh
  17. +0
    -0
      src/pEp/native_pEp/str_attr.cc
  18. +0
    -0
      src/pEp/native_pEp/str_attr.hh
  19. +0
    -0
      src/pEp/native_pEp/user_interface.cc
  20. +0
    -0
      src/pEp/native_pEp/user_interface.hh
  21. +6
    -0
      test/pyadpt-81.py

+ 19
- 0
Makefile View File

@ -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)

+ 16
- 24
setup.py View File

@ -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,


+ 30
- 0
src/pEp/__init__.py View File

@ -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()

src/adapter.cc → src/pEp/native_pEp/adapter.cc View File


src/adapter.hh → src/pEp/native_pEp/adapter.hh View File


src/basic_api.cc → src/pEp/native_pEp/basic_api.cc View File


src/basic_api.hh → src/pEp/native_pEp/basic_api.hh View File


src/identity.cc → src/pEp/native_pEp/identity.cc View File


src/identity.hh → src/pEp/native_pEp/identity.hh View File


src/locked_queue.hh → src/pEp/native_pEp/locked_queue.hh View File


src/message.cc → src/pEp/native_pEp/message.cc View File


src/message.hh → src/pEp/native_pEp/message.hh View File


src/message_api.cc → src/pEp/native_pEp/message_api.cc View File


src/message_api.hh → src/pEp/native_pEp/message_api.hh View File


src/pEpmodule.cc → src/pEp/native_pEp/pEpmodule.cc View File


src/pEpmodule.hh → src/pEp/native_pEp/pEpmodule.hh View File


src/str_attr.cc → src/pEp/native_pEp/str_attr.cc View File


src/str_attr.hh → src/pEp/native_pEp/str_attr.hh View File


src/user_interface.cc → src/pEp/native_pEp/user_interface.cc View File


src/user_interface.hh → src/pEp/native_pEp/user_interface.hh View File


+ 6
- 0
test/pyadpt-81.py View File

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

Loading…
Cancel
Save