Я использую имя пакета «iop-python» для своего приложения kivy. Его нет в pythonforandroid для компиляции, поэтому я написал для него рецепт. Но у меня возникли проблемы с написанием рецепта.
Ссылка на репозиторий git пакета iop-python:
https://github.com/BukiOffor/ Hydra-python-api/tree/main
Мне нужно скомпилировать этот пакет с помощью pythonforandroid
Мне нужно скомпилировать этот iop-python с помощью Pythonдля Android, так что будет запустить на Android
Код рецепта
import os
from pythonforandroid.recipe import PythonRecipe
from pythonforandroid.toolchain import shprint
import sh
from os.path import join
class HydraPythonApiRecipe(PythonRecipe):
version = 'main'
url = 'https://github.com/BukiOffor/hydra-pyth ... ain.tar.gz'
# Define dependencies for building the Python package
depends = ['python3', 'setuptools', 'wheel', 'rust']
# Define Python-specific dependencies
python_depends = ['maturin', 'tomli']
def build_arch(self, arch):
super().build_arch(arch)
# Ensure setuptools is installed
shprint(sh.pip3, 'install', 'setuptools')
# Set up Rust toolchain for the specific target architecture
rust_target = 'armv7-linux-androideabi' if 'armeabi' in arch.arch else arch.arch
shprint(sh.rustup, 'target', 'add', rust_target)
# Define the build directory based on architecture
build_dir = self.get_build_dir(arch.arch)
# Run maturin to build the Python wheel using Rust
# Ensure you're using the correct target for cross-compilation
env = self.get_recipe_env(arch) # Get the appropriate environment
shprint(sh.maturin, 'build', '--release', '--target', rust_target, '--out-dir', build_dir, _env=env)
# Install the resulting wheel
wheel_path = join(build_dir, f'hydra_python_api-{self.version}-py3-none-any.whl') # Update to match your wheel name pattern
shprint(sh.pip3, 'install', wheel_path)
def get_recipe_env(self, arch):
"""
Set up the build environment for the architecture, including Rust flags.
"""
env = super().get_recipe_env(arch)
# Set Rust-related environment variables for cross-compilation
rust_target = 'armv7-linux-androideabi' if 'armeabi' in arch.arch else arch.arch
env['CARGO_BUILD_TARGET'] = rust_target
env['RUSTFLAGS'] = '--sysroot={}'.format(self.ctx.ndk_sysroot(arch))
return env
def install_dependencies(self):
"""
Ensure all Python dependencies are installed from requirements.txt.
This should be called before building.
"""
shprint(sh.pip3, 'install', '-r', 'requirements.txt')
# Register the recipe
recipe = HydraPythonApiRecipe()
Подробнее здесь: https://stackoverflow.com/questions/792 ... on-android
Как я могу использовать пакет oop-python на Android? ⇐ Python
Программы на Python
-
Anonymous
1732980734
Anonymous
Я использую имя пакета «iop-python» для своего приложения kivy. Его нет в pythonforandroid для компиляции, поэтому я написал для него рецепт. Но у меня возникли проблемы с написанием рецепта.
Ссылка на репозиторий git пакета iop-python:
https://github.com/BukiOffor/ Hydra-python-api/tree/main
Мне нужно скомпилировать этот пакет с помощью pythonforandroid
Мне нужно скомпилировать этот iop-python с помощью Pythonдля Android, так что будет запустить на Android
Код рецепта
import os
from pythonforandroid.recipe import PythonRecipe
from pythonforandroid.toolchain import shprint
import sh
from os.path import join
class HydraPythonApiRecipe(PythonRecipe):
version = 'main'
url = 'https://github.com/BukiOffor/hydra-python-api/archive/main.tar.gz'
# Define dependencies for building the Python package
depends = ['python3', 'setuptools', 'wheel', 'rust']
# Define Python-specific dependencies
python_depends = ['maturin', 'tomli']
def build_arch(self, arch):
super().build_arch(arch)
# Ensure setuptools is installed
shprint(sh.pip3, 'install', 'setuptools')
# Set up Rust toolchain for the specific target architecture
rust_target = 'armv7-linux-androideabi' if 'armeabi' in arch.arch else arch.arch
shprint(sh.rustup, 'target', 'add', rust_target)
# Define the build directory based on architecture
build_dir = self.get_build_dir(arch.arch)
# Run maturin to build the Python wheel using Rust
# Ensure you're using the correct target for cross-compilation
env = self.get_recipe_env(arch) # Get the appropriate environment
shprint(sh.maturin, 'build', '--release', '--target', rust_target, '--out-dir', build_dir, _env=env)
# Install the resulting wheel
wheel_path = join(build_dir, f'hydra_python_api-{self.version}-py3-none-any.whl') # Update to match your wheel name pattern
shprint(sh.pip3, 'install', wheel_path)
def get_recipe_env(self, arch):
"""
Set up the build environment for the architecture, including Rust flags.
"""
env = super().get_recipe_env(arch)
# Set Rust-related environment variables for cross-compilation
rust_target = 'armv7-linux-androideabi' if 'armeabi' in arch.arch else arch.arch
env['CARGO_BUILD_TARGET'] = rust_target
env['RUSTFLAGS'] = '--sysroot={}'.format(self.ctx.ndk_sysroot(arch))
return env
def install_dependencies(self):
"""
Ensure all Python dependencies are installed from requirements.txt.
This should be called before building.
"""
shprint(sh.pip3, 'install', '-r', 'requirements.txt')
# Register the recipe
recipe = HydraPythonApiRecipe()
Подробнее здесь: [url]https://stackoverflow.com/questions/79239880/how-i-can-use-iop-pyhton-package-on-android[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия