Package a Django app... How to start?

I have at least these Python/Django projects:

and would like to package them for Yunohost usage… But how to start?

Where are well-structured examples of Django packages?

EDIT: I looked around and found:

Question about the project Layout…

It seems that weblate_ynh just store everything (settings.py, static etc.) under /var/www/$YNH_APP_INSTANCE_NAME/

Think that’s the right place for e.g. static files, but not for settings.py, isn’t it?

https://github.com/YunoHost-Apps/nodered_ynh used: /opt/yunohost/$YNH_APP_INSTANCE_NAME/

So maybe the right place for settings.py can be /opt/yunohost/$YNH_APP_INSTANCE_NAME/
and static under: /var/www/$YNH_APP_INSTANCE_NAME/

Is there somewhere a good overview about the best places?!?

The location of the files does not really matter actually, but here is the convention for YunoHost:

  • /var/www/$app for apps that rely on NGINX to serve their files
  • /opt/yunohost/$app for apps that do not serve web pages or rely on their own binary to serve files (that’s the case for Node-RED for example)

I don’t know specifically about Django apps, but it seems like they deploy their own server and serve the app on a port, right? If so, the /opt directory is best suited to house the files. Then use NGINX to proxy to locahost:$port.

I use uwsgi as Django app server and nginx for serving static files (e.g.: CSS, JS etc.)

I think it’s a bad practice to put “internal” files into /var/www/ (Files that never ever should served to public), isn’t it?

Currently i tried this:

# Path for e.g. "static" files, served by nginx:
final_www_path=/var/www/$app
test ! -e "$final_www_path" || ynh_die --message="This path already contains a folder"

# Path for own config files, e.g.: Django's settings.py:
final_home_path=/opt/yunohost/$app
test ! -e "$final_home_path" || ynh_die --message="This path already contains a folder"

Don’t know if this is a really good idea?

I think, as long as you keep track of these two paths in the other standard YunoHost scripts (backup, restore, upgrade, …), you will be fine. :wink:

2 Likes

I’m work on it here: https://github.com/jedie/pyinventory_ynh to get https://github.com/jedie/PyInventory installed…

EDIT: Moved to: https://github.com/YunoHost-Apps/pyinventory_ynh

Application pyinventory rise from level 3 to level 7 on https://ci-apps.yunohost.org/ci/job/638

:clap:

1 Like