1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pyinventory_ynh.git synced 2024-09-03 20:16:09 +02:00

Use poetry to run local_test.py

So we get django-auth-ldap installed.
Also add a Makefile for easier usage.
This commit is contained in:
JensDiemer 2020-12-19 20:19:06 +01:00
parent 4206f55b36
commit 0995215fd2
6 changed files with 71 additions and 14 deletions

1
.gitignore vendored
View file

@ -5,3 +5,4 @@
__pycache__ __pycache__
secret.txt secret.txt
/local_test/ /local_test/
/poetry.lock

37
Makefile Normal file
View file

@ -0,0 +1,37 @@
SHELL := /bin/bash
all: help
help:
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9 -]+:.*?## / {printf "\033[36m%-22s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
check-poetry:
@if [[ "$(shell poetry --version 2>/dev/null)" == *"Poetry"* ]] ; \
then \
echo "Poetry found, ok." ; \
else \
echo 'Please install poetry first, with e.g.:' ; \
echo 'make install-poetry' ; \
exit 1 ; \
fi
install-poetry: ## install or update poetry
pip3 install -U poetry
install: check-poetry ## install PyInventory via poetry
sudo apt install python3-ldap libldap2-dev libsasl2-dev
poetry install
update: install-poetry ## update the sources and installation
poetry update
local-test: check-poetry ## Run local_test.py to run pyinventory_ynh locally
poetry run ./local_test.py
local-diff-settings: ## Run "manage.py diffsettings" with local test
poetry run python3 local_test/opt_yunohost/manage.py diffsettings
##############################################################################
.PHONY: help check-poetry install-poetry install update local-test

View file

@ -1,9 +1,9 @@
# PyInventory for YunoHost # PyInventory for YunoHost
[![Integration level](https://dash.yunohost.org/integration/pyinventory.svg)](https://dash.yunohost.org/appci/app/pyinventory) ![](https://ci-apps.yunohost.org/ci/badges/pyinventory.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/pyinventory.maintain.svg) [![Integration level](https://dash.yunohost.org/integration/pyinventory.svg)](https://dash.yunohost.org/appci/app/pyinventory) ![](https://ci-apps.yunohost.org/ci/badges/pyinventory.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/pyinventory.maintain.svg)
[![Install PyInventory with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=pyinventory) [![Install PyInventory with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=pyinventory)
> *This package allows you to install PyInventory quickly and simply on a YunoHost server. > *This package allows you to install PyInventory quickly and simply on a YunoHost server.
If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.*
Pull requests welcome ;) Pull requests welcome ;)
@ -106,20 +106,18 @@ For quicker developing of PyInventory in the context of YunoHost app,
it's possible to run the Django developer server with the settings it's possible to run the Django developer server with the settings
and urls made for YunoHost installation. and urls made for YunoHost installation.
For this, just run `local_test.py` in a PyInventory virtualenv.
e.g.: e.g.:
```bash ```bash
~$ git clone https://github.com/jedie/PyInventory.git
~$ git clone https://github.com/YunoHost-Apps/pyinventory_ynh.git ~$ git clone https://github.com/YunoHost-Apps/pyinventory_ynh.git
~$ cd PyInventory/ ~$ cd pyinventory_ynh/
~/PyInventory$ make install ~/pyinventory_ynh$ make
~/PyInventory$ poetry shell install-poetry install or update poetry
(pyinventory-yd_5sxYx-py3.8) ~/PyInventory$ cd ../pyinventory_ynh/ install install PyInventory via poetry
(pyinventory-yd_5sxYx-py3.8) ~/pyinventory_ynh$ ./local_test.py update update the sources and installation
... local-test Run local_test.py to run pyinventory_ynh locally
Django version 2.2.17, using settings 'ynh_pyinventory_settings' ~/pyinventory_ynh$ make install-poetry
Starting development server at http://127.0.0.1:8000/ ~/pyinventory_ynh$ make install
~/pyinventory_ynh$ make local-test
``` ```
Notes: Notes:

View file

@ -130,6 +130,10 @@ def main():
# conf/ynh_urls.py -> local_test/ynh_urls.py # conf/ynh_urls.py -> local_test/ynh_urls.py
copy_patch(src_file=URLS_FILE, replaces=REPLACES) copy_patch(src_file=URLS_FILE, replaces=REPLACES)
with Path(FINAL_HOME_PATH / 'local_settings.py').open('w') as f:
f.write('# Only for local test run\n')
f.write('SERVE_FILES=True # used in src/inventory_project/urls.py\n')
# call "local_test/manage.py" via subprocess: # call "local_test/manage.py" via subprocess:
call_manage_py('check --deploy') call_manage_py('check --deploy')
call_manage_py('migrate --no-input') call_manage_py('migrate --no-input')

View file

@ -5,7 +5,7 @@
"description": { "description": {
"en": "Web based management to catalog things including state and location etc." "en": "Web based management to catalog things including state and location etc."
}, },
"version": "0.8.1~ynh6", "version": "0.8.1~ynh7",
"url": "https://github.com/jedie/PyInventory", "url": "https://github.com/jedie/PyInventory",
"license": "GPL-3.0", "license": "GPL-3.0",
"maintainer": { "maintainer": {

17
pyproject.toml Normal file
View file

@ -0,0 +1,17 @@
[tool.poetry]
name = "pyinventory_ynh"
version = "0.8.1~ynh7"
description = "Test pyinventory_ynh via local_test.py"
authors = ["JensDiemer <git@jensdiemer.de>"]
license = "GPL"
[tool.poetry.dependencies]
python = ">=3.7,<4.0.0"
pyinventory = "*"
django-auth-ldap = "*"
[tool.poetry.dev-dependencies]
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"