Repository: kivy/python-for-android

Issue:
Add recipe `pyreqwest_impersonate`
### Versions

- Python: 3.10
- OS: Linux mint
- Kivy: 2.2.1
- Cython: 0.29.33
- OpenJDK: 17

### Description

I made the recipe according to the example:
```
from pythonforandroid.recipe import RustCompiledComponentsRecipe


class Pyreqwest_impersonateRecipe(RustCompiledComponentsRecipe):
    version = "v0.4.1"
    url = "https://github.com/deedy5/pyreqwest_impersonate/archive/refs/tags/{version}.tar.gz"
    use_maturin = True
    hostpython_prerequisites = ["typing_extensions"]
    site_packages_name = "pyreqwest_impersonate"


recipe = Pyreqwest_impersonateRecipe()
```

### buildozer.spec

```
# (str) The directory in which python-for-android should look for your own build recipes (if any)
p4a.local_recipes = /home/odinson/PycharmProjects/OSINT/src/python-for-android/recipes/
```

### Logs

```
File "/home/odinson/PycharmProjects/OSINT/src/python-for-android/recipes/pyreqwest_impersonate/__init__.py", line 1, in <module>
    from pythonforandroid.recipe import RustCompiledComponentsRecipe
ImportError: cannot import name 'RustCompiledComponentsRecipe' from 'pythonforandroid.recipe' (/home/odinson/PycharmProjects/OSINT/.buildozer/android/platform/python-for-android/pythonforandroid/recipe.py)

```

`buildozer clean`  I did too. I did everything as required according to the documentation.


Discussion:
@krolaper I appreciate your efforts. You need to set `p4a.branch` to develop.
@T-Dynamos I just need to uncomment the line `#p4a.branch = master` in `buildozer.spec` ?
```
# (str) python-for-android branch to use, defaults to master
#p4a.branch = master
```
@krolaper Yes

```
p4a.branch = develop
```
@T-Dynamos Thank you for efficiency. I appreciate it. So far I see the process going on. In a few minutes I’ll run a test on my smartphone, and if anything happens, I’ll write about it.
@T-Dynamos During packing:
```
[INFO]:    Building pyreqwest_impersonate for arm64-v8a
[INFO]:    pyreqwest_impersonate apparently isn't already in site-packages
[ERROR]:   `rustup` was not found on host system.Please install it using :
`curl https://sh.rustup.rs -sSf | sh`
```
Should I install this on my system, either on a virtual one, or on an android?
@krolaper On which you are building. In your case`Linux mint`.
@T-Dynamos Is there any additional configuration required for rust? (that's what he suggested):
```
To configure your current shell, you need to source
the corresponding env file under $HOME/.cargo.

This is usually done by running one of the following (note the leading DOT):
. "$HOME/.cargo/env"            # For sh/bash/zsh/ash/dash/pdksh
source "$HOME/.cargo/env.fish"  # For fish
```

Since he still writes:
```
[ERROR]: `rustup` was not found on host system.Please install it using :
`curl https://sh.rustup.rs -sSf | sh`
```

I'm sorry, I just want to do everything right.
If you need anything else, please tell me.
@krolaper What is your current shell? Check it using `ps` command. If it is bash you need to add a line in `~/.bashrc` file:
`. "$HOME/.cargo/env"` <-- This line

```
This is usually done by running one of the following (note the leading DOT):
. "$HOME/.cargo/env"            # For sh/bash/zsh/ash/dash/pdksh
source "$HOME/.cargo/env.fish"  # For fish
```
@T-Dynamos ```odinson@PodinsonC:~$ ps
    PID TTY          TIME CMD
  62606 pts/1    00:00:00 bash
  63470 pts/1    00:00:00 ps```
i don't undestand )
i write - `. "$HOME/.cargo/env"`
same error, now I'll reboot the PC and try again
@krolaper Yes it is bash.

Just run this command to auto add that line:


```shell
echo '. "$HOME/.cargo/env"' >> ~/.bashrc  
```

And restart your terminal.

@T-Dynamos Help. I accidentally wrote this into the virtual environment I'm trying to package in. What needs to be written down to fix it back, otherwise he no longer knows the buildozer command
@krolaper Sorry I have no knowledge about venv.
@T-Dynamos I corrected my mistake, just went bash and deleted the unnecessary
@T-Dynamos log buildozer:
```
   Compiling foreign-types v0.5.0      ] 101/201: boring-sys-imp(build.rs),...
error: failed to run custom build command for `boring-sys-imp v2.1.0`d), un...

Caused by:
  process didn't exit successfully: `/home/odinson/PycharmProjects/OSINT/.buildozer/android/platform/build-arm64-v8a/build/other_builds/pyreqwest_impersonate/arm64-v8a__ndk_target_21/pyreqwest_impersonate/target/debug/build/boring-sys-imp-395ee56c15761dd7/build-script-build` (exit status: 101)
  --- stdout
  cargo:rerun-if-env-changed=BORING_BSSL_PATH
  cargo:rerun-if-env-changed=ANDROID_NDK_HOME

  --- stderr
  thread 'main' panicked at /home/odinson/.cargo/registry/src/index.crates.io-6f17d22bba15001f/boring-sys-imp-2.1.0/build.rs:158:18:
  Please set ANDROID_NDK_HOME for Android build: NotPresent
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
💥 maturin failed=========>            ] 110/201: brotli                      
  Caused by: Failed to build a native library through cargo
  Caused by: Cargo build finished with "exit status: 101": `env -u CARGO PYO3_ENVIRONMENT_SIGNATURE="cpython-3.11-64bit" PYO3_PYTHON="/home/odinson/PycharmProjects/OSINT/.buildozer/android/platform/build-arm64-v8a/build/other_builds/hostpython3/desktop/hostpython3/native-build/python3.11" PYTHON_SYS_EXECUTABLE="/home/odinson/PycharmProjects/OSINT/.buildozer/android/platform/build-arm64-v8a/build/other_builds/hostpython3/desktop/hostpython3/native-build/python3.11" "cargo" "rustc" "--features" "pyo3/extension-module" "--target" "aarch64-linux-android" "--message-format" "json-render-diagnostics" "--manifest-path" "/home/odinson/PycharmProjects/OSINT/.buildozer/android/platform/build-arm64-v8a/build/other_builds/pyreqwest_impersonate/arm64-v8a__ndk_target_21/pyreqwest_impersonate/Cargo.toml" "--lib"`
```

I have Android ndk `/home/odinson/.buildozer/android/platform/android-ndk-r25b/`
How can I indicate the correct path to them, and what needs to be written down next, what does it require?
@krolaper Sorry for late:

Here you go:

```python
from pythonforandroid.recipe import RustCompiledComponentsRecipe


class Pyreqwest_impersonateRecipe(RustCompiledComponentsRecipe):
    # ... other things ....

    def get_recipe_env(self, arch, **kwargs):
        env = super().get_recipe_env(arch, **kwargs)
        env["ANDROID_NDK_HOME"] = self.ctx.ndk_dir
        env["CFLAGS"] += f" -I{self.ctx.ndk.sysroot_include_dir}" 
        env["CXXFLAGS"] += f" -I{self.ctx.ndk.sysroot_include_dir}" 
        return env

recipe = Pyreqwest_impersonateRecipe()
```
@T-Dynamos log buildozer
```
[100%] Built target crypto
  cargo:root=/home/odinson/PycharmProjects/OSINT/.buildozer/android/platform/build-arm64-v8a/build/other_builds/pyreqwest_impersonate/arm64-v8a__ndk_target_21/pyreqwest_impersonate/target/aarch64-linux-android/debug/build/boring-sys-imp-169f8b4fd7943b34/out
  cargo:rustc-link-search=native=/home/odinson/PycharmProjects/OSINT/.buildozer/android/platform/build-arm64-v8a/build/other_builds/pyreqwest_impersonate/arm64-v8a__ndk_target_21/pyreqwest_impersonate/target/aarch64-linux-android/debug/build/boring-sys-imp-169f8b4fd7943b34/out/build/
  cargo:rustc-link-lib=static=crypto
  cargo:rustc-link-lib=static=ssl
  cargo:rerun-if-env-changed=BORING_BSSL_INCLUDE_PATH

  --- stderr
  android arch=aarch64 add ANDROID_ABI=arm64-v8a
  android toolchain=/home/odinson/.buildozer/android/platform/android-ndk-r25b/build/cmake/android.toolchain.cmake
  make[1]: warning: -j4 forced in submake: resetting jobserver mode.
  make[2]: warning: -j4 forced in submake: resetting jobserver mode.
  make[3]: warning: -j4 forced in submake: resetting jobserver mode.
  make[3]: warning: -j4 forced in submake: resetting jobserver mode.
  make[3]: warning: -j4 forced in submake: resetting jobserver mode.
  make[3]: warning: -j4 forced in submake: resetting jobserver mode.
  make[1]: warning: -j4 forced in submake: resetting jobserver mode.
  make[2]: warning: -j4 forced in submake: resetting jobserver mode.
  make[3]: warning: -j4 forced in submake: resetting jobserver mode.
  make[3]: warning: -j4 forced in submake: resetting jobserver mode.
  deps/boringssl/src/include/openssl/base.h:61:10: fatal error: 'sys/types.h' file not found
  thread 'main' panicked at /home/odinson/.cargo/registry/src/index.crates.io-6f17d22bba15001f/boring-sys-imp-2.1.0/build.rs:558:39:
  Unable to generate bindings: ClangDiagnostic("deps/boringssl/src/include/openssl/base.h:61:10: fatal error: 'sys/types.h' file not found\n")
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
💥 maturin failed
  Caused by: Failed to build a native library through cargo
  Caused by: Cargo build finished with "exit status: 101": `env -u CARGO PYO3_ENVIRONMENT_SIGNATURE="cpython-3.11-64bit" PYO3_PYTHON="/home/odinson/PycharmProjects/OSINT/.buildozer/android/platform/build-arm64-v8a/build/other_builds/hostpython3/desktop/hostpython3/native-build/python3.11" PYTHON_SYS_EXECUTABLE="/home/odinson/PycharmProjects/OSINT/.buildozer/android/platform/build-arm64-v8a/build/other_builds/hostpython3/desktop/hostpython3/native-build/python3.11" "cargo" "rustc" "--features" "pyo3/extension-module" "--target" "aarch64-linux-android" "--message-format" "json-render-diagnostics" "--manifest-path" "/home/odinson/PycharmProjects/OSINT/.buildozer/android/platform/build-arm64-v8a/build/other_builds/pyreqwest_impersonate/arm64-v8a__ndk_target_21/pyreqwest_impersonate/Cargo.toml" "--lib"`
