How to write a python-for-android recipe for a package in a local directory and not a zip file url? - buildozer

I have
buildozer.spec
recipes/
myrecipe/
__init__.py
mypackage/
setup.py
code.py
But when I try to write a recipe with a file:// URL as seen when googling this issue, I get an error Exception: Given path is neither a file nor a directory: /home/user/project/.buildozer/android/platform/build-armeabi-v7a/packages/mypackage/mypackage (not the mypackage twice).
How can I achieve this?

There is an IncludedFilesBehaviour mixin just for this, just give it a relative path with src_filename:
from pythonforandroid.recipe import IncludedFilesBehaviour, CppCompiledComponentsPythonRecipe
import os
import sys
class MyRecipe(IncludedFilesBehaviour, CppCompiledComponentsPythonRecipe):
version = 'stable'
src_filename = "../../../phase-engine"
name = 'phase-engine'
depends = ['setuptools']
call_hostpython_via_targetpython = False
install_in_hostpython = True
def get_recipe_env(self, arch):
env = super().get_recipe_env(arch)
env['LDFLAGS'] += ' -lc++_shared'
return env
recipe = MyRecipe()

Related

I am getting a error of STATICFILE DIR in python

WARNINGS:
?: (staticfiles.W004) The directory 'E:\Python Practice\Django\userproject\static' in the STATICFILES_DIRS setting does not exist.
System check identified 1 issue (0 silenced).
You need to write in settings.py file :
STATIC_URL = 'static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")]
You need to write static files directory to serve the static content in settings.py file as :
STATICFILES_DIRS = [os.path.join(BASE_DIR, "static")]
Hope it will work for you.

Cant add plugin in poetry

I have initialized poetry in my project. Add some libs and got this pyproject.toml:
[tool.poetry]
name = "dataapi"
version = "0.1.0"
description = "API for service."
authors = ["Claus Stolz"]
[tool.poetry.dependencies]
python = "^3.8"
gino = "^1.0.1"
fastapi = "^0.63.0"
uvicorn = "^0.13.3"
gunicorn = "^20.0.4"
alembic = "^1.5.2"
psycopg2 = "^2.8.6"
gino-starlette = "^0.1.1"
[tool.poetry.dev-dependencies]
pytest = "^6.2.1"
requests = "^2.25.1"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
Now i try to add in pyproject.toml my own plugin to use it like entry points in code:
[tool.poetry.plugins."dataapi.modules"]
users = "dataapi.app.api.v1.endpoints.users"
Then try to use poetry install, but it give me message:
Installing dependencies from lock file
No dependencies to install or update
I try another methods of poetry: update,lock, but nothing happened. I tried to delete the lock file and then run poetry install - but it gave no results either.
I run my service to check and it give me an error:
for ep in entry_points()["dataapi.modules"]:
KeyError: 'dataapi.modules'
Method where i try to got entry points:
import logging
from importlib.metadata import entry_points
logger = logging.getLogger(__name__)
def load_modules(app=None):
for ep in entry_points()["dataapi.modules"]:
logger.info("Loading module: %s", ep.name)
mod = ep.load()
if app:
init_app = getattr(mod, "init_app", None)
if init_app:
init_app(app)
I really don't understood how add plugin in poetry and need help...

unable to open database file on a hosting service pythonanywhere

I want to deploy my project on pythonanywhere. Error.log says that server or machine is unable to open my database. Everything works fine on my local machine. I watched a video of Pretty Printed from YouTube
This how I initialize in app.py. This what I got from error.log
db_session.global_init("db/data.sqlite")
this in db_session:
def global_init(db_file):
global __factory
if __factory:
return
if not db_file or not db_file.strip():
raise Exception("Необходимо указать файл базы данных.")
conn_str = f'sqlite:///{db_file.strip()}?check_same_thread=False'
print(f"Подключение к базе данных по адресу {conn_str}")
engine = sa.create_engine(conn_str, echo=False)
__factory = orm.sessionmaker(bind=engine)
from . import __all_models
SqlAlchemyBase.metadata.create_all(engine)
def create_session() -> Session:
global __factory
return __factory()
last thing is my wsgi.py:
import sys
path = '/home/r1chter/Chicken-beta'
if path not in sys.path:
sys.path.append(path)
import os
from dotenv import load_dotenv
project_folder = os.path.expanduser(path)
load_dotenv(os.path.join(project_folder, '.env'))
import app # noqa
application = app.app()
Usually errors like this on PythonAnywhere are due to providing relative path instead of absolute path.

How can I change Pelican Static Site Theme (on Windows dev Machine)?

I am not able to switch from the default theme. I am using powershell and running on Windows 7.
I generate and view with
.Scripts\pelican .\content
.Scripts\pelican --listen
Even .Scripts\pelican -t 'notmyidea' is not working
I have pelican-themes and pelican-plugins cloned into my project folder. Here are my configuration file content
publishconf.py:
#!/usr/bin/env python
# -*- coding: utf-8 -*- #
from __future__ import unicode_literals
# This file is only used if you use `make publish` or
# explicitly specify it as your config file.
import os
import sys
sys.path.append(os.curdir)
from pelicanconf import *
# If your site is available via HTTPS, make sure SITEURL begins with https://
SITEURL = 'https://aself.com'
RELATIVE_URLS = False
FEED_ALL_ATOM = 'feeds/all.atom.xml'
CATEGORY_FEED_ATOM = 'feeds/{slug}.atom.xml'
DELETE_OUTPUT_DIRECTORY = True
# Following items are often useful when publishing
#DISQUS_SITENAME = ""
#GOOGLE_ANALYTICS = ""
THEME = "pelican-themes/blue-penguin"
# THEME = 'plumage'
# THEME = 'notmyidea'
LOAD_CONTENT_CACHE = False
PLUGINS_PATHS = ["plugins", "pelican-plugins"]
PLUGINS = ['assets','tipue_search']
TIPUE_SEARCH = True
# TEMPLATE_PAGES = {
# 'search.html': 'search.html',
# }
Change
THEME = "pelican-themes/blue-penguin"
to
THEME = "blue-penguin"
using the command
pelican-themes -l
will show you the installed themes you have

ImproperlyConfigured: Requested setting MIDDLEWARE_CLASSES, but settings are not configured

i am confuring the apache mod_wsgi to django project
and here is my djangotest.wsgi file
import os
import sys
sys.path = ['/home/pavan/djangoproject'] + sys.path
os.environ['DJANGO_SETTINS_MODULE'] = 'djangoproject.settings'
import django.core.handlers.wsgi
_application = django.core.handlers.wsgi.WSGIHandler()
def application(environ, start_response):
environ['PATH_INFO'] = environ['SCRIPT_NAME'] + environ['PATH_INFO']
return _application(environ, start_response)
and i add the WSGIScrptAlias to my virtual directory
when i try to get the homepage of the project it says the following error
ImproperlyConfigured: Requested setting MIDDLEWARE_CLASSES, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
Looks like you have a typo on line 4. 'DJANGO_SETTINS_MODULE' should be 'DJANGO_SETTINGS_MODULE'.