-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3016 from T-Dynamos/pyreqwest_impersonate
recipes: add new `pyreqwest_impersonate` recipe
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
pythonforandroid/recipes/pyreqwest_impersonate/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from pythonforandroid.logger import info | ||
from pythonforandroid.recipe import RustCompiledComponentsRecipe | ||
|
||
|
||
class Pyreqwest_impersonateRecipe(RustCompiledComponentsRecipe): | ||
version = "v0.4.5" | ||
url = "https://github.com/deedy5/pyreqwest_impersonate/archive/refs/tags/{version}.tar.gz" | ||
|
||
def get_recipe_env_post(self, arch, **kwargs): | ||
env = super().get_recipe_env(arch, **kwargs) | ||
env["ANDROID_NDK_HOME"] = self.ctx.ndk.llvm_prebuilt_dir | ||
return env | ||
|
||
def get_recipe_env_pre(self, arch, **kwargs): | ||
env = super().get_recipe_env(arch, **kwargs) | ||
env["ANDROID_NDK_HOME"] = self.ctx.ndk_dir | ||
return env | ||
|
||
def build_arch(self, arch): | ||
# Why need of two env? | ||
# Because there are two dependencies which accepts | ||
# different ANDROID_NDK_HOME | ||
self.get_recipe_env = self.get_recipe_env_pre | ||
prebuild_ = super().build_arch | ||
try: | ||
prebuild_(arch) | ||
except Exception: | ||
info("pyreqwest_impersonate first build failed, as expected") | ||
self.get_recipe_env = self.get_recipe_env_post | ||
prebuild_(arch) | ||
|
||
|
||
recipe = Pyreqwest_impersonateRecipe() |