Skip to content

Commit eff95e9

Browse files
committed
Add cryptography recipe workaround for Android linking
1 parent 6e90999 commit eff95e9

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

recipes/cryptography/__init__.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Workaround for `ImportError: dlopen failed: cannot locate symbol`
2+
# https://github.com/kivy/python-for-android/issues/3329
3+
4+
from pythonforandroid.recipes.cryptography import (
5+
CryptographyRecipe as UpstreamCryptographyRecipe,
6+
)
7+
8+
9+
class CryptographyRecipe(UpstreamCryptographyRecipe):
10+
def get_recipe_env(self, arch, **kwargs):
11+
env = super().get_recipe_env(arch, **kwargs)
12+
13+
python_link_version = self.ctx.python_recipe.link_version
14+
link_arg = f"-Clink-arg=-lpython{python_link_version}"
15+
16+
rustflags = env.get("RUSTFLAGS", "").split()
17+
18+
if link_arg not in rustflags:
19+
rustflags.append(link_arg)
20+
21+
env["RUSTFLAGS"] = " ".join(rustflags)
22+
23+
return env
24+
25+
26+
recipe = CryptographyRecipe()

0 commit comments

Comments
 (0)