Skip to content

Commit 819cecd

Browse files
authored
Merge pull request #1444 from goffi-contrib/omemo_recipe
[omemo] Added recipes needed to build omemo module
2 parents 7c125ad + d853e81 commit 819cecd

File tree

11 files changed

+286
-0
lines changed

11 files changed

+286
-0
lines changed

ci/constants.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ class TargetPython(Enum):
3838
'm2crypto',
3939
'netifaces',
4040
'Pillow',
41+
# depends on cffi that still seems to have compilation issues
42+
'protobuf_cpp',
43+
'xeddsa',
44+
'x3dh',
45+
'pynacl',
46+
'doubleratchet',
47+
'omemo',
4148
'cryptography',
4249
# https://github.com/kivy/python-for-android/issues/1405
4350
'psycopg2',
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
from pythonforandroid.recipe import PythonRecipe
2+
3+
4+
class DoubleRatchetRecipe(PythonRecipe):
5+
name = 'doubleratchet'
6+
version = '0.4.0'
7+
url = 'https://pypi.python.org/packages/source/D/DoubleRatchet/DoubleRatchet-{version}.tar.gz'
8+
depends = [
9+
('python2', 'python3crystax'),
10+
'setuptools',
11+
'cryptography',
12+
]
13+
patches = ['requires_fix.patch']
14+
call_hostpython_via_targetpython = False
15+
16+
17+
recipe = DoubleRatchetRecipe()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff -urN DoubleRatchet.ori/setup.py DoubleRatchet/setup.py
2+
--- DoubleRatchet.ori/setup.py 2018-10-28 18:55:16.259540354 +0100
3+
+++ DoubleRatchet/setup.py 2018-10-28 18:55:39.349541117 +0100
4+
@@ -21,7 +21,7 @@
5+
author_email = "[email protected]",
6+
license = "MIT",
7+
packages = find_packages(),
8+
- install_requires = [ "cryptography>=1.7.1" ],
9+
+ install_requires = [],
10+
python_requires = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4",
11+
zip_safe = True,
12+
classifiers = [
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from pythonforandroid.recipe import PythonRecipe
2+
3+
4+
class OmemoRecipe(PythonRecipe):
5+
name = 'omemo'
6+
version = '0.7.1'
7+
url = 'https://pypi.python.org/packages/source/O/OMEMO/OMEMO-{version}.tar.gz'
8+
site_packages_name = 'omemo'
9+
depends = [
10+
('python2', 'python3crystax'),
11+
'setuptools',
12+
'protobuf_cpp',
13+
'x3dh',
14+
'DoubleRatchet',
15+
'hkdf==0.0.3',
16+
]
17+
patches = ['remove_dependencies.patch', 'wireformat.patch']
18+
call_hostpython_via_targetpython = False
19+
20+
21+
recipe = OmemoRecipe()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
diff -urN OMEMO-0.7.1.ori/setup.py OMEMO-0.7.1/setup.py
2+
--- OMEMO-0.7.1.ori/setup.py 2018-09-09 16:31:44.000000000 +0200
3+
+++ OMEMO-0.7.1/setup.py 2018-11-02 09:08:50.819963131 +0100
4+
@@ -15,12 +15,6 @@
5+
license = "GPLv3",
6+
packages = find_packages(),
7+
install_requires = [
8+
- "X3DH>=0.5.3,<0.6",
9+
- "DoubleRatchet>=0.4.0,<0.5",
10+
- "hkdf==0.0.3",
11+
- "pynacl>=1.0.1",
12+
- "cryptography>=1.7.1",
13+
- "protobuf>=2.6.1"
14+
],
15+
python_requires = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4",
16+
zip_safe = True,
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
diff -urN OMEMO-0.7.1.ori/omemo/signal/wireformat/whispertextprotocol_pb2.py OMEMO-0.7.1/omemo/signal/wireformat/whispertextprotocol_pb2.py
2+
--- OMEMO-0.7.1.ori/omemo/signal/wireformat/whispertextprotocol_pb2.py 2018-09-02 21:04:26.000000000 +0200
3+
+++ OMEMO-0.7.1/omemo/signal/wireformat/whispertextprotocol_pb2.py 2018-11-02 10:39:15.196715321 +0100
4+
@@ -21,7 +21,6 @@
5+
syntax='proto2',
6+
serialized_pb=_b('\n\x19WhisperTextProtocol.proto\"R\n\rSignalMessage\x12\x16\n\x0e\x64h_ratchet_key\x18\x01 \x01(\x0c\x12\t\n\x01n\x18\x02 \x01(\r\x12\n\n\x02pn\x18\x03 \x01(\r\x12\x12\n\nciphertext\x18\x04 \x01(\x0c\"\x7f\n\x13PreKeySignalMessage\x12\x17\n\x0fregistration_id\x18\x05 \x01(\r\x12\x0f\n\x07otpk_id\x18\x01 \x01(\r\x12\x0e\n\x06spk_id\x18\x06 \x01(\r\x12\n\n\x02\x65k\x18\x02 \x01(\x0c\x12\n\n\x02ik\x18\x03 \x01(\x0c\x12\x16\n\x0esignal_message\x18\x04 \x01(\x0c')
7+
)
8+
-_sym_db.RegisterFileDescriptor(DESCRIPTOR)
9+
10+
11+
12+
@@ -39,28 +38,28 @@
13+
has_default_value=False, default_value=_b(""),
14+
message_type=None, enum_type=None, containing_type=None,
15+
is_extension=False, extension_scope=None,
16+
- options=None),
17+
+ options=None, file=DESCRIPTOR),
18+
_descriptor.FieldDescriptor(
19+
name='n', full_name='SignalMessage.n', index=1,
20+
number=2, type=13, cpp_type=3, label=1,
21+
has_default_value=False, default_value=0,
22+
message_type=None, enum_type=None, containing_type=None,
23+
is_extension=False, extension_scope=None,
24+
- options=None),
25+
+ options=None, file=DESCRIPTOR),
26+
_descriptor.FieldDescriptor(
27+
name='pn', full_name='SignalMessage.pn', index=2,
28+
number=3, type=13, cpp_type=3, label=1,
29+
has_default_value=False, default_value=0,
30+
message_type=None, enum_type=None, containing_type=None,
31+
is_extension=False, extension_scope=None,
32+
- options=None),
33+
+ options=None, file=DESCRIPTOR),
34+
_descriptor.FieldDescriptor(
35+
name='ciphertext', full_name='SignalMessage.ciphertext', index=3,
36+
number=4, type=12, cpp_type=9, label=1,
37+
has_default_value=False, default_value=_b(""),
38+
message_type=None, enum_type=None, containing_type=None,
39+
is_extension=False, extension_scope=None,
40+
- options=None),
41+
+ options=None, file=DESCRIPTOR),
42+
],
43+
extensions=[
44+
],
45+
@@ -91,42 +90,42 @@
46+
has_default_value=False, default_value=0,
47+
message_type=None, enum_type=None, containing_type=None,
48+
is_extension=False, extension_scope=None,
49+
- options=None),
50+
+ options=None, file=DESCRIPTOR),
51+
_descriptor.FieldDescriptor(
52+
name='otpk_id', full_name='PreKeySignalMessage.otpk_id', index=1,
53+
number=1, type=13, cpp_type=3, label=1,
54+
has_default_value=False, default_value=0,
55+
message_type=None, enum_type=None, containing_type=None,
56+
is_extension=False, extension_scope=None,
57+
- options=None),
58+
+ options=None, file=DESCRIPTOR),
59+
_descriptor.FieldDescriptor(
60+
name='spk_id', full_name='PreKeySignalMessage.spk_id', index=2,
61+
number=6, type=13, cpp_type=3, label=1,
62+
has_default_value=False, default_value=0,
63+
message_type=None, enum_type=None, containing_type=None,
64+
is_extension=False, extension_scope=None,
65+
- options=None),
66+
+ options=None, file=DESCRIPTOR),
67+
_descriptor.FieldDescriptor(
68+
name='ek', full_name='PreKeySignalMessage.ek', index=3,
69+
number=2, type=12, cpp_type=9, label=1,
70+
has_default_value=False, default_value=_b(""),
71+
message_type=None, enum_type=None, containing_type=None,
72+
is_extension=False, extension_scope=None,
73+
- options=None),
74+
+ options=None, file=DESCRIPTOR),
75+
_descriptor.FieldDescriptor(
76+
name='ik', full_name='PreKeySignalMessage.ik', index=4,
77+
number=3, type=12, cpp_type=9, label=1,
78+
has_default_value=False, default_value=_b(""),
79+
message_type=None, enum_type=None, containing_type=None,
80+
is_extension=False, extension_scope=None,
81+
- options=None),
82+
+ options=None, file=DESCRIPTOR),
83+
_descriptor.FieldDescriptor(
84+
name='signal_message', full_name='PreKeySignalMessage.signal_message', index=5,
85+
number=4, type=12, cpp_type=9, label=1,
86+
has_default_value=False, default_value=_b(""),
87+
message_type=None, enum_type=None, containing_type=None,
88+
is_extension=False, extension_scope=None,
89+
- options=None),
90+
+ options=None, file=DESCRIPTOR),
91+
],
92+
extensions=[
93+
],
94+
@@ -145,6 +144,7 @@
95+
96+
DESCRIPTOR.message_types_by_name['SignalMessage'] = _SIGNALMESSAGE
97+
DESCRIPTOR.message_types_by_name['PreKeySignalMessage'] = _PREKEYSIGNALMESSAGE
98+
+_sym_db.RegisterFileDescriptor(DESCRIPTOR)
99+
100+
SignalMessage = _reflection.GeneratedProtocolMessageType('SignalMessage', (_message.Message,), dict(
101+
DESCRIPTOR = _SIGNALMESSAGE,
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
from pythonforandroid.recipe import CompiledComponentsPythonRecipe
2+
import os
3+
4+
5+
class PyNaCLRecipe(CompiledComponentsPythonRecipe):
6+
name = 'pynacl'
7+
version = '1.3.0'
8+
url = 'https://pypi.python.org/packages/source/P/PyNaCl/PyNaCl-{version}.tar.gz'
9+
10+
depends = ['hostpython2', 'python2', 'six', 'setuptools', 'cffi', 'libsodium']
11+
call_hostpython_via_targetpython = False
12+
13+
def get_recipe_env(self, arch):
14+
env = super(PyNaCLRecipe, self).get_recipe_env(arch)
15+
env['SODIUM_INSTALL'] = 'system'
16+
17+
libsodium_build_dir = self.get_recipe(
18+
'libsodium', self.ctx).get_build_dir(arch.arch)
19+
env['CFLAGS'] += ' -I{}'.format(os.path.join(libsodium_build_dir,
20+
'src/libsodium/include'))
21+
env['LDFLAGS'] += ' -L{}'.format(
22+
self.ctx.get_libs_dir(arch.arch) +
23+
'-L{}'.format(self.ctx.libs_dir)) + ' -L{}'.format(
24+
libsodium_build_dir)
25+
26+
return env
27+
28+
29+
recipe = PyNaCLRecipe()
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from pythonforandroid.recipe import PythonRecipe
2+
3+
4+
class X3DHRecipe(PythonRecipe):
5+
name = 'x3dh'
6+
version = '0.5.3'
7+
url = 'https://pypi.python.org/packages/source/X/X3DH/X3DH-{version}.tar.gz'
8+
site_packages_name = 'x3dh'
9+
depends = [
10+
('python2', 'python3crystax'),
11+
'setuptools',
12+
'cryptography',
13+
'xeddsa',
14+
]
15+
patches = ['requires_fix.patch']
16+
call_hostpython_via_targetpython = False
17+
18+
19+
recipe = X3DHRecipe()
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff -urN X3DH-0.5.3.ori/setup.py X3DH-0.5.3/setup.py
2+
--- X3DH-0.5.3.ori/setup.py 2018-10-28 19:15:16.444766623 +0100
3+
+++ X3DH-0.5.3/setup.py 2018-10-28 19:15:38.028060948 +0100
4+
@@ -24,7 +24,7 @@
5+
author_email = "[email protected]",
6+
license = "MIT",
7+
packages = find_packages(),
8+
- install_requires = [ "cryptography>=1.7.1", "XEdDSA>=0.4.2" ],
9+
+ install_requires = [],
10+
python_requires = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4",
11+
zip_safe = True,
12+
classifiers = [
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from pythonforandroid.recipe import CythonRecipe
2+
from pythonforandroid.toolchain import current_directory, shprint
3+
from os.path import join
4+
import sh
5+
6+
7+
class XedDSARecipe(CythonRecipe):
8+
name = 'xeddsa'
9+
version = '0.4.4'
10+
url = 'https://pypi.python.org/packages/source/X/XEdDSA/XEdDSA-{version}.tar.gz'
11+
depends = [
12+
('python2', 'python3crystax'),
13+
'setuptools',
14+
'cffi',
15+
'pynacl',
16+
]
17+
patches = ['remove_dependencies.patch']
18+
call_hostpython_via_targetpython = False
19+
20+
def build_arch(self, arch):
21+
with current_directory(join(self.get_build_dir(arch.arch))):
22+
env = self.get_recipe_env(arch)
23+
hostpython = sh.Command(self.ctx.hostpython)
24+
shprint(
25+
hostpython, 'ref10/build.py',
26+
_env=env
27+
)
28+
python_version = self.ctx.python_recipe.version[0:3]
29+
site_packages_dir = 'lib/python{python_version}/site-packages'.format(
30+
python_version=python_version)
31+
site_packages = join(self.ctx.get_python_install_dir(),
32+
site_packages_dir)
33+
shprint(sh.cp, '_crypto_sign.so', site_packages)
34+
self.install_python_package(arch)
35+
36+
37+
recipe = XedDSARecipe()
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff -urN XEdDSA-0.4.4.ori/setup.py XEdDSA-0.4.4/setup.py
2+
--- XEdDSA-0.4.4.ori/setup.py 2018-09-23 16:08:35.000000000 +0200
3+
+++ XEdDSA-0.4.4/setup.py 2018-10-30 08:21:23.338790184 +0100
4+
@@ -22,9 +22,8 @@
5+
author_email = "[email protected]",
6+
license = "MIT",
7+
packages = find_packages(),
8+
- install_requires = [ "cffi>=1.9.1", "pynacl>=1.0.1" ],
9+
- setup_requires = [ "cffi>=1.9.1" ],
10+
- cffi_modules = [ os.path.join("ref10", "build.py") + ":ffibuilder" ],
11+
+ install_requires = ["pynacl>=1.0.1" ],
12+
+ setup_requires = [],
13+
python_requires = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, <4",
14+
include_package_data = True,
15+
zip_safe = False,

0 commit comments

Comments
 (0)