Compare commits

..

2 Commits

Author SHA1 Message Date
heck add818a91a closing branch 3 years ago
David 566d0a2162 opdate from optparse to argparse PYADAPT-61 3 years ago

@ -1,30 +0,0 @@
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
max_line_length = 300
tab_width = 4
# C++ Coding style
# I know these keys are unknown, regard it as documentation
[*.{cc,hh}]
indent_brace_style = K&R
curly_bracket_next_line = false
spaces_around_operators = true
spaces_around_brackets = true
[*.py]
indent_size = 4
[Makefile]
indent_style = tab
[*.ini]
indent_size = 2
[*.cfg]
indent_size = 2

82
.gitignore vendored

@ -1,82 +0,0 @@
syntax: glob
ws/
pEp.egg-info/
dist/
build/
.pythonhist
.gnupg
.lldb
.so
.pEp_management.db*
.python_history
__pycache__/
test/Laptop/
test/Library/
test/Phone/
test/TestInbox/
test/Backup/
test/lib/
test/imap_settings.py
venv/
build-windows/Debug/
build-windows/Release/
build-windows/packages/
build-windows/.vs/
build-windows/pEpPythonAdapter.vcxproj.*
launch.json
settings.json
# Default ignored files
.idea/
docs/build/
.eggs/
.tox/
=======
# Build config
local.conf
# Python artifacts
/build/
/dist/
__pycache__/
*.py[co]
/.tox
.pytest_cache
/venv/
/_venv/
*.egg-info/
/*.egg-link
/*.egg
/.eggs/
/pip-wheel-metadata/
# file generated by setuptools_scm
/src/pEp/__version__.py
# Doc artifacts
/docs/build/
# Test artifacts
/test/Laptop
/test/Library
/test/Phone
/test/TestInbox
/test/Backup
/test/lib
/test/imap_settings.py
# Editor artifacts and config
.idea/
*~
.\#*
\#*#
*.swp
.idea
.spyproject
*.code-workspace
tags
ws
# platform artifacts
.DS_store
/src/pEp/_pEp.cpython-38-darwin.so

@ -0,0 +1,25 @@
syntax: glob
*.swp
ws
tags
.DS_Store
pEp.egg-info
dist
build
.pythonhist
.gnupg
.lldb
.pEp_management.db*
.python_history
__pycache__
test/Laptop
test/Library
test/Phone
test/TestInbox
test/Backup
test/lib
test/imap_settings.py
venv
launch.json
settings.json

@ -1,9 +0,0 @@
# This is the list of pEpPythonAdapter's significant contributors.
#
# This does not necessarily list everyone who has contributed code
# To see the full list of contributors, see the revision history in
# source control.
Volker Birk <vb@pep-project.org> (original author and maintainer)
Heck <heck@pep.foundation> (current maintainer and author)
Hartmut Goebel <h.goebel@crazy-compilers.com> (contributions)
juga <juga@pep.foundation> (contributions)

@ -1,6 +0,0 @@
# 1st Party Dependencies
## Prefer git tags instead of SHA hashes when possible.
libpEpAdapter=Release_2.1.17
pEpEngine=Release_2.1.23
sequoia=365d00a08bec6a5a48d48a7c7893d78c27092b59

@ -1,88 +0,0 @@
include Makefile.conf
.PHONY: all compile compile-inplace dist dist-egg dist-whl install install-user venv envtest install-test test develop docs clean clean-all clean-docs
all: install
# Build
# =====
compile:
python3 setup.py build_ext $(DEBUG_OPT) $(PREFIX_OPT)
compile-inplace:
python3 setup.py build_ext $(DEBUG_OPT) $(PREFIX_OPT) --inplace
# Packaging
# =========
# create wheel and egg package in dist/
dist: dist-whl dist-egg
# create wheel package in dist/
dist-whl: compile
python3 setup.py bdist_wheel
# create egg package in dist/
dist-egg: compile
python3 setup.py bdist_egg
# Installation
# ============
# installs the package system wide
install: compile
pip3 install .
# installs the package into your user home
install-user: compile
pip3 install . --user
# Envrionment
# ===========
# Creates and activates a new venv that has the LD_LIBRARY_PATH/DYLD_LIBRARY_PATH
# already set for the prefix specified in local.conf
# Only activates venv if already existing
venv:
python3 -m venv $(VENV_DIR)
LD_LIBRARY_PATH=$(PREFIX)/lib \
DYLD_LIBRARY_PATH=$(PREFIX)/lib \
bash --rcfile $(VENV_DIR)/bin/activate
# Tests if the current environment is able to load the pEp module
envtest:
python3 -c 'import pEp'
# Test
# ====
# Use these targets only in venv created with 'make venv'
install-test: compile
pip3 install .[test]
test:
pytest
# Development
develop: compile
pip install -e .
# Documentation
# =============
docs: compile-inplace
make html -C docs/
# Housekeeping
# ============
clean-all: clean
rm -rf $(VENV_DIR)
clean: clean-docs
rm -rf $(BUILD_DIR)
rm -rf $(DIST_DIR)
rm -rf $(PYTHON_ARTIFACTS)
rm -rf $(VERSION_FILE)
rm -rf $(BUILD_INPLACE)
clean-docs:
make clean -C docs/

@ -1,26 +0,0 @@
HERE:=$(dir $(lastword $(MAKEFILE_LIST)))
# Constants
BUILD_DIR = ./build
DIST_DIR = ./dist
VERSION_FILE = ./src/pEp/__version__.py
BUILD_INPLACE = ./src/pEp/_pEp.cpython-38-darwin.so
PYTHON_ARTIFACTS += ./.eggs
PYTHON_ARTIFACTS += ./src/pEp.egg-info
PYTHON_ARTIFACTS += ./.pytest_cache
VENV_DIR = ./venv
# Build config Defaults
DEBUG=1
PREFIX=$(HOME)
######### Overrides #########
-include $(HERE)local.conf
ifeq ($(DEBUG),1)
DEBUG_OPT+=--debug
endif
ifneq ($(PREFIX),)
PREFIX_OPT += --prefix=$(PREFIX)
endif

@ -0,0 +1,11 @@
There's a setup.py in pEpPythonAdapter/
In Python we've setup tools, so it's:
python3 setup.py build
python3 setup.py install
That is a Python concept. You can find more about it here:
https://docs.python.org/3/extending/building.html#building-c-and-c-extensions-with-distutils

@ -1,22 +0,0 @@
pEpPythonAdapter
================
Python adapter for the `pEpEngine <https://pep.foundation/dev/repos/pEpEngine/>`_
Documentation
-------------
The build instructions can be found in ``docs/source/install.rst``.
These build instruction also cover how to generate the complete documentation using sphinx.
Issues
------
If you are not pEp internal, please send a mail to: heck@pep.foundation
If you are pEp internal, please open a ticket in our `jira bugtracker <https://pep.foundation/jira/projects/PYADPT/)`_ and for any questions, you are always welcome on #adapter>.
License
-------
|GNU AFFERO GENERAL PUBLIC LICENSE
|Version 3, 19 November 2007
|See LICENSE.txt

@ -1,31 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31005.135
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pEpPythonAdapter", "pEpPythonAdapter.vcxproj", "{F7D4314B-C7BA-4117-9AE7-AC5C1492153D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F7D4314B-C7BA-4117-9AE7-AC5C1492153D}.Debug|x64.ActiveCfg = Debug|x64
{F7D4314B-C7BA-4117-9AE7-AC5C1492153D}.Debug|x64.Build.0 = Debug|x64
{F7D4314B-C7BA-4117-9AE7-AC5C1492153D}.Debug|x86.ActiveCfg = Debug|Win32
{F7D4314B-C7BA-4117-9AE7-AC5C1492153D}.Debug|x86.Build.0 = Debug|Win32
{F7D4314B-C7BA-4117-9AE7-AC5C1492153D}.Release|x64.ActiveCfg = Release|x64
{F7D4314B-C7BA-4117-9AE7-AC5C1492153D}.Release|x64.Build.0 = Release|x64
{F7D4314B-C7BA-4117-9AE7-AC5C1492153D}.Release|x86.ActiveCfg = Release|Win32
{F7D4314B-C7BA-4117-9AE7-AC5C1492153D}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B63BC9BA-EF76-4FB4-9126-29CBFAD9092C}
EndGlobalSection
EndGlobal

@ -1,112 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<ProjectGuid>{F7D4314B-C7BA-4117-9AE7-AC5C1492153D}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Makefile</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<NMakeBuildCommandLine>nmake /F "$(ProjectDir)..\make.mak" debug</NMakeBuildCommandLine>
<NMakeOutput>
</NMakeOutput>
<NMakePreprocessorDefinitions>WIN32;_DEBUG;_DLL;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<NMakeCleanCommandLine>nmake /F "$(ProjectDir)..\make.mak" clean</NMakeCleanCommandLine>
<SourcePath>$(VC_SourcePath);$(ProjectDir)..</SourcePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<NMakeBuildCommandLine>make.cmd</NMakeBuildCommandLine>
<NMakeOutput>pEpPythonAdapter.exe</NMakeOutput>
<NMakePreprocessorDefinitions>_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<NMakeBuildCommandLine>nmake /F "$(ProjectDir)..\make.mak" release</NMakeBuildCommandLine>
<NMakeOutput>
</NMakeOutput>
<NMakePreprocessorDefinitions>WIN32;NDEBUG;_DLL;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
<NMakeCleanCommandLine>nmake /F "$(ProjectDir)..\make.mak" clean</NMakeCleanCommandLine>
<SourcePath>$(VC_SourcePath);$(ProjectDir)..</SourcePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<NMakeBuildCommandLine>make.cmd</NMakeBuildCommandLine>
<NMakeOutput>pEpPythonAdapter.exe</NMakeOutput>
<NMakePreprocessorDefinitions>NDEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>
</PropertyGroup>
<ItemDefinitionGroup>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="..\make.mak" />
<None Include="..\setup.py" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="packages\boost.1.72.0.0\build\boost.targets" Condition="Exists('packages\boost.1.72.0.0\build\boost.targets')" />
<Import Project="packages\boost_locale-vc142.1.72.0.0\build\boost_locale-vc142.targets" Condition="Exists('packages\boost_locale-vc142.1.72.0.0\build\boost_locale-vc142.targets')" />
<Import Project="packages\boost_python38-vc142.1.72.0.0\build\boost_python38-vc142.targets" Condition="Exists('packages\boost_python38-vc142.1.72.0.0\build\boost_python38-vc142.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\boost.1.72.0.0\build\boost.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\boost.1.72.0.0\build\boost.targets'))" />
<Error Condition="!Exists('packages\boost_locale-vc142.1.72.0.0\build\boost_locale-vc142.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\boost_locale-vc142.1.72.0.0\build\boost_locale-vc142.targets'))" />
<Error Condition="!Exists('packages\boost_python38-vc142.1.72.0.0\build\boost_python38-vc142.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\boost_python38-vc142.1.72.0.0\build\boost_python38-vc142.targets'))" />
</Target>
</Project>

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="boost" version="1.72.0.0" targetFramework="native" />
<package id="boost_locale-vc142" version="1.72.0.0" targetFramework="native" />
<package id="boost_python38-vc142" version="1.72.0.0" targetFramework="native" />
</packages>

@ -0,0 +1,4 @@
pEpPythonAdapter => Python 3
=> g++ | clang | CL.EXE
-> boost::python
-> pEpEngine

@ -1,19 +0,0 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SOURCEDIR = source
BUILDDIR = build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

@ -1,35 +0,0 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build
if "%1" == "" goto help
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
:end
popd

@ -1,12 +0,0 @@
pEp package
===========
Module contents
---------------
.. automodule:: pEp
:members:
:imported-members:
:undoc-members:
:show-inheritance:

@ -1,206 +0,0 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
import os
import sys
sys.path.insert(0, os.path.abspath('../../src'))
# -- Project information -----------------------------------------------------
project = "pEpPythonAdapter"
copyright = "2020, Volker Birk, heck, Hartmut Goebel, juga"
author = "Volker Birk, heck, Hartmut Goebel, juga"
import pEp
# The full version, including alpha/beta/rc tags
release = pEp.__version__
# The short X.Y version
version = ".".join(release.split(".")[:2])
# DEBUG
print("release:", release)
print("version:", version)
# -- General configuration ---------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.doctest",
"sphinx.ext.intersphinx",
"sphinx.ext.todo",
"sphinx.ext.coverage",
"sphinx.ext.viewcode",
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = ".rst"
# The master toctree document.
master_doc = "index"
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = None
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = "nature"
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ["_static"]
# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}
# -- Options for HTMLHelp output ---------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = "pEpPythonAdapterdoc"
# -- Options for LaTeX output ------------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(
master_doc,
"pEpPythonAdapter.tex",
"pEpPythonAdapter Documentation",
"2020, Volker Birk, heck, juga",
"manual",
)
]
# -- Options for manual page output ------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(
master_doc,
"peppythonadapter",
"pEpPythonAdapter Documentation",
[author],
1,
)
]
# -- Options for Texinfo output ----------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(
master_doc,
"pEpPythonAdapter",
"pEpPythonAdapter Documentation",
author,
"pEpPythonAdapter",
"One line description of project.",
"Miscellaneous",
)
]
# -- Options for Epub output -------------------------------------------------
# Bibliographic Dublin Core info.
epub_title = project
# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#
# epub_identifier = ''
# A unique identification for the text.
#
# epub_uid = ''
# A list of files that should not be packed into the epub file.
epub_exclude_files = ["search.html"]
# -- Extension configuration -------------------------------------------------
# -- Options for intersphinx extension ---------------------------------------
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {"https://docs.python.org/": None}
# -- Options for todo extension ----------------------------------------------
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True

@ -1,21 +0,0 @@
.. pEpPythonAdapter documentation master file, created by
sphinx-quickstart on Wed Oct 21 12:35:11 2020.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to pEpPythonAdapter's documentation!
============================================
.. toctree::
:maxdepth: 2
:caption: Contents:
install
software_using
api/pEp
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

@ -1,143 +0,0 @@
Installation
============
Requirements
------------
In order to build, use or install this extension module, you need to have some
system dependencies already installed:
* pEp-base (sequoia, libetpan, asn1c, yml2, pEpEngine, libpEpAdapter)
* boost-python
These `build instructions <https://dev.pep.foundation/Common%20Adapter%20Documentation/Adapter%20Build%20Instructions>`_ will get you all setup.
Additionally, there is a `build script <http://pep-security.lu/gitlab/juga/Internal-Deployment/-/blob/master/build-pep-stack.sh>`_
that executes these build instructions automatically (Debian and MacOS):
.. Note:: If you dont install pEp-base system wide, but under a prefix, like /home/foo/local/,
you will need to have LD_LIBARY_PATH/DYLD_LIBRARY_PATH adjusted for all the following operations.
Build
-----
The pEpPythonAdapter is a python extension module that contains C/C++ code that needs to be
compiled first. So, before any use or installation, the module needs to be built.
Build config
~~~~~~~~~~~~
Create a local build config by creating a 'local.conf' file. There is a 'local.conf.example' describing
all the build options. You can use this as a template.
``cp local.conf.example local.conf``
If you have pEp-base installed under a custom prefix (e.g. /home/foo/local) it is important
that you specify "PREFIX".
Build
~~~~~
To build the module just type:
``make``
This will compile the C/C++ parts of the module and create the python packages in the .egg and .wheel format
in the dist/ dir.
Virtualenv
----------
We recommend using a venv to work on/with the pEpPythonAdapter.
There is a convenience make target that will create and activate a venv that already has the LD_LIBRARY_PATH
or DYLD_LIBRARY_PATH set according to your ``local.conf``.
If the venv does not exist yet it will be created and activated.
If the venv already exists it will only be activated.
``make venv``
After that, to install the pEp module into the venv, do:
``make install``
Installation
------------
You can install the module in the in the following ways.
To install the extension module system wide or into a venv, use:
``make install``
To install the extension module into your home dir, use:
``make install-user``
Test
----
To run the whole testsuite you need to first create/activate the venv:
``make venv``
then install the test-dependencies:
``make install-test``
And finally run the test-suite:
``make test``
Module Development
------------------
To develop on the module itself, first of all create and activate a venv:
``make venv``
Then, in the venv install the module in development mode.
``make develop``
While developing there are two levels of changes. Changes to the python part of the module (pEp), and
changes to the C/C++ part of the module (_pEp). If you change just python code, the changes are effective immediately.
If you do changes to the C/C++ part you need to issue ``make develop`` again, to recompile the extension and install
the new binary (.so/.dylib) of the module into the venv.
Documentation
-------------
The documentation of the pEpPythonAdapter uses `Sphinx <https://www.sphinx-doc.org/>`_
Refer to the `Sphinx installation instructions <https://www.sphinx-doc.org/en/master/usage/installation.html>`_ to install it.
To generate the documentation in the HTML format, there is a make target "docs"
But first, you need to create/activate the venv or set the LD_LIBRARY_PATH manually.
``make venv``
``make docs``
You can see the generated HTML documentation in a browser opening the directory
`docs/build/html`.
Housekeeping
------------
There are the following "clean" targets.
To delete all the generated documentation, run:
``make docs-clean``
To delete all the "derived" files including eggs, wheels, shared libs, build files and caches, run:
``make clean``
To delete all of make clean plus the venv (should equal a complete reset), run:
``make clean-all``
Docker
------
If you know how to use docker, you can avoid having to install all
the dependencies using the image
https://registry.gitlab.com/juga0/pepdocker/peppythonadapter.
.. Note:: This docker image is not officially maintained and it exists only
until there is an official Debian one.

@ -1,7 +0,0 @@
Software using pEpPythonAdapter
===============================
- `pEpProxy <https://pep-security.lu/gitlab/marcel/pepproxy>`_
- `command-line-tool <https://pep-security.lu/gitlab/enterprise-editon/command-line-tool>`_
- `pEpPythonMixnet <https://gitea.pep.foundation/pEp.foundation/pEpPythonMixnet>`_
- `pEpSimulator <URL???>`_

@ -1,131 +0,0 @@
#/!usr/bin/env python3
#
# Copyleft 2020, p≡p Security
# Copyleft 2020, Hartmut Goebel <h.goebel@crazy-compilers.com>
#
# This file is under GNU General Public License 3.0
"""
This examples shows how to transport pEp messages within a
simple XML based message format which is capable for attachments.
pEp message elements loosely follow the "pEp for XML specification" and
https://pEp.software/ns/pEp-1.0.xsd.
IMPORTANT: In this example, no error checking is done. Neither is
the "pEp for XML" specification enforced.
Structure of the simple XML based message:
<msg>
<from>from-addr</from>
<to>to-addr</to>
<body>text of the messgage (must not be XML)</bod>
<attachments>
<attachment>textual data</attachment>
<attachments>
</msg>
"""
from lxml import etree
import email.utils
import pEp
__all__ = ["serialize_pEp_message", "parse_serialized_message"]
CT2TAG = {
'application/pgp-keys': 'keydata',
'application/pEp.sync': 'sync',
'application/pEp.distribution': 'distribution',
'application/pgp-signature': 'signature',
}
TAG2CT = dict((v,k)for (k,v) in CT2TAG.items())
PEP_NAMESPACE = "https://pEp.software/ns/pEp-1.0.xsd"
PEP_NS = '{%s}' % PEP_NAMESPACE
NSMAP = {'pEp': PEP_NAMESPACE}
INCOMING = 0
OUTGOING = 1
UNENCRYPTED = 0
def serialize_pEp_message(msg):
root = etree.Element("msg", nsmap=NSMAP)
etree.SubElement(root, "to").text = str(msg.to[0])
etree.SubElement(root, "from").text = str(msg.from_)
if msg.enc_format == UNENCRYPTED:
# unencrypted
etree.SubElement(root, "body").text = msg.longmsg
attachments = etree.SubElement(root, "attachments")
# FIXME: Namespace
attachments = etree.SubElement(attachments,
PEP_NS + "attachments",
version=msg.opt_fields['X-pEp-Version'])
# TODO: opt_fields, esp. auto-consume
# TODO: Order pEp attachments by type
for attach in msg.attachments:
# no need to base64-encode, attachement are ascii-armoured
# already
#attachment = base64_encode(attachment)
# FIXME: Namespace
a = etree.SubElement(attachments,
PEP_NS + CT2TAG[attach.mime_type])
a.text = attach.decode("ascii")
else: # encrypted
# forget about longmsg and original body
# encrypted message is an attachment and there might be
# further attachments, e.g. new keys
# build a new message out of these attachments
etree.SubElement(root, "body") # emptry body
attachments = etree.SubElement(root, "attachments")
assert len(msg.attachments) == 2
# first attachment is "Version: 1"
attach = msg.attachments[1]
# no need to base64-encode, attachements are ascii-armoured
# already
n = etree.SubElement(root, PEP_NS + "message")
n.text = attach.decode("ascii")
return etree.tostring(root)
def parse_serialized_message(transport_message):
def addr2identity(text):
name, addr = email.utils.parseaddr(text)
ident = pEp.Identity(addr, name)
ident.update()
return ident
# parse the XML text, fetch from and to
root = etree.fromstring(transport_message)
from_ = addr2identity(root.xpath("./from/text()")[0])
msg1 = pEp.Message(INCOMING, from_)
msg1.to.append(addr2identity(root.xpath("./to/text()")[0]))
enc_msg = root.find("{%s}message" % PEP_NAMESPACE)
if enc_msg is not None:
# this is an encrypted message, ignore all but the encrypted message
msg1.attachments = [
# As of Engine r4652 the encrypted message must be the second
# attachment
pEp.Blob(b"Version: 1", "application/pgp-encrypted"),
pEp.Blob(enc_msg.text.encode(), "application/xxpgp-encrypted")]
else:
# this is an unencrypted message, might contain pEp attachments
msg1.longmsg = root.findtext("body")
pEp_attachments = None
attachments = root.find("attachments")
if attachments is not None:
pEp_attachments = attachments.find("{%s}attachments" % PEP_NAMESPACE)
if pEp_attachments is not None:
msg1.opt_fields['X-pEp-Version'] = pEp_attachments.attrib["version"]
pEp_attachs = []
for tagname in ("keydata", "signature", "sync", "distribution"):
for attach in pEp_attachments.iterfind(
"{%s}%s" % (PEP_NAMESPACE, tagname)):
pEp_attachs.append(
pEp.Blob(attach.text.encode(), TAG2CT[tagname]))
msg1.attachments = pEp_attachs
msg2, keys, rating, flags = msg1.decrypt()
return msg2, rating

@ -1,11 +0,0 @@
# This is an Example build config file (local.conf)
# you might not need this file, but if the defaults dont work for you
# You can override them here.
# Tweak the values to your needs and rename it to local.conf
######### C++ Compiler #########
# DEBUG=1
# DEBUG=0
############# DIRS #############
# PREFIX=$(HOME)/local

@ -1,39 +0,0 @@
# build dirs
BUILD_DIR = $(ProjectDir)..\build
DIST_DIR = $(ProjectDir)..\dist
# create wheel and egg package in dist
dist: dist-whl dist-egg
# create wheel package in dist
dist-whl: compile
PY -3.8-32 setup.py bdist_wheel
# create egg package in dist
dist-egg: compile
PY -3.8-32 setup.py bdist_egg
# build the module into build
compile:
CD..
PY -3.8-32 setup.py build_ext --debug
# delete output directories
clean:
@if exist $(BUILD_DIR) rmdir /S /Q $(BUILD_DIR)
@if exist $(DIST_DIR) rmdir /S /Q $(DIST_DIR)
# create directories and build application
all: clean dist
# release build
release: clean
CD..
PY -3.8-32 setup.py build_ext
PY -3.8-32 setup.py bdist_wheel
#debug build
debug: clean
CD..
PY -3.8-32 setup.py build_ext --debug
PY -3.8-32 setup.py bdist_wheel

@ -1,18 +0,0 @@
[build-system]
# Preparing for PEP-517/PEP-518, but not in effect yet.
# These requires are not effective yet, setup.cfg is.
requires =[
"setuptools >=39.2.0",
"setuptools_scm >= 4.1.2",
"wheel >= 0.35.1" ]
build-backend = "setuptools.build_meta"
[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-rP --forked"
testpaths = [
"tests",
]

@ -1,46 +0,0 @@
[metadata]
name = pEp
url = https://pep.foundation
download_url =
ext_package = pEp
author = Volker Birk, heck, Hartmut Goebel, juga
author_email = vb@pep-project.org
maintainer = heck
maintainer_email = heck@pep.foundation
description = p≡p for Python
long_description = file: README.md
keywords = pEp, crypto, end-to-end, python adapter, key management, high-level
license = GNU Affero General Public License
license_files = LICENSE.txt
platforms = linux, macOs
classifiers =
Intended Audience :: Developers
Topic :: Utilities
License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
Natural Language :: English
Operating System :: OS Independent
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Development Status :: 3 - Alpha
[options]
zip_safe = false
include_package_data = true
python_requires = >=3.7,<3.9
test_suite = tests
install_requires =
# deprecated/redundant with pyproject.toml, but lets keep both ways around for now
setup_requires =
setuptools >=39.2.0
setuptools_scm >= 4.1.2
wheel >= 0.35.1
[options.extras_require]
# To install these dependencies, run pip install .[test]
test =
pytest
pytest-forked
lxml
termcolor
doc = sphinx

@ -1,226 +1,285 @@
# -*- coding: utf-8 -*-
# This file is under GNU Affero General Public License 3.0
# see LICENSE.txt
#
# For more debugging, export DISTUTILS_DEBUG=True
from __future__ import print_function
import sys
from sys import argv
import os
from os import environ
from os.path import join
import platform
from os import environ, uname
from os.path import dirname, exists, join
from setuptools import setup, Extension
from glob import glob
import sysconfig
if sys.platform == 'winnt':
if sys.version_info[0] >= 3:
import winreg
else:
import _winreg as winreg
from setuptools.command.build_ext import build_ext
def pEpLog(*msg):
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)
if sys.version_info[0] < 3:
FileNotFoundError = EnvironmentError
def find(fname, pathlist):
for path in pathlist:
cand_fname = join(path, fname)
if exists(cand_fname):
return path
raise FileNotFoundError(fname)
def append_once(lst, element):
if element not in lst:
lst.append(element)
def extend_once(lst, elements):
for element in elements:
if element not in lst:
lst.append(element)
def getPythonLibver():
g = sysconfig.get_config_vars()
sent = []
for template in (
'{cmd}{py_version_nodot}{abiflags}',
'{cmd}{py_version_nodot}',
'{cmd}{py_version_major}',
'{cmd}{py_version_major}{abiflags}',
'{cmd}'
):
val = template.format(
cmd = g['PYTHON'],
py_version_nodot = g['py_version_nodot'],
py_version_major = sys.version_info[0],
abiflags = g.get('ABIFLAGS', ''),
)
if val not in sent:
yield val
sent.append(val)
class BuildExtCommand(build_ext):
# default_pyver = next( getPythonLibver() )
user_options = build_ext.user_options + [
('prefix=', None, 'Use pEp-base installation in prefix (libs/includes)'),
# ('boost-python=', None, 'Boost Python version to use (e.g. \'python34\')'),
('local', None, 'Use local pEp install in HOME/USERPROFILE'),
('with-pEp-engine=', None, 'Path to pEp Engine source'),
('with-pEp-libadapter=', None, 'Path to pEp C++ Adapter Library source'),
('with-boost=', None, 'Path to Boost install prefix'),
('with-asn1c-share=', None, 'Path to installed ASN1C share directory'),
]
def initialize_options(self):
build_ext.initialize_options(self)
self.prefix = getattr(self, "prefix=", None)
def windowsGetInstallLocation(self):
reg_path = "SOFTWARE\\Classes\\TypeLib\\{564A4350-419E-47F1-B0DF-6FCCF0CD0BBC}\\1.0\\0\\win32"
KeyName = None
def windowsGetInstallLocation():
# 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)
REG_PATH = "Software\\Microsoft\\Office\\Outlook\\Addins\\pEp"
regKey = None
pEpLog("Registry Lookup:", reg_path, KeyName)
try:
regKey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, reg_path, 0, winreg.KEY_READ)
regKey = winreg.OpenKey(
winreg.HKEY_LOCAL_MACHINE, REG_PATH, 0, winreg.KEY_READ)
# Keys: Description, FileName, FriendlyName, LoadBehavior
com_server, _ = winreg.QueryValueEx(regKey, KeyName)
except WindowsError as error:
pEpLog("Error ocurred: " + error)
com_server, regtype = winreg.QueryValueEx(regKey, 'FileName')
winreg.CloseKey(regKey)
except WindowsError:
com_server = None
finally:
if winreg:
winreg.CloseKey(regKey)
# <install-base>\\bin\\COM_Server.exe
dirname = os.path.dirname
ret = dirname(dirname(com_server))
pEpLog("Value:", ret)
return ret
def windowsGetBoostDirs(self):
for dir in [f.path for f in os.scandir(join(os.getcwd(), 'build-windows', 'packages')) if f.is_dir()]:
if 'boost.' in dir or 'boost_python' in dir or 'boost_locale' in dir:
yield join(dir, 'lib', 'native'), join(dir, 'lib', 'native', 'include')
def get_build_info_win32(self):
home = environ.get('PER_USER_DIRECTORY') or environ.get('USERPROFILE')
inst_prefix = self.windowsGetInstallLocation()
sys_includes = [
join(inst_prefix),
] + [d[1] for d in self.windowsGetBoostDirs()]
sys_libdirs = [ join(inst_prefix, 'Debug')] if self.debug else [ join(inst_prefix, 'Release')]
sys_libdirs += [d[0] for d in self.windowsGetBoostDirs()]
libs = [
'pEpEngine',
'libpEpAdapter',
'boost_python38-vc142-mt-x32-1_72',
'boost_locale-vc142-mt-x32-1_72'
]
compile_flags = ['/std:c++14', '/permissive']
if self.debug:
pEpLog("debug mode")
compile_flags += ['/Od', '/Zi', '/DEBUG']
return (home, sys_includes, sys_libdirs, libs, compile_flags)
def get_build_info_darwin(self):
home = environ.get('PER_USER_DIRECTORY') or environ.get('HOME')
sys_includes = [
'/opt/local/include',
]
sys_libdirs = [
'/opt/local/lib',
]
libs = [
'pEpEngine',
'pEpAdapter',
'boost_python38-mt',
'boost_locale-mt'
]
compile_flags = ['-std=c++14', '-fpermissive']
if self.debug:
pEpLog("debug mode")
compile_flags += ['-O0', '-g', '-UNDEBUG']
return (home, sys_includes, sys_libdirs, libs, compile_flags)
def get_build_info_linux(self):
home = environ.get('PER_USER_DIRECTORY') or environ.get('HOME')
sys_includes = [
'/usr/local/include',
'/usr/include',
]
sys_libdirs = [
'/usr/local/lib',
'/usr/lib',
'/usr/lib/{}-linux-gnu'.format(platform.machine())
]
libs = [
'pEpEngine',
'pEpAdapter',
'boost_python3',
'boost_locale'
]
compile_flags = ['-std=c++14', '-fpermissive']
if self.debug:
pEpLog("debug mode")
compile_flags += ['-O0', '-g', '-UNDEBUG']
return (home, sys_includes, sys_libdirs, libs, compile_flags)
return dirname( dirname( com_server ) )
def initialize_options(self):
build_ext.initialize_options(self)
# self.boost_python = BuildExtCommand.default_pyver
self.local = None != environ.get('PER_USER_DIRECTORY')
self.with_pEp_engine = None
self.with_pEp_libadapter = None
self.with_boost = None
self.with_asn1c_share = None
def finalize_options(self):
build_ext.finalize_options(self)
pEpLog("prefix: ", self.prefix)
pEpLog("sys.platform: ", sys.platform)
# get build information for platform
if sys.platform == 'win32':
build_info = self.get_build_info_win32()
elif sys.platform == 'darwin':
build_info = self.get_build_info_darwin()
elif sys.platform == 'linux':
build_info = self.get_build_info_linux()
# normalize paths given by user (expand tilde etc.)
for with_option in ('pEp_engine', 'pEp_libadapter', 'boost', 'asn1c_share'):
w_opt = 'with_' + with_option
w_val = getattr(self, w_opt)
if w_val != None:
setattr(self, w_opt, os.path.normpath(w_val))
if sys.platform == 'darwin':
HOME = environ.get('PER_USER_DIRECTORY') or environ.get('HOME')
PEPLIBNAME = 'libpEpEngine.dylib'
LIBPEPA = 'libpEpAdapter.a'
BOOSTLIBNAME = 'libboost_{boost_python:s}-mt.dylib'
SYS_INCLUDES = [
'/opt/local/include', # we prefer MacPorts over Homebrew (but support both)
'/usr/local/include',
'/Library/Frameworks/PrettyEasyPrivacy.framework/Versions/A/include',
join(environ["HOME"], 'include'),
'/usr/include',
]
SYS_SHARES = [
'/opt/local/share',
'/usr/local/share',
'/Library/Frameworks/PrettyEasyPrivacy.framework/Versions/A/share',
join(environ["HOME"], 'share'),
'/usr/share',
]
SYS_LIB_PREFIXES = [
'/opt/local/lib',
'/usr/local/lib',
'/Library/Frameworks/PrettyEasyPrivacy.framework/Versions/A/lib',
join(environ["HOME"], 'lib'),
'/usr/lib',
]
elif sys.platform == 'winnt':
HOME = environ.get('PER_USER_DIRECTORY') or environ.get('USERPROFILE')
SYS_ROOT = environ.get('SystemRoot')
PROFILE_ROOT = environ.get('AppData')
LOCAL_ROOT = environ.get('LocalAppData')
INST_PREFIX = windowsGetInstallLocation()
PEPLIBNAME = 'pEpEngine.dll'
LIBPEPA = 'libpEpAdapter.a'
BOOSTLIBNAME = 'boost_{boost_python:s}-mt.dll'
SYS_INCLUDES = [
join(INST_PREFIX, 'include'),
join(PROFILE_ROOT, 'pEp', 'include'),
join(LOCAL_ROOT, 'pEp', 'include'),
join(SYS_ROOT, 'pEp', 'include'),
]
SYS_SHARES = [
join(INST_PREFIX, 'share'),
join(PROFILE_ROOT, 'pEp', 'share'),
join(LOCAL_ROOT, 'pEp', 'share'),
join(SYS_ROOT, 'pEp', 'share'),
]
SYS_LIB_PREFIXES = [
join(INST_PREFIX, 'bin'),
join(PROFILE_ROOT, 'pEp', 'bin'),
join(LOCAL_ROOT, 'pEp', 'bin'),
join(SYS_ROOT, 'pEp', 'bin'),
]
else:
pEpLog("Platform not supported:" + sys.platform)
exit()
(home, sys_includes, sys_libdirs, libs, compile_flags) = build_info
# Build the Includes -I and Library paths -L
# Start empty
includes = []
libdirs = []
HOME = environ.get('PER_USER_DIRECTORY') or environ.get('HOME')
PEPLIBNAME = 'pEpEngine.so'
LIBPEPA = 'libpEpAdapter.a'
BOOSTLIBNAME = 'boost_{boost_python:s}-mt.so'
SYS_INCLUDES = ['/usr/local/pEp/include', '/usr/local/include', '/usr/include']
SYS_SHARES = ['/usr/local/pEp/share', '/usr/local/share', '/usr/share']
SYS_LIB_PREFIXES = ['/usr/local/pEp/bin', '/usr/local/bin', '/usr/bin']
use_local_incl = (self.local or os.path.isfile(
join(HOME, 'include', 'pEp', 'pEpEngine.h')) )
use_local_lib = (self.local or os.path.isfile(
join(HOME, 'lib', PEPLIBNAME)) )
INCLUDES = [ join(HOME, 'include') ] if use_local_incl else []
INCLUDES.extend(SYS_INCLUDES)
SHARES = [ join(HOME, 'share') ] if use_local_incl else []
SHARES.extend(SYS_SHARES)
LIBS = [ join(HOME, 'lib') ] if use_local_lib else []
LIBS.extend(SYS_LIB_PREFIXES)
if not self.with_pEp_engine:
ENGINE_INC = find( join('pEp', 'pEpEngine.h'), INCLUDES )
ENGINE_LIB = find( PEPLIBNAME, LIBS )