```

@krolaper Had some progress:

Before running buildozer do:
`rustup default nightly` then:

```python
from pythonforandroid.recipe import RustCompiledComponentsRecipe


class Pyreqwest_impersonateRecipe(RustCompiledComponentsRecipe):
    version = "v0.4.1"
    url = "https://github.com/deedy5/pyreqwest_impersonate/archive/refs/tags/{version}.tar.gz"
    site_packages_name = "pyreqwest_impersonate"

    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):
        self.get_recipe_env = self.get_recipe_env_pre
        prebuild_ = super().build_arch
        try:
            prebuild_(arch)
        except Exception:
            self.get_recipe_env = self.get_recipe_env_post
            prebuild_(arch)


recipe = Pyreqwest_impersonateRecipe()
```
@deedy5 Maybe you can help here:

```
Compiling encoding_rs v0.8.34====>  ] 189/201: mime_guess, pyo3            
error[E0432]: unresolved import `simd_funcs`/201: encoding_rs, pyo3           
  --> /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/x_user_defined.rs:16:13
   |
16 |         use simd_funcs::*;
   |             ^^^^^^^^^^ use of undeclared crate or module `simd_funcs`

error[E0412]: cannot find type `u16x8` in this scope
   --> /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/handles.rs:129:40
    |
129 |     pub fn simd_at(&self, i: usize) -> u16x8 {
    |                                        ^^^^^ not found in this scope
    |
help: consider importing this type alias
    |
39  + use core::simd::u16x8;
    |

error[E0425]: cannot find value `SIMD_STRIDE_SIZE` in this scope
    --> /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/handles.rs:131:21
     |
131  |         assert!(i + SIMD_STRIDE_SIZE / 2 <= self.len);
     |                     ^^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `ALU_STRIDE_SIZE`
     |
    ::: /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/ascii.rs:1323:9
     |
1323 |         pub const ALU_STRIDE_SIZE: usize = 8;
     |         ------------------------------------- similarly named constant `ALU_STRIDE_SIZE` defined here

error[E0425]: cannot find value `SIMD_STRIDE_SIZE` in this scope
    --> /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/handles.rs:161:12
     |
161  |         if SIMD_STRIDE_SIZE / 2 <= self.len {
     |            ^^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `ALU_STRIDE_SIZE`
     |
    ::: /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/ascii.rs:1323:9
     |
1323 |         pub const ALU_STRIDE_SIZE: usize = 8;
     |         ------------------------------------- similarly named constant `ALU_STRIDE_SIZE` defined here

error[E0425]: cannot find value `SIMD_STRIDE_SIZE` in this scope
    --> /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/handles.rs:162:47
     |
162  |             let len_minus_stride = self.len - SIMD_STRIDE_SIZE / 2;
     |                                               ^^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `ALU_STRIDE_SIZE`
     |
    ::: /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/ascii.rs:1323:9
     |
1323 |         pub const ALU_STRIDE_SIZE: usize = 8;
     |         ------------------------------------- similarly named constant `ALU_STRIDE_SIZE` defined here

error[E0425]: cannot find value `SIMD_STRIDE_SIZE` in this scope
    --> /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/handles.rs:175:27
     |
175  |                 offset += SIMD_STRIDE_SIZE / 2;
     |                           ^^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `ALU_STRIDE_SIZE`
     |
    ::: /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/ascii.rs:1323:9
     |
1323 |         pub const ALU_STRIDE_SIZE: usize = 8;
     |         ------------------------------------- similarly named constant `ALU_STRIDE_SIZE` defined here

error[E0425]: cannot find value `SIMD_STRIDE_SIZE` in this scope
    --> /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/handles.rs:256:8
     |
256  |     if SIMD_STRIDE_SIZE <= len {
     |        ^^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `ALU_STRIDE_SIZE`
     |
    ::: /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/ascii.rs:1323:9
     |
1323 |         pub const ALU_STRIDE_SIZE: usize = 8;
     |         ------------------------------------- similarly named constant `ALU_STRIDE_SIZE` defined here

error[E0425]: cannot find value `SIMD_STRIDE_SIZE` in this scope
    --> /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/handles.rs:257:38
     |
257  |         let len_minus_stride = len - SIMD_STRIDE_SIZE;
     |                                      ^^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `ALU_STRIDE_SIZE`
     |
    ::: /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/ascii.rs:1323:9
     |
1323 |         pub const ALU_STRIDE_SIZE: usize = 8;
     |         ------------------------------------- similarly named constant `ALU_STRIDE_SIZE` defined here

error[E0425]: cannot find value `SIMD_STRIDE_SIZE` in this scope
    --> /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/handles.rs:260:52
     |
260  | ...rc.simd_at(offset + (SIMD_STRIDE_SIZE / 2));
     |                         ^^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `ALU_STRIDE_SIZE`
     |
    ::: /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/ascii.rs:1323:9
     |
1323 |         pub const ALU_STRIDE_SIZE: usize = 8;
     |         ------------------------------------- similarly named constant `ALU_STRIDE_SIZE` defined here

error[E0425]: cannot find value `SIMD_STRIDE_SIZE` in this scope
    --> /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/handles.rs:273:23
     |
273  |             offset += SIMD_STRIDE_SIZE;
     |                       ^^^^^^^^^^^^^^^^ help: a constant with a similar name exists: `ALU_STRIDE_SIZE`
     |
    ::: /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/ascii.rs:1323:9
     |
1323 |         pub const ALU_STRIDE_SIZE: usize = 8;
     |         ------------------------------------- similarly named constant `ALU_STRIDE_SIZE` defined here

error[E0425]: cannot find function `load16_unaligned` in this scope
   --> /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/x_user_defined.rs:125:34
    |
125 |             let input = unsafe { load16_unaligned(src_ptr.add(i * 16)) };
    |                                  ^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `simd_unpack` in this scope
   --> /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/x_user_defined.rs:126:35
    |
126 |             let (first, second) = simd_unpack(input);
    |                                   ^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `store8_unaligned` in this scope
   --> /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/x_user_defined.rs:129:17
    |
129 |                 store8_unaligned(dst_ptr.add(i * 16), shift_upper(first));
    |                 ^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `store8_unaligned` in this scope
   --> /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/x_user_defined.rs:130:17
    |
130 | ...   store8_unaligned(dst_ptr.add((i * 16) + 8), shift_upper(second));
    |       ^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `load16_unaligned` in this scope
   --> /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/handles.rs:137:31
    |
137 | ...   unsafe { to_u16_lanes(load16_unaligned(self.ptr.add(byte_index))) }
    |                             ^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `to_u16_lanes` in this scope
   --> /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/handles.rs:137:18
    |
137 | ...   unsafe { to_u16_lanes(load16_unaligned(self.ptr.add(byte_index))) }
    |                ^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `simd_byte_swap` in this scope
   --> /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/handles.rs:166:28
    |
166 |                     simd = simd_byte_swap(simd);
    |                            ^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `store8_unaligned` in this scope
   --> /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/handles.rs:170:21
    |
170 | ...   store8_unaligned(other.as_mut_ptr().add(offset), simd);
    |       ^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `contains_surrogates` in this scope
   --> /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/handles.rs:172:20
    |
172 |                 if contains_surrogates(simd) {
    |                    ^^^^^^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `simd_byte_swap` in this scope
   --> /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/handles.rs:262:25
    |
262 |                 first = simd_byte_swap(first);
    |                         ^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `simd_byte_swap` in this scope
   --> /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/handles.rs:263:26
    |
263 |                 second = simd_byte_swap(second);
    |                          ^^^^^^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `simd_is_basic_latin` in this scope
   --> /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/handles.rs:265:17
    |
265 |               if !simd_is_basic_latin(first | second) {
    |                   ^^^^^^^^^^^^^^^^^^^ help: a function with a similar name exists: `ascii_to_basic_latin`
    |
   ::: /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/ascii.rs:231:9
    |
231 | /         pub unsafe fn $name(
232 | |             src: *const $src_unit,
233 | |             dst: *mut $dst_unit,
234 | |             len: usize,
...   |
336 | |             None
337 | |         }
    | |_________- similarly named function `ascii_to_basic_latin` defined here

error[E0425]: cannot find function `simd_pack` in this scope
   --> /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/handles.rs:268:26
    |
268 |             let packed = simd_pack(first, second);
    |                          ^^^^^^^^^ not found in this scope

error[E0425]: cannot find function `store16_unaligned` in this scope
   --> /home/tdynamos/.cargo/registry/src/index.crates.io-6f17d22bba15001f/encoding_rs-0.8.34/src/handles.rs:271:17
    |
271 |                 store16_unaligned(dst.as_mut_ptr().add(offset), packed);
    |                 ^^^^^^^^^^^^^^^^^ not found in this scope

Some errors have detailed explanations: E0412, E0425, E0432.
For more information about an error, try `rustc --explain E0412`.
error: could not compile `encoding_rs` (lib) due to 24 previous errors
warning: build failed, waiting for other jobs to finish...
💥 maturin failed===================>  ] 191/201: pyo3                        
  Caused by: Failed to build a native library through cargo
  Caused by: Cargo build finished with "exit status: 101": `env -u CARGO PYO3_ENVIRONMENT_SIGNATURE="cpython-3.11-64bit" PYO3_PYTHON="/tmp/build-env-c_wq7jrr/bin/python" PYTHON_SYS_EXECUTABLE="/tmp/build-env-c_wq7jrr/bin/python" "cargo" "rustc" "--features" "pyo3/extension-module" "--target" "armv7-linux-androideabi" "--message-format" "json-render-diagnostics" "--manifest-path" "/home/tdynamos/Expreiments/PythonTest/.buildozer/android/platform/build-armeabi-v7a/build/other_builds/pyreqwest_impersonate/armeabi-v7a__ndk_target_23/pyreqwest_impersonate/Cargo.toml" "--release" "--lib"`
Error: command ['maturin', 'pep517', 'build-wheel', '-i', '/tmp/build-env-c_wq7jrr/bin/python', '--compatibility', 'off'] returned non-zero exit status 1

ERROR Backend subprocess exited when trying to invoke build_wheel
``` 
@T-Dynamos 
Try it with version v0.4.0 for now.
@T-Dynamos I completed it https://github.com/kivy/python-for-android/issues/3012#issuecomment-2094691104 
Compilation with rust was successful. I'm waiting for the full compilation to complete. And this is with version 0.4.1
I was happy early. Log:
```
NFO: ccache: numpy/core/src/common/numpyos.c
INFO: ccache: build/src.aarch64-linux-android-3.11/numpy/core/src/common/npy_cpu_features.c
INFO: compiling C++ sources
INFO: C compiler: /usr/bin/ccache /home/odinson/.buildozer/android/platform/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -target aarch64-linux-android21 -fomit-frame-pointer -march=armv8-a -fPIC -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -target aarch64-linux-android21 -fomit-frame-pointer -march=armv8-a -fPIC -I/home/odinson/PycharmProjects/OSINT/.buildozer/android/platform/build-arm64-v8a/build/other_builds/python3-libbz2/arm64-v8a__ndk_target_21/python3/Include -DANDROID -I/home/odinson/.buildozer/android/platform/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include -I/home/odinson/PycharmProjects/OSINT/.buildozer/android/platform/build-arm64-v8a/build/python-installs/AIGodOSINT/arm64-v8a/include/python3.1 -fPIC

creating build/temp.aarch64-linux-android-3.11/numpy/core/src/npysort
INFO: compile options: '-DNPY_INTERNAL_BUILD=1 -DHAVE_NPY_CONFIG_H=1 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1 -D_LARGEFILE64_SOURCE=1 -Ibuild/src.aarch64-linux-android-3.11/numpy/core/src/common -Ibuild/src.aarch64-linux-android-3.11/numpy/core/src/umath -Inumpy/core/include -Ibuild/src.aarch64-linux-android-3.11/numpy/core/include/numpy -Ibuild/src.aarch64-linux-android-3.11/numpy/distutils/include -Inumpy/core/src/common -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/src/_simd -I/home/odinson/PycharmProjects/OSINT/.buildozer/android/platform/build-arm64-v8a/build/other_builds/hostpython3/desktop/hostpython3/Include -I/home/odinson/PycharmProjects/OSINT/.buildozer/android/platform/build-arm64-v8a/build/other_builds/hostpython3/desktop/hostpython3/native-build -Ibuild/src.aarch64-linux-android-3.11/numpy/core/src/common -Ibuild/src.aarch64-linux-android-3.11/numpy/core/src/npymath -c'
extra options: '-std=c++11 -D__STDC_VERSION__=0 -fno-exceptions -fno-rtti'
INFO: ccache: numpy/core/src/npysort/radixsort.cpp
INFO: ccache: numpy/core/src/umath/clip.cpp
 #0 0x0000000002a047d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/odinson/.buildozer/android/platform/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/bin/ld+0x2a047d8)
 #1 0x0000000002a03940 llvm::sys::RunSignalHandlers() (/home/odinson/.buildozer/android/platform/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/bin/ld+0x2a03940)
 #2 0x0000000002a04c2a (/home/odinson/.buildozer/android/platform/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/bin/ld+0x2a04c2a)
 #3 0x00007f608cc97520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00007f608cdf57cd ./string/../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:317:0
 #5 0x00000000021e051b void lld::elf::InputSection::writeTo<llvm::object::ELFType<(llvm::support::endianness)1, true> >(unsigned char*) (/home/odinson/.buildozer/android/platform/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/bin/ld+0x21e051b)
 #6 0x00000000021e03a3 (/home/odinson/.buildozer/android/platform/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/bin/ld+0x21e03a3)
 #7 0x0000000002a1c4e2 (/home/odinson/.buildozer/android/platform/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/bin/ld+0x2a1c4e2)
 #8 0x0000000002a1c3ba (/home/odinson/.buildozer/android/platform/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/bin/ld+0x2a1c3ba)
 #9 0x00000000026d3ab4 (/home/odinson/.buildozer/android/platform/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/bin/ld+0x26d3ab4)
#10 0x00000000026d38f6 (/home/odinson/.buildozer/android/platform/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/bin/ld+0x26d38f6)
#11 0x00007f608cce9ac3 start_thread ./nptl/./nptl/pthread_create.c:442:8
#12 0x00007f608cd7b850 ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:83:0
ld: error: failed to write to the output file: No such file or directory
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
INFO: /usr/bin/ccache /home/odinson/.buildozer/android/platform/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -target aarch64-linux-android21 -fomit-frame-pointer -march=armv8-a -fPIC -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -L/home/odinson/PycharmProjects/OSINT/.buildozer/android/platform/build-arm64-v8a/build/other_builds/librt/arm64-v8a__ndk_target_21/librt/p4a-librt-recipe-tempdir -L/home/odinson/PycharmProjects/OSINT/.buildozer/android/platform/build-arm64-v8a/build/libs_collections/AIGodOSINT/arm64-v8a -L/home/odinson/PycharmProjects/OSINT/.buildozer/android/platform/build-arm64-v8a/build/other_builds/python3-libbz2/arm64-v8a__ndk_target_21/python3/android-build -lpython3.11 -target aarch64-linux-android21 -fomit-frame-pointer -march=armv8-a -fPIC -I/home/odinson/PycharmProjects/OSINT/.buildozer/android/platform/build-arm64-v8a/build/other_builds/python3-libbz2/arm64-v8a__ndk_target_21/python3/Include -DANDROID -I/home/odinson/.buildozer/android/platform/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include -I/home/odinson/PycharmProjects/OSINT/.buildozer/android/platform/build-arm64-v8a/build/python-installs/AIGodOSINT/arm64-v8a/include/python3.1 build/temp.aarch64-linux-android-3.11/build/src.aarch64-linux-android-3.11/numpy/core/src/umath/loops_unary_fp.dispatch.o build/temp.aarch64-linux-android-3.11/build/src.aarch64-linux-android-3.11/numpy/core/src/umath/loops_arithm_fp.dispatch.o build/temp.aarch64-linux-android-3.11/build/src.aarch64-linux-android-3.11/numpy/core/src/umath/loops_arithmetic.dispatch.o build/temp.aarch64-linux-android-3.11/build/src.aarch64-linux-android-3.11/numpy/core/src/umath/loops_trigonometric.dispatch.o build/temp.aarch64-linux-android-3.11/build/src.aarch64-linux-android-3.11/numpy/core/src/umath/loops_umath_fp.dispatch.o build/temp.aarch64-linux-android-3.11/build/src.aarch64-linux-android-3.11/numpy/core/src/umath/loops_exponent_log.dispatch.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/abstractdtypes.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/alloc.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/arrayobject.o build/temp.aarch64-linux-android-3.11/build/src.aarch64-linux-android-3.11/numpy/core/src/multiarray/arraytypes.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/array_coercion.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/array_method.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/array_assign_scalar.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/array_assign_array.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/arrayfunction_override.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/buffer.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/calculation.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/compiled_base.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/common.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/common_dtype.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/convert.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/convert_datatype.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/conversion_utils.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/ctors.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/datetime.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/datetime_strings.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/datetime_busday.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/datetime_busdaycal.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/descriptor.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/dlpack.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/dtypemeta.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/dragon4.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/dtype_transfer.o build/temp.aarch64-linux-android-3.11/build/src.aarch64-linux-android-3.11/numpy/core/src/multiarray/einsum.o build/temp.aarch64-linux-android-3.11/build/src.aarch64-linux-android-3.11/numpy/core/src/multiarray/einsum_sumprod.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/experimental_public_dtype_api.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/flagsobject.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/getset.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/hashdescr.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/item_selection.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/iterators.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/legacy_dtype_implementation.o build/temp.aarch64-linux-android-3.11/build/src.aarch64-linux-android-3.11/numpy/core/src/multiarray/lowlevel_strided_loops.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/mapping.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/methods.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/multiarraymodule.o build/temp.aarch64-linux-android-3.11/build/src.aarch64-linux-android-3.11/numpy/core/src/multiarray/nditer_templ.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/nditer_api.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/nditer_constr.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/nditer_pywrap.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/number.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/refcount.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/sequence.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/shape.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/scalarapi.o build/temp.aarch64-linux-android-3.11/build/src.aarch64-linux-android-3.11/numpy/core/src/multiarray/scalartypes.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/strfuncs.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/temp_elide.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/typeinfo.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/usertypes.o build/temp.aarch64-linux-android-3.11/numpy/core/src/multiarray/vdot.o build/temp.aarch64-linux-android-3.11/build/src.aarch64-linux-android-3.11/numpy/core/src/npysort/quicksort.o build/temp.aarch64-linux-android-3.11/build/src.aarch64-linux-android-3.11/numpy/core/src/npysort/mergesort.o build/temp.aarch64-linux-android-3.11/build/src.aarch64-linux-android-3.11/numpy/core/src/npysort/timsort.o build/temp.aarch64-linux-android-3.11/build/src.aarch64-linux-android-3.11/numpy/core/src/npysort/heapsort.o build/temp.aarch64-linux-android-3.11/build/src.aarch64-linux-android-3.11/numpy/core/src/npysort/selection.o build/temp.aarch64-linux-android-3.11/build/src.aarch64-linux-android-3.11/numpy/core/src/npysort/binsearch.o build/temp.aarch64-linux-android-3.11/numpy/core/src/umath/umathmodule.o build/temp.aarch64-linux-android-3.11/numpy/core/src/umath/reduction.o build/temp.aarch64-linux-android-3.11/build/src.aarch64-linux-android-3.11/numpy/core/src/umath/loops.o build/temp.aarch64-linux-android-3.11/build/src.aarch64-linux-android-3.11/numpy/core/src/umath/matmul.o build/temp.aarch64-linux-android-3.11/numpy/core/src/umath/dispatching.o build/temp.aarch64-linux-android-3.11/numpy/core/src/umath/legacy_array_method.o build/temp.aarch64-linux-android-3.11/numpy/core/src/umath/ufunc_object.o build/temp.aarch64-linux-android-3.11/numpy/core/src/umath/extobj.o build/temp.aarch64-linux-android-3.11/build/src.aarch64-linux-android-3.11/numpy/core/src/umath/scalarmath.o build/temp.aarch64-linux-android-3.11/numpy/core/src/umath/ufunc_type_resolution.o build/temp.aarch64-linux-android-3.11/numpy/core/src/umath/override.o build/temp.aarch64-linux-android-3.11/numpy/core/src/umath/_scaled_float_dtype.o build/temp.aarch64-linux-android-3.11/numpy/core/src/common/array_assign.o build/temp.aarch64-linux-android-3.11/numpy/core/src/common/mem_overlap.o build/temp.aarch64-linux-android-3.11/numpy/core/src/common/npy_argparse.o build/temp.aarch64-linux-android-3.11/numpy/core/src/common/npy_hashtable.o build/temp.aarch64-linux-android-3.11/numpy/core/src/common/npy_longdouble.o build/temp.aarch64-linux-android-3.11/numpy/core/src/common/ucsnarrow.o build/temp.aarch64-linux-android-3.11/numpy/core/src/common/ufunc_override.o build/temp.aarch64-linux-android-3.11/numpy/core/src/common/numpyos.o build/temp.aarch64-linux-android-3.11/build/src.aarch64-linux-android-3.11/numpy/core/src/common/npy_cpu_features.o build/temp.aarch64-linux-android-3.11/numpy/core/src/npysort/radixsort.o build/temp.aarch64-linux-android-3.11/numpy/core/src/umath/clip.o -Lbuild/temp.aarch64-linux-android-3.11 -lnpymath -lm -o build/lib.aarch64-linux-android-3.11/numpy/core/_multiarray_umath.cpython-311-x86_64-linux-gnu.so
error: Command "/usr/bin/ccache /home/odinson/.buildozer/android/platform/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -target aarch64-linux-android21 -fomit-frame-pointer -march=armv8-a -fPIC -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -L/home/odinson/PycharmProjects/OSINT/.buildozer/android/platform/build-arm64-v8a/build/other_builds/librt/arm64-v8a__ndk_target_21/librt/p4a-librt-recipe-tempdir -L/home/odinson/PycharmProjects/OSINT/.buildozer/android/platform/build-arm64-v8a/build/libs_collections/AIGodOSINT/arm64-v8a -L/home/odinson/PycharmProjects/OSINT/.buildozer/android/platform/build-arm64-v8a/build/other_builds/python3-libbz2/arm64-v8a__ndk_target_21/python3/android-build -lpython3.11 -target aarch64-linux-android21 -fomit-frame-pointer -march=armv8-a -fPIC -I/home/odinson/PycharmProjects/OSINT/.buildozer/android/platform/build-arm64-v8a/build/other_builds/python3-libbz2/arm64-v8a__ndk_target_21/python3/Include -DANDROID -I/home/odinson/.buildozer/android/platform/android-ndk-r25b/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include -I/home/odinson/PycharmProjects/OSINT/.buildozer/android/platform/build-arm64-v8a/build/python-installs/AIGodOSINT/arm64-v8a/include/python3.1 build/temp.aarch64-linux-android-3.11/numpy/linalg/lapack_litemodule.o build/temp.aarch64-linux-android-3.11/numpy/linalg/lapack_lite/python_xerbla.o build/temp.aarch64-linux-android-3.11/numpy/linalg/lapack_lite/f2c_z_lapack.o build/temp.aarch64-linux-android-3.11/numpy/linalg/lapack_lite/f2c_c_lapack.o build/temp.aarch64-linux-android-3.11/numpy/linalg/lapack_lite/f2c_d_lapack.o build/temp.aarch64-linux-android-3.11/numpy/linalg/lapack_lite/f2c_s_lapack.o build/temp.aarch64-linux-android-3.11/numpy/linalg/lapack_lite/f2c_lapack.o build/temp.aarch64-linux-android-3.11/numpy/linalg/lapack_lite/f2c_blas.o build/temp.aarch64-linux-android-3.11/numpy/linalg/lapack_lite/f2c_config.o build/temp.aarch64-linux-android-3.11/numpy/linalg/lapack_lite/f2c.o -Lbuild/temp.aarch64-linux-android-3.11 -lm -o build/lib.aarch64-linux-android-3.11/numpy/linalg/lapack_lite.cpython-311-x86_64-linux-gnu.so" failed with exit status 1
INFO: 
########### EXT COMPILER OPTIMIZATION ###########
INFO: Platform      : 
  Architecture: aarch64
  Compiler    : unix-like

CPU baseline  : 
  Requested   : 'min'
  Enabled     : NEON NEON_FP16 NEON_VFPV4 ASIMD
  Flags       : none
  Extra checks: none

CPU dispatch  : 
  Requested   : 'max -xop -fma4'
  Enabled     : ASIMDHP ASIMDDP
  Generated   : 
              : 
  ASIMDHP     : NEON NEON_FP16 NEON_VFPV4 ASIMD
  Flags       : -march=armv8.2-a+fp16
  Extra checks: none
  Detect      : ASIMD ASIMDHP
              : numpy/core/src/umath/_umath_tests.dispatch.c
INFO: CCompilerOpt.cache_flush[817] : write cache to path -> /home/odinson/PycharmProjects/OSINT/.buildozer/android/platform/build-arm64-v8a/build/other_builds/numpy/arm64-v8a__ndk_target_21/numpy/build/temp.aarch64-linux-android-3.11/ccompiler_opt_cache_ext.py
INFO: 
########### CLIB COMPILER OPTIMIZATION ###########
INFO: Platform      : 
  Architecture: aarch64
  Compiler    : unix-like

CPU baseline  : 
  Requested   : 'min'
  Enabled     : NEON NEON_FP16 NEON_VFPV4 ASIMD
  Flags       : none
  Extra checks: none

CPU dispatch  : 
  Requested   : 'max -xop -fma4'
  Enabled     : ASIMDHP ASIMDDP
  Generated   : none
INFO: CCompilerOpt.cache_flush[817] : write cache to path -> /home/odinson/PycharmProjects/OSINT/.buildozer/android/platform/build-arm64-v8a/build/other_builds/numpy/arm64-v8a__ndk_target_21/numpy/build/temp.aarch64-linux-android-3.11/ccompiler_opt_cache_clib.py
```
Now I'll try with version 0.4.0
With v0.4.0 use `rustup default stable`

@deedy5 Thank you!. I will test this now.
![image](https://github.com/kivy/python-for-android/assets/68729523/57d17f36-2ac3-4d6c-a4ef-8f859683f963)

Final recipe:
```python
from pythonforandroid.recipe import RustCompiledComponentsRecipe


class Pyreqwest_impersonateRecipe(RustCompiledComponentsRecipe):
    version = "v0.4.0"
    url = "https://github.com/deedy5/pyreqwest_impersonate/archive/refs/tags/{version}.tar.gz"
    site_packages_name = "pyreqwest_impersonate"

    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):
        self.get_recipe_env = self.get_recipe_env_pre
        prebuild_ = super().build_arch
        try:
            prebuild_(arch)
        except Exception:
            self.get_recipe_env = self.get_recipe_env_post
            prebuild_(arch)

recipe = Pyreqwest_impersonateRecipe()
```

I will add this to p4a later, and don't ask me why I have to set `ANDROID_NDK_HOME` twice :)
@krolaper Please consider informing, if it worked on smartphone.
@T-Dynamos version 0.4.0:
Packing was successful.
Everything started on the smartphone too.
Thanks a lot.
@T-Dynamos 
Build with `v0.4.2` (faster than 0.4.0)
@deedy5 Builds fine.

Resolving patch:
diff --git a/pythonforandroid/recipes/pyreqwest_impersonate/__init__.py b/pythonforandroid/recipes/pyreqwest_impersonate/__init__.py
new file mode 100644
--- /dev/null
+++ b/pythonforandroid/recipes/pyreqwest_impersonate/__init__.py
@@ -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()


Test patch: