mirror of
https://github.com/YunoHost-Apps/pyinventory_ynh.git
synced 2024-09-03 20:16:09 +02:00
Install Python 3.11.7
Borrowed helper from: https://github.com/YunoHost-Apps/homeassistant_ynh/blob/master/scripts/_common.sh
This commit is contained in:
parent
5340fa4cb3
commit
33a1dfb40a
17 changed files with 1045 additions and 503 deletions
|
@ -16,5 +16,5 @@ max_line_length = 119
|
|||
indent_style = tab
|
||||
insert_final_newline = false
|
||||
|
||||
[*.yml]
|
||||
[{*.yaml,*.yml}]
|
||||
indent_size = 2
|
||||
|
|
2
.github/workflows/package_linter.yml
vendored
2
.github/workflows/package_linter.yml
vendored
|
@ -24,7 +24,7 @@ jobs:
|
|||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install toml
|
||||
pip install toml pyparsing
|
||||
|
||||
- name: 'Clone YunoHost apps package linter'
|
||||
run: |
|
||||
|
|
10
.github/workflows/tests.yml
vendored
10
.github/workflows/tests.yml
vendored
|
@ -16,10 +16,7 @@ jobs:
|
|||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
python-version: ["3.12", "3.11", "3.10", "3.9"]
|
||||
env:
|
||||
PYTHONUNBUFFERED: 1
|
||||
PYTHONWARNINGS: always
|
||||
python-version: ["3.12", "3.11"]
|
||||
steps:
|
||||
- name: Checkout
|
||||
run: |
|
||||
|
@ -37,7 +34,7 @@ jobs:
|
|||
with:
|
||||
python-version: '${{ matrix.python-version }}'
|
||||
cache: 'pip' # caching pip dependencies
|
||||
cache-dependency-path: '**/requirements.dev.txt'
|
||||
cache-dependency-path: '**/requirements.*.txt'
|
||||
|
||||
- name: 'Bootstrap dev venv'
|
||||
# The first CLI call will create the .venv
|
||||
|
@ -53,6 +50,9 @@ jobs:
|
|||
./dev-cli.py safety
|
||||
|
||||
- name: 'Run tests with Python v${{ matrix.python-version }}'
|
||||
env:
|
||||
PYTHONUNBUFFERED: 1
|
||||
PYTHONWARNINGS: always
|
||||
run: |
|
||||
.venv/bin/coverage erase
|
||||
./dev-cli.py coverage
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,6 +2,7 @@
|
|||
*.egg-info
|
||||
__pycache__
|
||||
/dist/
|
||||
/build/
|
||||
/coverage.*
|
||||
/htmlcov/
|
||||
*.orig
|
||||
|
|
|
@ -11,18 +11,18 @@ asgiref==3.7.2 \
|
|||
async-timeout==4.0.3 \
|
||||
--hash=sha256:4640d96be84d82d02ed59ea2b7105a0f7b33abe8703703cd0ab0bf87c427522f \
|
||||
--hash=sha256:7405140ff1230c310e51dc27b3145b9092d659ce68ff733fb0cefe3ee42be028
|
||||
# via pyinventory-ynh (pyproject.toml)
|
||||
# via cli-base-utilities
|
||||
bleach==6.1.0 \
|
||||
--hash=sha256:0a31f1837963c41d46bbf1331b8778e1308ea0791db03cc4e7357b97cf42a8fe \
|
||||
--hash=sha256:3225f354cfc436b9789c66c4ee030194bee0568fbf9cbdad3bc8b5c26c5f12b6
|
||||
# via django-tools
|
||||
bx-django-utils==69 \
|
||||
--hash=sha256:39e96b8ad47bcf36d6713e4e42c8d09deb21e413160dc2944f17b7d2e2244713 \
|
||||
--hash=sha256:59b806aa36b50184f14bd0f7a61fb66c478fa231a44f92472360ce0cf1616013
|
||||
bx-django-utils==70 \
|
||||
--hash=sha256:41c8bd54c0eab07ce914ec7bf3eca115324fba577b158a89d827b4312a4e6a98 \
|
||||
--hash=sha256:dfc2db1ef019c51ea446687dff1602f75984f3bc410426d3c3ff34d2fab58f1a
|
||||
# via pyinventory
|
||||
bx-py-utils==88 \
|
||||
--hash=sha256:32fbc7e9ff3dfb0a817c80fb1d165ec559643dab59c0be549e646acbf8223b75 \
|
||||
--hash=sha256:3a6f4eeef6abcac834b2c1ea4c5211130fd930a064aa0baabddd7c2bd00e38ac
|
||||
bx-py-utils==90 \
|
||||
--hash=sha256:2c15b3b7d8a8e4f0bc6815517fb732fb303ce6878c3e45bbd60633b2811bf0ea \
|
||||
--hash=sha256:bb8aa9bd59b6c733cc8fe65340a98bbff026bbc5aa3c3c01324f27d84b8c9302
|
||||
# via
|
||||
# bx-django-utils
|
||||
# cli-base-utilities
|
||||
|
@ -124,19 +124,19 @@ charset-normalizer==3.3.2 \
|
|||
--hash=sha256:fd1abc0d89e30cc4e02e4064dc67fcc51bd941eb395c502aac3ec19fab46b519 \
|
||||
--hash=sha256:ff8fa367d09b717b2a17a052544193ad76cd49979c805768879cb63d9ca50561
|
||||
# via requests
|
||||
cli-base-utilities==0.4.4 \
|
||||
--hash=sha256:110bef895fb7dfc29662f463ccedc4c985a880afbde2e6dea387d0d2f96f4985 \
|
||||
--hash=sha256:72d4248776519a21c3448d6e348511ce6fe8c3742c154e158473236c8278fb1c
|
||||
# via pyinventory-ynh (pyproject.toml)
|
||||
cli-base-utilities==0.7.0 \
|
||||
--hash=sha256:3d13b861d4c96b597b1dc3c6fdbe428dc72c444ab61008cc9555292d7b3ec8b4 \
|
||||
--hash=sha256:fa39bd83900749ece5866ea996d270880081a5155497f74db46995c28b1a9425
|
||||
# via pyinventory_ynh (pyproject.toml)
|
||||
click==8.1.7 \
|
||||
--hash=sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28 \
|
||||
--hash=sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de
|
||||
# via
|
||||
# cli-base-utilities
|
||||
# rich-click
|
||||
colorlog==6.7.0 \
|
||||
--hash=sha256:0d33ca236784a1ba3ff9c532d4964126d8a2c44f1f0cb1d2b0728196f512f662 \
|
||||
--hash=sha256:bd94bd21c1e13fac7bd3153f4bc3a7dc0eb0974b8bc2fdf1a989e474f6e582e5
|
||||
colorlog==6.8.0 \
|
||||
--hash=sha256:4ed23b05a1154294ac99f511fabe8c1d6d4364ec1f7fc989c7fb515ccc29d375 \
|
||||
--hash=sha256:fbb6fdf9d5685f2517f388fb29bb27d54e8654dd31f58bc2a3b217e967a95ca6
|
||||
# via
|
||||
# django-yunohost-integration
|
||||
# pyinventory
|
||||
|
@ -150,9 +150,9 @@ diff-match-patch==20230430 \
|
|||
# via
|
||||
# django-import-export
|
||||
# django-reversion-compare
|
||||
django==4.2.7 \
|
||||
--hash=sha256:8e0f1c2c2786b5c0e39fe1afce24c926040fad47c8ea8ad30aaf1188df29fc41 \
|
||||
--hash=sha256:e1d37c51ad26186de355cbcec16613ebdabfa9689bbade9c538835205a8abbe9
|
||||
django==5.0.1 \
|
||||
--hash=sha256:8c8659665bc6e3a44fefe1ab0a291e5a3fb3979f9a8230be29de975e57e8f854 \
|
||||
--hash=sha256:f47a37a90b9bbe2c8ec360235192c7fddfdc832206fcf618bb849b39256affc1
|
||||
# via
|
||||
# bx-django-utils
|
||||
# django-admin-sortable2
|
||||
|
@ -173,9 +173,9 @@ django-admin-sortable2==2.1.10 \
|
|||
--hash=sha256:3756b02c7d09c5b37efe657718d5aae2b75f46fd01bbfe1c39d4e60651019d79 \
|
||||
--hash=sha256:98d1c8d268398c3c3aff4752f766b2c307a5bd97174938c29f818d8a4697854d
|
||||
# via pyinventory
|
||||
django-axes==6.1.1 \
|
||||
--hash=sha256:29c48ff5f09046afd5e9a16e96d3bbb79f6c11c59f0a7bbd732559e60d0aa9fa \
|
||||
--hash=sha256:cd1bc4f7becc8e9243eb4090dffa258d7d7125ca0ce3153b6ffc920bccbf2c3f
|
||||
django-axes==6.3.0 \
|
||||
--hash=sha256:86e2444ad024610e6cb8520e88f34a3b4cd042b1234c5c86ecb1d1629b841701 \
|
||||
--hash=sha256:8e415193d7881a3e517734a5ebfde92a0b00a919a0777cbae52c7f0246b30ad1
|
||||
# via django-yunohost-integration
|
||||
django-ckeditor==6.7.0 \
|
||||
--hash=sha256:0489f7a6ae93360d328f77cea17c04891103cbdfa6c962af386bbe47e811671b \
|
||||
|
@ -189,21 +189,21 @@ django-debug-toolbar==4.2.0 \
|
|||
--hash=sha256:af99128c06e8e794479e65ab62cc6c7d1e74e1c19beb44dcbf9bad7a9c017327 \
|
||||
--hash=sha256:bc7fdaafafcdedefcc67a4a5ad9dac96efd6e41db15bc74d402a54a2ba4854dc
|
||||
# via pyinventory
|
||||
django-import-export==3.3.3 \
|
||||
--hash=sha256:2c1b16e1cf2ea5f62a165d8867e7c6dcff25673ab7201fd18aaf67c9ee90367e \
|
||||
--hash=sha256:78973202e93897326ab0411d64eaf89b72779fcb21ee9e5f64f3fb96571a5978
|
||||
django-import-export==3.3.5 \
|
||||
--hash=sha256:56b4196d85677989f3d6b15863c23ac351b21d973e53ddaa226f62510acdc034 \
|
||||
--hash=sha256:81bd7a6b35c0ee3c78b99e2bedb7f320c13d551d9482f968864c83f8a24daf58
|
||||
# via pyinventory
|
||||
django-js-asset==2.1.0 \
|
||||
--hash=sha256:36a3a4dd6e9efc895fb127d13126020f6ec1ec9469ad42878d42143f22495d90 \
|
||||
--hash=sha256:be6f69ae5c4865617aa7726c48eddb64089a1e7d4ea7d22a35a3beb8282020f6
|
||||
django-js-asset==2.2.0 \
|
||||
--hash=sha256:0c57a82cae2317e83951d956110ce847f58ff0cdc24e314dbc18b35033917e94 \
|
||||
--hash=sha256:7ef3e858e13d06f10799b56eea62b1e76706f42cf4e709be4e13356bc0ae30d8
|
||||
# via django-ckeditor
|
||||
django-redis==5.4.0 \
|
||||
--hash=sha256:6a02abaa34b0fea8bf9b707d2c363ab6adc7409950b2db93602e6cb292818c42 \
|
||||
--hash=sha256:ebc88df7da810732e2af9987f7f426c96204bf89319df4c6da6ca9a2942edd5b
|
||||
# via django-yunohost-integration
|
||||
django-reversion==5.0.8 \
|
||||
--hash=sha256:229ad0d2819416157502ff13d81bad2366227b763ce85b63b8a223edb756a513 \
|
||||
--hash=sha256:45d378bc6e606df6b2ad0077aec8b0a00e35f18c74ca2a1ae9cc262ceb32fb9a
|
||||
django-reversion==5.0.10 \
|
||||
--hash=sha256:1209a7965ea91f39a297424450f88732e01acf841e024a1eec6c6420367a6252 \
|
||||
--hash=sha256:c18749a67c1db4167ccaccc36395c5fe6078f312869683c2f3d214051e5a6b29
|
||||
# via django-reversion-compare
|
||||
django-reversion-compare==0.16.2 \
|
||||
--hash=sha256:5629f226fc73bd7b95de47b2e21e2eba2fa39f004ba0fee6d460e96676c0dc9b \
|
||||
|
@ -219,12 +219,12 @@ django-tools==0.54.0 \
|
|||
# via
|
||||
# django-yunohost-integration
|
||||
# pyinventory
|
||||
django-yunohost-integration[ynh]==0.6.0 \
|
||||
--hash=sha256:9596ab56b66edf1b56eccaceb4b5807df237e752128e79568cd13b075267f26f \
|
||||
--hash=sha256:dfb72b94ae30e02948dd60ca76d56da4ca6a74ea04f357b8d61b94807fca0493
|
||||
django-yunohost-integration[ynh]==0.7.1 \
|
||||
--hash=sha256:7dde5ce8cb5ff92a6f6bf7366882652b796d0ce62b8839eda5f800a87b104523 \
|
||||
--hash=sha256:d6dbddd9fae54e3ce4b0fbc6e8a3c0f19ed145c358b8bb8677baddd30ae6a028
|
||||
# via
|
||||
# django-yunohost-integration
|
||||
# pyinventory-ynh (pyproject.toml)
|
||||
# pyinventory_ynh (pyproject.toml)
|
||||
et-xmlfile==1.1.0 \
|
||||
--hash=sha256:8eb9e2bc2f8c97e37a2dc85a09ecdcdec9d8a396530a6d5a33b30b9a92da0c5c \
|
||||
--hash=sha256:a2ba85d1d6a74ef63837eed693bcb89c3f752169b0e3e7ae5b16ca5e1b3deada
|
||||
|
@ -265,63 +265,78 @@ packaging==23.2 \
|
|||
--hash=sha256:048fb0e9405036518eaaf48a55953c750c11e1a1b68e0dd1a9d62ed0c092cfc5 \
|
||||
--hash=sha256:8c491190033a9af7e1d931d0b5dacc2ef47509b34dd0de67ed209b5203fc88c7
|
||||
# via
|
||||
# cli-base-utilities
|
||||
# django-yunohost-integration
|
||||
# gunicorn
|
||||
pillow==10.1.0 \
|
||||
--hash=sha256:00f438bb841382b15d7deb9a05cc946ee0f2c352653c7aa659e75e592f6fa17d \
|
||||
--hash=sha256:0248f86b3ea061e67817c47ecbe82c23f9dd5d5226200eb9090b3873d3ca32de \
|
||||
--hash=sha256:04f6f6149f266a100374ca3cc368b67fb27c4af9f1cc8cb6306d849dcdf12616 \
|
||||
--hash=sha256:062a1610e3bc258bff2328ec43f34244fcec972ee0717200cb1425214fe5b839 \
|
||||
--hash=sha256:0a026c188be3b443916179f5d04548092e253beb0c3e2ee0a4e2cdad72f66099 \
|
||||
--hash=sha256:0f7c276c05a9767e877a0b4c5050c8bee6a6d960d7f0c11ebda6b99746068c2a \
|
||||
--hash=sha256:1a8413794b4ad9719346cd9306118450b7b00d9a15846451549314a58ac42219 \
|
||||
--hash=sha256:1ab05f3db77e98f93964697c8efc49c7954b08dd61cff526b7f2531a22410106 \
|
||||
--hash=sha256:1c3ac5423c8c1da5928aa12c6e258921956757d976405e9467c5f39d1d577a4b \
|
||||
--hash=sha256:1c41d960babf951e01a49c9746f92c5a7e0d939d1652d7ba30f6b3090f27e412 \
|
||||
--hash=sha256:1fafabe50a6977ac70dfe829b2d5735fd54e190ab55259ec8aea4aaea412fa0b \
|
||||
--hash=sha256:1fb29c07478e6c06a46b867e43b0bcdb241b44cc52be9bc25ce5944eed4648e7 \
|
||||
--hash=sha256:24fadc71218ad2b8ffe437b54876c9382b4a29e030a05a9879f615091f42ffc2 \
|
||||
--hash=sha256:2cdc65a46e74514ce742c2013cd4a2d12e8553e3a2563c64879f7c7e4d28bce7 \
|
||||
--hash=sha256:2ef6721c97894a7aa77723740a09547197533146fba8355e86d6d9a4a1056b14 \
|
||||
--hash=sha256:3b834f4b16173e5b92ab6566f0473bfb09f939ba14b23b8da1f54fa63e4b623f \
|
||||
--hash=sha256:3d929a19f5469b3f4df33a3df2983db070ebb2088a1e145e18facbc28cae5b27 \
|
||||
--hash=sha256:41f67248d92a5e0a2076d3517d8d4b1e41a97e2df10eb8f93106c89107f38b57 \
|
||||
--hash=sha256:47e5bf85b80abc03be7455c95b6d6e4896a62f6541c1f2ce77a7d2bb832af262 \
|
||||
--hash=sha256:4d0152565c6aa6ebbfb1e5d8624140a440f2b99bf7afaafbdbf6430426497f28 \
|
||||
--hash=sha256:50d08cd0a2ecd2a8657bd3d82c71efd5a58edb04d9308185d66c3a5a5bed9610 \
|
||||
--hash=sha256:61f1a9d247317fa08a308daaa8ee7b3f760ab1809ca2da14ecc88ae4257d6172 \
|
||||
--hash=sha256:6932a7652464746fcb484f7fc3618e6503d2066d853f68a4bd97193a3996e273 \
|
||||
--hash=sha256:7a7e3daa202beb61821c06d2517428e8e7c1aab08943e92ec9e5755c2fc9ba5e \
|
||||
--hash=sha256:7dbaa3c7de82ef37e7708521be41db5565004258ca76945ad74a8e998c30af8d \
|
||||
--hash=sha256:7df5608bc38bd37ef585ae9c38c9cd46d7c81498f086915b0f97255ea60c2818 \
|
||||
--hash=sha256:806abdd8249ba3953c33742506fe414880bad78ac25cc9a9b1c6ae97bedd573f \
|
||||
--hash=sha256:883f216eac8712b83a63f41b76ddfb7b2afab1b74abbb413c5df6680f071a6b9 \
|
||||
--hash=sha256:912e3812a1dbbc834da2b32299b124b5ddcb664ed354916fd1ed6f193f0e2d01 \
|
||||
--hash=sha256:937bdc5a7f5343d1c97dc98149a0be7eb9704e937fe3dc7140e229ae4fc572a7 \
|
||||
--hash=sha256:9882a7451c680c12f232a422730f986a1fcd808da0fd428f08b671237237d651 \
|
||||
--hash=sha256:9a92109192b360634a4489c0c756364c0c3a2992906752165ecb50544c251312 \
|
||||
--hash=sha256:9d7bc666bd8c5a4225e7ac71f2f9d12466ec555e89092728ea0f5c0c2422ea80 \
|
||||
--hash=sha256:a5f63b5a68daedc54c7c3464508d8c12075e56dcfbd42f8c1bf40169061ae666 \
|
||||
--hash=sha256:a646e48de237d860c36e0db37ecaecaa3619e6f3e9d5319e527ccbc8151df061 \
|
||||
--hash=sha256:a89b8312d51715b510a4fe9fc13686283f376cfd5abca8cd1c65e4c76e21081b \
|
||||
--hash=sha256:a92386125e9ee90381c3369f57a2a50fa9e6aa8b1cf1d9c4b200d41a7dd8e992 \
|
||||
--hash=sha256:ae88931f93214777c7a3aa0a8f92a683f83ecde27f65a45f95f22d289a69e593 \
|
||||
--hash=sha256:afc8eef765d948543a4775f00b7b8c079b3321d6b675dde0d02afa2ee23000b4 \
|
||||
--hash=sha256:b0eb01ca85b2361b09480784a7931fc648ed8b7836f01fb9241141b968feb1db \
|
||||
--hash=sha256:b1c25762197144e211efb5f4e8ad656f36c8d214d390585d1d21281f46d556ba \
|
||||
--hash=sha256:b4005fee46ed9be0b8fb42be0c20e79411533d1fd58edabebc0dd24626882cfd \
|
||||
--hash=sha256:b920e4d028f6442bea9a75b7491c063f0b9a3972520731ed26c83e254302eb1e \
|
||||
--hash=sha256:baada14941c83079bf84c037e2d8b7506ce201e92e3d2fa0d1303507a8538212 \
|
||||
--hash=sha256:bb40c011447712d2e19cc261c82655f75f32cb724788df315ed992a4d65696bb \
|
||||
--hash=sha256:c0949b55eb607898e28eaccb525ab104b2d86542a85c74baf3a6dc24002edec2 \
|
||||
--hash=sha256:c9aeea7b63edb7884b031a35305629a7593272b54f429a9869a4f63a1bf04c34 \
|
||||
--hash=sha256:cfe96560c6ce2f4c07d6647af2d0f3c54cc33289894ebd88cfbb3bcd5391e256 \
|
||||
--hash=sha256:d27b5997bdd2eb9fb199982bb7eb6164db0426904020dc38c10203187ae2ff2f \
|
||||
--hash=sha256:d921bc90b1defa55c9917ca6b6b71430e4286fc9e44c55ead78ca1a9f9eba5f2 \
|
||||
--hash=sha256:e6bf8de6c36ed96c86ea3b6e1d5273c53f46ef518a062464cd7ef5dd2cf92e38 \
|
||||
--hash=sha256:eaed6977fa73408b7b8a24e8b14e59e1668cfc0f4c40193ea7ced8e210adf996 \
|
||||
--hash=sha256:fa1d323703cfdac2036af05191b969b910d8f115cf53093125e4058f62012c9a \
|
||||
--hash=sha256:fe1e26e1ffc38be097f0ba1d0d07fcade2bcfd1d023cda5b29935ae8052bd793
|
||||
pillow==10.2.0 \
|
||||
--hash=sha256:0304004f8067386b477d20a518b50f3fa658a28d44e4116970abfcd94fac34a8 \
|
||||
--hash=sha256:0689b5a8c5288bc0504d9fcee48f61a6a586b9b98514d7d29b840143d6734f39 \
|
||||
--hash=sha256:0eae2073305f451d8ecacb5474997c08569fb4eb4ac231ffa4ad7d342fdc25ac \
|
||||
--hash=sha256:0fb3e7fc88a14eacd303e90481ad983fd5b69c761e9e6ef94c983f91025da869 \
|
||||
--hash=sha256:11fa2e5984b949b0dd6d7a94d967743d87c577ff0b83392f17cb3990d0d2fd6e \
|
||||
--hash=sha256:127cee571038f252a552760076407f9cff79761c3d436a12af6000cd182a9d04 \
|
||||
--hash=sha256:154e939c5f0053a383de4fd3d3da48d9427a7e985f58af8e94d0b3c9fcfcf4f9 \
|
||||
--hash=sha256:15587643b9e5eb26c48e49a7b33659790d28f190fc514a322d55da2fb5c2950e \
|
||||
--hash=sha256:170aeb00224ab3dc54230c797f8404507240dd868cf52066f66a41b33169bdbe \
|
||||
--hash=sha256:1b5e1b74d1bd1b78bc3477528919414874748dd363e6272efd5abf7654e68bef \
|
||||
--hash=sha256:1da3b2703afd040cf65ec97efea81cfba59cdbed9c11d8efc5ab09df9509fc56 \
|
||||
--hash=sha256:1e23412b5c41e58cec602f1135c57dfcf15482013ce6e5f093a86db69646a5aa \
|
||||
--hash=sha256:2247178effb34a77c11c0e8ac355c7a741ceca0a732b27bf11e747bbc950722f \
|
||||
--hash=sha256:257d8788df5ca62c980314053197f4d46eefedf4e6175bc9412f14412ec4ea2f \
|
||||
--hash=sha256:3031709084b6e7852d00479fd1d310b07d0ba82765f973b543c8af5061cf990e \
|
||||
--hash=sha256:322209c642aabdd6207517e9739c704dc9f9db943015535783239022002f054a \
|
||||
--hash=sha256:322bdf3c9b556e9ffb18f93462e5f749d3444ce081290352c6070d014c93feb2 \
|
||||
--hash=sha256:33870dc4653c5017bf4c8873e5488d8f8d5f8935e2f1fb9a2208c47cdd66efd2 \
|
||||
--hash=sha256:35bb52c37f256f662abdfa49d2dfa6ce5d93281d323a9af377a120e89a9eafb5 \
|
||||
--hash=sha256:3c31822339516fb3c82d03f30e22b1d038da87ef27b6a78c9549888f8ceda39a \
|
||||
--hash=sha256:3eedd52442c0a5ff4f887fab0c1c0bb164d8635b32c894bc1faf4c618dd89df2 \
|
||||
--hash=sha256:3ff074fc97dd4e80543a3e91f69d58889baf2002b6be64347ea8cf5533188213 \
|
||||
--hash=sha256:47c0995fc4e7f79b5cfcab1fc437ff2890b770440f7696a3ba065ee0fd496563 \
|
||||
--hash=sha256:49d9ba1ed0ef3e061088cd1e7538a0759aab559e2e0a80a36f9fd9d8c0c21591 \
|
||||
--hash=sha256:51f1a1bffc50e2e9492e87d8e09a17c5eea8409cda8d3f277eb6edc82813c17c \
|
||||
--hash=sha256:52a50aa3fb3acb9cf7213573ef55d31d6eca37f5709c69e6858fe3bc04a5c2a2 \
|
||||
--hash=sha256:54f1852cd531aa981bc0965b7d609f5f6cc8ce8c41b1139f6ed6b3c54ab82bfb \
|
||||
--hash=sha256:609448742444d9290fd687940ac0b57fb35e6fd92bdb65386e08e99af60bf757 \
|
||||
--hash=sha256:69ffdd6120a4737710a9eee73e1d2e37db89b620f702754b8f6e62594471dee0 \
|
||||
--hash=sha256:6fad5ff2f13d69b7e74ce5b4ecd12cc0ec530fcee76356cac6742785ff71c452 \
|
||||
--hash=sha256:7049e301399273a0136ff39b84c3678e314f2158f50f517bc50285fb5ec847ad \
|
||||
--hash=sha256:70c61d4c475835a19b3a5aa42492409878bbca7438554a1f89d20d58a7c75c01 \
|
||||
--hash=sha256:716d30ed977be8b37d3ef185fecb9e5a1d62d110dfbdcd1e2a122ab46fddb03f \
|
||||
--hash=sha256:753cd8f2086b2b80180d9b3010dd4ed147efc167c90d3bf593fe2af21265e5a5 \
|
||||
--hash=sha256:773efe0603db30c281521a7c0214cad7836c03b8ccff897beae9b47c0b657d61 \
|
||||
--hash=sha256:7823bdd049099efa16e4246bdf15e5a13dbb18a51b68fa06d6c1d4d8b99a796e \
|
||||
--hash=sha256:7c8f97e8e7a9009bcacbe3766a36175056c12f9a44e6e6f2d5caad06dcfbf03b \
|
||||
--hash=sha256:823ef7a27cf86df6597fa0671066c1b596f69eba53efa3d1e1cb8b30f3533068 \
|
||||
--hash=sha256:8373c6c251f7ef8bda6675dd6d2b3a0fcc31edf1201266b5cf608b62a37407f9 \
|
||||
--hash=sha256:83b2021f2ade7d1ed556bc50a399127d7fb245e725aa0113ebd05cfe88aaf588 \
|
||||
--hash=sha256:870ea1ada0899fd0b79643990809323b389d4d1d46c192f97342eeb6ee0b8483 \
|
||||
--hash=sha256:8d12251f02d69d8310b046e82572ed486685c38f02176bd08baf216746eb947f \
|
||||
--hash=sha256:9c23f307202661071d94b5e384e1e1dc7dfb972a28a2310e4ee16103e66ddb67 \
|
||||
--hash=sha256:9d189550615b4948f45252d7f005e53c2040cea1af5b60d6f79491a6e147eef7 \
|
||||
--hash=sha256:a086c2af425c5f62a65e12fbf385f7c9fcb8f107d0849dba5839461a129cf311 \
|
||||
--hash=sha256:a2b56ba36e05f973d450582fb015594aaa78834fefe8dfb8fcd79b93e64ba4c6 \
|
||||
--hash=sha256:aebb6044806f2e16ecc07b2a2637ee1ef67a11840a66752751714a0d924adf72 \
|
||||
--hash=sha256:b1b3020d90c2d8e1dae29cf3ce54f8094f7938460fb5ce8bc5c01450b01fbaf6 \
|
||||
--hash=sha256:b4b6b1e20608493548b1f32bce8cca185bf0480983890403d3b8753e44077129 \
|
||||
--hash=sha256:b6f491cdf80ae540738859d9766783e3b3c8e5bd37f5dfa0b76abdecc5081f13 \
|
||||
--hash=sha256:b792a349405fbc0163190fde0dc7b3fef3c9268292586cf5645598b48e63dc67 \
|
||||
--hash=sha256:b7c2286c23cd350b80d2fc9d424fc797575fb16f854b831d16fd47ceec078f2c \
|
||||
--hash=sha256:babf5acfede515f176833ed6028754cbcd0d206f7f614ea3447d67c33be12516 \
|
||||
--hash=sha256:c365fd1703040de1ec284b176d6af5abe21b427cb3a5ff68e0759e1e313a5e7e \
|
||||
--hash=sha256:c4225f5220f46b2fde568c74fca27ae9771536c2e29d7c04f4fb62c83275ac4e \
|
||||
--hash=sha256:c570f24be1e468e3f0ce7ef56a89a60f0e05b30a3669a459e419c6eac2c35364 \
|
||||
--hash=sha256:c6dafac9e0f2b3c78df97e79af707cdc5ef8e88208d686a4847bab8266870023 \
|
||||
--hash=sha256:c8de2789052ed501dd829e9cae8d3dcce7acb4777ea4a479c14521c942d395b1 \
|
||||
--hash=sha256:cb28c753fd5eb3dd859b4ee95de66cc62af91bcff5db5f2571d32a520baf1f04 \
|
||||
--hash=sha256:cb4c38abeef13c61d6916f264d4845fab99d7b711be96c326b84df9e3e0ff62d \
|
||||
--hash=sha256:d1b35bcd6c5543b9cb547dee3150c93008f8dd0f1fef78fc0cd2b141c5baf58a \
|
||||
--hash=sha256:d8e6aeb9201e655354b3ad049cb77d19813ad4ece0df1249d3c793de3774f8c7 \
|
||||
--hash=sha256:d8ecd059fdaf60c1963c58ceb8997b32e9dc1b911f5da5307aab614f1ce5c2fb \
|
||||
--hash=sha256:da2b52b37dad6d9ec64e653637a096905b258d2fc2b984c41ae7d08b938a67e4 \
|
||||
--hash=sha256:e87f0b2c78157e12d7686b27d63c070fd65d994e8ddae6f328e0dcf4a0cd007e \
|
||||
--hash=sha256:edca80cbfb2b68d7b56930b84a0e45ae1694aeba0541f798e908a49d66b837f1 \
|
||||
--hash=sha256:f379abd2f1e3dddb2b61bc67977a6b5a0a3f7485538bcc6f39ec76163891ee48 \
|
||||
--hash=sha256:fe4c15f6c9285dc54ce6553a3ce908ed37c8f3825b5a51a15c91442bb955b868
|
||||
# via pyinventory
|
||||
pprintpp==0.4.0 \
|
||||
--hash=sha256:b6b4dcdd0c0c0d75e4d7b2f21a9e933e5b2ce62b26e1a54537f9651ae5a5c01d \
|
||||
|
@ -349,7 +364,7 @@ pygments==2.17.2 \
|
|||
pyinventory==0.19.3 \
|
||||
--hash=sha256:42e5710956e466df389ddf01c1ab8f9c432890b745a2a32765085c67fda78cfa \
|
||||
--hash=sha256:b9efc88ca43aa57c4e04f2024087e50015bd9fc969730e3049258b06d048cce4
|
||||
# via pyinventory-ynh (pyproject.toml)
|
||||
# via pyinventory_ynh (pyproject.toml)
|
||||
python-stdnum==1.19 \
|
||||
--hash=sha256:133ec82f56390ea74c190569e98f2fb14b869808b1d54785708f22d0fead8b3f \
|
||||
--hash=sha256:1b5b401ad3f45b798b0317313b781a433f5d7a5ff2c9feb8054664f76f78644e
|
||||
|
@ -426,9 +441,9 @@ rich==13.7.0 \
|
|||
# via
|
||||
# cli-base-utilities
|
||||
# rich-click
|
||||
rich-click==1.7.1 \
|
||||
--hash=sha256:660c8ea345343f47c5de88f62afa34a19d9f4c7accdd9c6e39dc17eece6affcd \
|
||||
--hash=sha256:c37d19af85c86b9a256c18e9d23637ae89478300ec8dc5e220c6ca213675f2f9
|
||||
rich-click==1.7.2 \
|
||||
--hash=sha256:22f93439a3d65f4a04e07cd584f4d01d132d96899766af92ed287618156abbe2 \
|
||||
--hash=sha256:a42bcdcb8696c4ca7a3b1a39e1aba3d2cb64ad00690b4c022fdcb2cbccebc3fc
|
||||
# via cli-base-utilities
|
||||
six==1.16.0 \
|
||||
--hash=sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926 \
|
||||
|
@ -446,13 +461,17 @@ tablib[html,ods,xls,xlsx,yaml]==3.5.0 \
|
|||
# via
|
||||
# django-import-export
|
||||
# tablib
|
||||
tomli==2.0.1 \
|
||||
--hash=sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc \
|
||||
--hash=sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f
|
||||
# via cli-base-utilities
|
||||
tomlkit==0.12.3 \
|
||||
--hash=sha256:75baf5012d06501f07bee5bf8e801b9f343e7aac5a92581f20f80ce632e6b5a4 \
|
||||
--hash=sha256:b0a645a9156dc7cb5d3a1f0d4bab66db287fcb8e0430bdd4664a095ea16414ba
|
||||
# via cli-base-utilities
|
||||
typing-extensions==4.8.0 \
|
||||
--hash=sha256:8f92fc8806f9a6b641eaa5318da32b44d401efaac0f6678c9bc448ba3605faa0 \
|
||||
--hash=sha256:df8e4339e9cb77357558cbdbceca33c303714cf861d1eef15e1070055ae8b7ef
|
||||
typing-extensions==4.9.0 \
|
||||
--hash=sha256:23478f88c37f27d76ac8aee6c905017a143b0b1b886c3c9f66bc2fd94f9f5783 \
|
||||
--hash=sha256:af72aea155e91adfc61c3ae9e0e342dbc0cba726d6cba4b6c72c1f34e47291cd
|
||||
# via rich-click
|
||||
urllib3==2.1.0 \
|
||||
--hash=sha256:55901e917a5896a349ff771be919f8bd99aff50b79fe58fec595eb37bbc56bb3 \
|
||||
|
@ -472,7 +491,7 @@ xlwt==1.3.0 \
|
|||
# via tablib
|
||||
|
||||
# The following packages are considered to be unsafe in a requirements file:
|
||||
setuptools==69.0.2 \
|
||||
--hash=sha256:1e8fdff6797d3865f37397be788a4e3cba233608e9b509382a2777d25ebde7f2 \
|
||||
--hash=sha256:735896e78a4742605974de002ac60562d286fa8051a7e2299445e8e8fbb01aa6
|
||||
setuptools==69.0.3 \
|
||||
--hash=sha256:385eb4edd9c9d5c17540511303e39a147ce2fc04bc55289c322b9e5904fe2c05 \
|
||||
--hash=sha256:be1af57fc409f93647f2e8e4573a142ed38724b8cdd389706a867bb4efcf1e78
|
||||
# via django-axes
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
"""
|
||||
|
||||
import hashlib
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
import venv
|
||||
|
@ -32,7 +33,7 @@ else:
|
|||
sys.exit(-1)
|
||||
|
||||
|
||||
assert sys.version_info >= (3, 9), 'Python version is too old!'
|
||||
assert sys.version_info >= (3, 10), f'Python version {sys.version_info} is too old!'
|
||||
|
||||
|
||||
if sys.platform == 'win32': # wtf
|
||||
|
@ -77,7 +78,7 @@ def venv_up2date():
|
|||
|
||||
|
||||
def verbose_check_call(*popen_args):
|
||||
print(f'\n+ {" ".join(str(arg) for arg in popen_args)}\n')
|
||||
print(f'\n+ {shlex.join(str(arg) for arg in popen_args)}\n')
|
||||
return subprocess.check_call(popen_args)
|
||||
|
||||
|
||||
|
|
|
@ -2,31 +2,34 @@
|
|||
CLI for development
|
||||
"""
|
||||
import logging
|
||||
import os
|
||||
import shlex
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import django
|
||||
import rich_click as click
|
||||
from bx_py_utils.path import assert_is_file
|
||||
from cli_base.cli_tools import code_style
|
||||
from cli_base.cli_tools.dev_tools import run_tox
|
||||
from cli_base.cli_tools.subprocess_utils import verbose_check_call
|
||||
from cli_base.cli_tools.test_utils.snapshot import UpdateTestSnapshotFiles
|
||||
from cli_base.cli_tools.verbosity import OPTION_KWARGS_VERBOSE
|
||||
from cli_base.cli_tools.version_info import print_version
|
||||
from django.core.management.commands.test import Command as DjangoTestCommand
|
||||
from django_yunohost_integration.local_test import CreateResults, create_local_test
|
||||
from manageprojects.utilities import code_style
|
||||
from django_yunohost_integration.local_test import create_local_test
|
||||
from manageprojects.utilities.publish import publish_package
|
||||
from rich import print # noqa; noqa
|
||||
from rich import print
|
||||
from rich.console import Console
|
||||
from rich.traceback import install as rich_traceback_install
|
||||
from rich_click import RichGroup
|
||||
|
||||
import pyinventory_ynh
|
||||
from pyinventory_ynh import constants
|
||||
from pyinventory_ynh.constants import PACKAGE_ROOT
|
||||
from pyinventory_ynh.tests import setup_ynh_tests
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
PACKAGE_ROOT = Path(pyinventory_ynh.__file__).parent.parent
|
||||
assert_is_file(PACKAGE_ROOT / 'pyproject.toml')
|
||||
|
||||
OPTION_ARGS_DEFAULT_TRUE = dict(is_flag=True, show_default=True, default=True)
|
||||
OPTION_ARGS_DEFAULT_FALSE = dict(is_flag=True, show_default=True, default=False)
|
||||
ARGUMENT_EXISTING_DIR = dict(
|
||||
|
@ -45,7 +48,6 @@ ARGUMENT_NOT_EXISTING_DIR = dict(
|
|||
ARGUMENT_EXISTING_FILE = dict(
|
||||
type=click.Path(exists=True, file_okay=True, dir_okay=False, readable=True, path_type=Path)
|
||||
)
|
||||
CLI_EPILOG = 'Project Homepage: https://github.com/YunoHost-Apps/pyinventory_ynh'
|
||||
|
||||
|
||||
class ClickGroup(RichGroup): # FIXME: How to set the "info_name" easier?
|
||||
|
@ -54,16 +56,19 @@ class ClickGroup(RichGroup): # FIXME: How to set the "info_name" easier?
|
|||
return super().make_context(info_name, *args, **kwargs)
|
||||
|
||||
|
||||
@click.group(cls=ClickGroup, epilog=CLI_EPILOG)
|
||||
@click.group(
|
||||
cls=ClickGroup,
|
||||
epilog=constants.CLI_EPILOG,
|
||||
)
|
||||
def cli():
|
||||
pass
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option('--verbose/--no-verbose', **OPTION_ARGS_DEFAULT_FALSE)
|
||||
def mypy(verbose: bool = True):
|
||||
@click.option('-v', '--verbosity', **OPTION_KWARGS_VERBOSE)
|
||||
def mypy(verbosity: int):
|
||||
"""Run Mypy (configured in pyproject.toml)"""
|
||||
verbose_check_call('mypy', '.', cwd=PACKAGE_ROOT, verbose=verbose, exit_on_error=True)
|
||||
verbose_check_call('mypy', '.', cwd=PACKAGE_ROOT, verbose=verbosity > 0, exit_on_error=True)
|
||||
|
||||
|
||||
cli.add_command(mypy)
|
||||
|
@ -165,7 +170,7 @@ def publish():
|
|||
Build and upload this project to PyPi
|
||||
"""
|
||||
try:
|
||||
_run_django_test_cli() # Don't publish a broken state
|
||||
_run_django_test_cli(argv=sys.argv, exit_after_run=True) # Don't publish a broken state
|
||||
except SystemExit as err:
|
||||
assert err.code == 0, f'Exit code is not 0: {err.code}'
|
||||
|
||||
|
@ -181,12 +186,12 @@ cli.add_command(publish)
|
|||
|
||||
@click.command()
|
||||
@click.option('--color/--no-color', **OPTION_ARGS_DEFAULT_TRUE)
|
||||
@click.option('--verbose/--no-verbose', **OPTION_ARGS_DEFAULT_FALSE)
|
||||
def fix_code_style(color: bool = True, verbose: bool = False):
|
||||
@click.option('-v', '--verbosity', **OPTION_KWARGS_VERBOSE)
|
||||
def fix_code_style(color: bool, verbosity: int):
|
||||
"""
|
||||
Fix code style of all pyinventory_ynh source code files via darker
|
||||
"""
|
||||
code_style.fix(package_root=PACKAGE_ROOT, color=color, verbose=verbose)
|
||||
code_style.fix(package_root=PACKAGE_ROOT, darker_color=color, darker_verbose=verbosity > 0)
|
||||
|
||||
|
||||
cli.add_command(fix_code_style)
|
||||
|
@ -194,12 +199,12 @@ cli.add_command(fix_code_style)
|
|||
|
||||
@click.command()
|
||||
@click.option('--color/--no-color', **OPTION_ARGS_DEFAULT_TRUE)
|
||||
@click.option('--verbose/--no-verbose', **OPTION_ARGS_DEFAULT_FALSE)
|
||||
def check_code_style(color: bool = True, verbose: bool = False):
|
||||
@click.option('-v', '--verbosity', **OPTION_KWARGS_VERBOSE)
|
||||
def check_code_style(color: bool, verbosity: int):
|
||||
"""
|
||||
Check code style by calling darker + flake8
|
||||
"""
|
||||
code_style.check(package_root=PACKAGE_ROOT, color=color, verbose=verbose)
|
||||
code_style.check(package_root=PACKAGE_ROOT, darker_color=color, darker_verbose=verbosity > 0)
|
||||
|
||||
|
||||
cli.add_command(check_code_style)
|
||||
|
@ -210,59 +215,31 @@ def update_test_snapshot_files():
|
|||
"""
|
||||
Update all test snapshot files (by remove and recreate all snapshot files)
|
||||
"""
|
||||
|
||||
def iter_snapshot_files():
|
||||
yield from PACKAGE_ROOT.rglob('*.snapshot.*')
|
||||
|
||||
removed_file_count = 0
|
||||
for item in iter_snapshot_files():
|
||||
item.unlink()
|
||||
removed_file_count += 1
|
||||
print(f'{removed_file_count} test snapshot files removed... run tests...')
|
||||
|
||||
with UpdateTestSnapshotFiles(root_path=PACKAGE_ROOT, verbose=True):
|
||||
# Just recreate them by running tests:
|
||||
os.environ['RAISE_SNAPSHOT_ERRORS'] = '0' # Recreate snapshot files without error
|
||||
try:
|
||||
_run_django_test_cli()
|
||||
finally:
|
||||
new_files = len(list(iter_snapshot_files()))
|
||||
print(f'{new_files} test snapshot files created, ok.\n')
|
||||
_run_django_test_cli(argv=sys.argv, exit_after_run=False)
|
||||
|
||||
|
||||
cli.add_command(update_test_snapshot_files)
|
||||
|
||||
|
||||
def _run_django_test_cli():
|
||||
def _run_django_test_cli(argv, exit_after_run=True):
|
||||
"""
|
||||
Call the origin Django test manage command CLI and pass all args to it.
|
||||
"""
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
|
||||
setup_ynh_tests()
|
||||
|
||||
print('Compile YunoHost files...')
|
||||
result: CreateResults = create_local_test(
|
||||
django_settings_path=PACKAGE_ROOT / 'conf' / 'settings.py',
|
||||
destination=PACKAGE_ROOT / 'local_test',
|
||||
runserver=False,
|
||||
extra_replacements={
|
||||
'__DEBUG_ENABLED__': '0', # "1" or "0" string
|
||||
'__LOG_LEVEL__': 'INFO',
|
||||
'__ADMIN_EMAIL__': 'foo-bar@test.tld',
|
||||
'__DEFAULT_FROM_EMAIL__': 'django_app@test.tld',
|
||||
},
|
||||
)
|
||||
print('Local test files created:')
|
||||
print(result)
|
||||
|
||||
data_dir = str(result.data_dir_path)
|
||||
if data_dir not in sys.path:
|
||||
sys.path.insert(0, data_dir)
|
||||
|
||||
django.setup()
|
||||
|
||||
os.chdir(Path(pyinventory_ynh.__file__).parent)
|
||||
print('\nStart Django unittests with:')
|
||||
for default_arg in ('shuffle', 'buffer'):
|
||||
if default_arg not in argv and f'--no-{default_arg}' not in argv:
|
||||
argv.append(f'--{default_arg}')
|
||||
print(shlex.join(argv))
|
||||
print()
|
||||
|
||||
test_command = DjangoTestCommand()
|
||||
test_command.run_from_argv(sys.argv)
|
||||
test_command.run_from_argv(argv)
|
||||
if exit_after_run:
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
@click.command() # Dummy command
|
||||
|
@ -270,23 +247,18 @@ def test():
|
|||
"""
|
||||
Compile YunoHost files and run Django unittests
|
||||
"""
|
||||
_run_django_test_cli()
|
||||
_run_django_test_cli(argv=sys.argv, exit_after_run=True)
|
||||
|
||||
|
||||
cli.add_command(test)
|
||||
|
||||
|
||||
def _run_tox():
|
||||
verbose_check_call(sys.executable, '-m', 'tox', *sys.argv[2:])
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
@click.command() # Dummy "tox" command
|
||||
def tox():
|
||||
"""
|
||||
Run tox
|
||||
"""
|
||||
_run_tox()
|
||||
run_tox()
|
||||
|
||||
|
||||
cli.add_command(tox)
|
||||
|
@ -349,16 +321,23 @@ cli.add_command(diffsettings)
|
|||
def main():
|
||||
print_version(pyinventory_ynh)
|
||||
|
||||
print(f'{sys.argv=}')
|
||||
if len(sys.argv) >= 2:
|
||||
# Check if we just pass a command call
|
||||
# Check if we can just pass a command call to origin CLI:
|
||||
command = sys.argv[1]
|
||||
if command == 'test':
|
||||
_run_django_test_cli()
|
||||
sys.exit(0)
|
||||
elif command == 'tox':
|
||||
_run_tox()
|
||||
sys.exit(0)
|
||||
command_map = {
|
||||
'test': _run_django_test_cli,
|
||||
'tox': run_tox,
|
||||
}
|
||||
if real_func := command_map.get(command):
|
||||
real_func(argv=sys.argv, exit_after_run=True)
|
||||
|
||||
console = Console()
|
||||
rich_traceback_install(
|
||||
width=console.size.width, # full terminal width
|
||||
show_locals=True,
|
||||
suppress=[click],
|
||||
max_frames=2,
|
||||
)
|
||||
|
||||
print('Execute Click CLI')
|
||||
cli()
|
||||
|
|
11
pyinventory_ynh/constants.py
Normal file
11
pyinventory_ynh/constants.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
from pathlib import Path
|
||||
|
||||
import pyinventory_ynh
|
||||
from bx_py_utils.path import assert_is_file
|
||||
|
||||
|
||||
PACKAGE_ROOT = Path(pyinventory_ynh.__file__).parent.parent
|
||||
assert_is_file(PACKAGE_ROOT / 'pyproject.toml')
|
||||
|
||||
|
||||
CLI_EPILOG = 'Project Homepage: https://github.com/YunoHost-Apps/pyinventory_ynh'
|
|
@ -1,6 +1,63 @@
|
|||
import os
|
||||
import sys
|
||||
import unittest.util
|
||||
from pathlib import Path
|
||||
|
||||
import django
|
||||
import pyinventory_ynh
|
||||
from bx_py_utils.test_utils.deny_requests import deny_any_real_request
|
||||
from cli_base.cli_tools.verbosity import MAX_LOG_LEVEL, setup_logging
|
||||
from pyinventory_ynh.constants import PACKAGE_ROOT
|
||||
from django_yunohost_integration.local_test import CreateResults, create_local_test
|
||||
from rich import print # noqa
|
||||
|
||||
|
||||
# Hacky way to expand the failed test output:
|
||||
unittest.util._MAX_LENGTH = os.environ.get('UNITTEST_MAX_LENGTH', 300)
|
||||
def pre_configure_tests() -> None:
|
||||
print(f'Configure unittests via "load_tests Protocol" from {Path(__file__).relative_to(Path.cwd())}')
|
||||
|
||||
# Hacky way to display more "assert"-Context in failing tests:
|
||||
_MIN_MAX_DIFF = unittest.util._MAX_LENGTH - unittest.util._MIN_DIFF_LEN
|
||||
unittest.util._MAX_LENGTH = int(os.environ.get('UNITTEST_MAX_LENGTH', 300))
|
||||
unittest.util._MIN_DIFF_LEN = unittest.util._MAX_LENGTH - _MIN_MAX_DIFF
|
||||
|
||||
# Deny any request via docket/urllib3 because tests they should mock all requests:
|
||||
deny_any_real_request()
|
||||
|
||||
# Display DEBUG logs in tests:
|
||||
setup_logging(verbosity=MAX_LOG_LEVEL)
|
||||
|
||||
|
||||
def setup_ynh_tests() -> None:
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
|
||||
|
||||
print('Compile YunoHost files...')
|
||||
result: CreateResults = create_local_test(
|
||||
django_settings_path=PACKAGE_ROOT / 'conf' / 'settings.py',
|
||||
destination=PACKAGE_ROOT / 'local_test',
|
||||
runserver=False,
|
||||
extra_replacements={
|
||||
'__DEBUG_ENABLED__': '0', # "1" or "0" string
|
||||
'__LOG_LEVEL__': 'INFO',
|
||||
'__ADMIN_EMAIL__': 'foo-bar@test.tld',
|
||||
'__DEFAULT_FROM_EMAIL__': 'django_app@test.tld',
|
||||
},
|
||||
)
|
||||
print('Local test files created:')
|
||||
print(result)
|
||||
|
||||
data_dir = str(result.data_dir_path)
|
||||
if data_dir not in sys.path:
|
||||
sys.path.insert(0, data_dir)
|
||||
|
||||
django.setup()
|
||||
|
||||
os.chdir(Path(pyinventory_ynh.__file__).parent)
|
||||
|
||||
|
||||
def load_tests(loader, tests, pattern):
|
||||
"""
|
||||
Use unittest "load_tests Protocol" as a hook to setup test environment before running tests.
|
||||
https://docs.python.org/3/library/unittest.html#load-tests-protocol
|
||||
"""
|
||||
pre_configure_tests()
|
||||
return loader.discover(start_dir=Path(__file__).parent, pattern=pattern)
|
||||
|
|
25
pyinventory_ynh/tests/local_settings_source.py
Normal file
25
pyinventory_ynh/tests/local_settings_source.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
# This file will be copied to the "local test" files, to overwrite Django settings
|
||||
|
||||
import os
|
||||
|
||||
|
||||
print('Load local settings file:', __file__)
|
||||
|
||||
ENV_TYPE = os.environ.get('ENV_TYPE', None)
|
||||
print(f'ENV_TYPE: {ENV_TYPE!r}')
|
||||
|
||||
if ENV_TYPE == 'local':
|
||||
print(f'Activate settings overwrite by {__file__}')
|
||||
SECURE_SSL_REDIRECT = False # Don't redirect http to https
|
||||
SERVE_FILES = True # May used in urls.py
|
||||
AUTH_PASSWORD_VALIDATORS = [] # accept all passwords
|
||||
ALLOWED_HOSTS = ['127.0.0.1', 'localhost'] # For local dev. server
|
||||
CACHES = { # Setup a working cache, without Redis ;)
|
||||
'default': {
|
||||
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
|
||||
'LOCATION': 'unique-snowflake',
|
||||
},
|
||||
}
|
||||
elif ENV_TYPE == 'test':
|
||||
SILENCED_SYSTEM_CHECKS = ['security.W018'] # tests runs with DEBUG=True
|
||||
ALLOWED_HOSTS = [] # For unittests (Django's setup_test_environment() will add 'testserver')
|
|
@ -25,8 +25,8 @@ class DjangoYnhTestCase(HtmlAssertionMixin, TestCase):
|
|||
|
||||
assert settings.PATH_URL == 'app_path'
|
||||
|
||||
assert str(settings.DATA_DIR_PATH).endswith('/local_test/opt_yunohost')
|
||||
assert str(settings.INSTALL_DIR_PATH).endswith('/local_test/var_www')
|
||||
assert str(settings.DATA_DIR_PATH).endswith('/local_test/opt_yunohost'), f'{settings.DATA_DIR_PATH=}'
|
||||
assert str(settings.INSTALL_DIR_PATH).endswith('/local_test/var_www'), f'{settings.INSTALL_DIR_PATH=}'
|
||||
assert str(settings.LOG_FILE_PATH).endswith(
|
||||
'/local_test/var_log_pyinventory.log'
|
||||
), f'{settings.LOG_FILE_PATH=}'
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="main" id="main">
|
||||
<div class="content" id="content-start" tabindex="-1">
|
||||
<main class="content" id="content-start" tabindex="-1">
|
||||
<!-- Content -->
|
||||
<div class="colMS" id="content">
|
||||
<h1>
|
||||
|
@ -88,5 +88,5 @@
|
|||
https://github.com/jedie/PyInventory
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</div>
|
|
@ -1,4 +1,3 @@
|
|||
import os
|
||||
|
||||
from pyinventory_ynh.cli.dev import PACKAGE_ROOT
|
||||
|
||||
|
@ -12,7 +11,6 @@ from bx_django_utils.filename import clean_filename
|
|||
from bx_py_utils.path import assert_is_dir, assert_is_file
|
||||
from django.test.testcases import TestCase
|
||||
from django_tools.unittest_utils.project_setup import check_editor_config
|
||||
from django_yunohost_integration.test_utils import assert_project_version
|
||||
from inventory import __version__ as upstream_version
|
||||
|
||||
from pyinventory_ynh import __version__ as ynh_pkg_version
|
||||
|
@ -47,13 +45,6 @@ class ProjectSetupTestCase(TestCase):
|
|||
manifest_version = ynh_pkg_version.replace('+', '~')
|
||||
self.assertEqual(self.manifest_cfg['version'], manifest_version)
|
||||
|
||||
if 'GITHUB_ACTION' not in os.environ:
|
||||
# Github has a rate-limiting... So don't fetch the API if we run as GitHub action
|
||||
assert_project_version(
|
||||
current_version=ynh_pkg_version,
|
||||
github_project_url='https://github.com/jedie/PyInventory',
|
||||
)
|
||||
|
||||
def test_screenshot_filenames(self):
|
||||
"""
|
||||
https://forum.yunohost.org/t/yunohost-bot-cant-handle-spaces-in-screenshots/19483
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
from pathlib import Path
|
||||
|
||||
from bx_py_utils.auto_doc import assert_readme_block
|
||||
from pyinventory_ynh.cli.dev import PACKAGE_ROOT, cli
|
||||
from pyinventory_ynh.constants import CLI_EPILOG
|
||||
from manageprojects.test_utils.click_cli_utils import invoke_click
|
||||
from manageprojects.tests.base import BaseTestCase
|
||||
|
||||
from pyinventory_ynh.cli.dev import CLI_EPILOG, PACKAGE_ROOT, cli
|
||||
|
||||
|
||||
def assert_cli_help_in_readme(text_block: str, marker: str, readme_path: Path):
|
||||
text_block = text_block.replace(CLI_EPILOG, '')
|
||||
|
|
|
@ -7,25 +7,25 @@ readme = "README.md"
|
|||
authors = [
|
||||
{name = 'Jens Diemer', email = 'pyinventory_ynh@jensdiemer.de'}
|
||||
]
|
||||
requires-python = ">=3.9" # Stay with 3.9 until YunoHost used >=Debian 11 (Bullseye)
|
||||
|
||||
# YunoHost used Debian 11 (Bullseye) that only contains 3.9
|
||||
# But we will install a Python 3.11.x
|
||||
requires-python = ">=3.11"
|
||||
|
||||
dependencies = [
|
||||
"pyinventory", # https://github.com/jedie/PyInventory
|
||||
#
|
||||
# extras "ynh" will install: gunicorn, psycopg2, django-redis and django-axes
|
||||
# see: https://github.com/YunoHost-Apps/django_yunohost_integration/blob/main/pyproject.toml
|
||||
"django_yunohost_integration[ynh]>=0.6.0", # https://github.com/YunoHost-Apps/django_yunohost_integration
|
||||
"django_yunohost_integration[ynh]>=0.7.1", # https://github.com/YunoHost-Apps/django_yunohost_integration
|
||||
#
|
||||
"cli-base-utilities>=0.4.4", # https://github.com/jedie/cli-base-utilities
|
||||
#
|
||||
# indirect depencies, added because we didn't create the requirements.txt with Python <3.11
|
||||
# See: https://github.com/jazzband/pip-tools/issues/1326
|
||||
"async-timeout", # needed by redis for python<=3.11.2
|
||||
"cli-base-utilities", # https://github.com/jedie/cli-base-utilities
|
||||
]
|
||||
[project.optional-dependencies]
|
||||
dev = [
|
||||
"bx_django_utils", # https://github.com/boxine/bx_django_utils
|
||||
"beautifulsoup4", # https://pypi.org/project/beautifulsoup4/
|
||||
"manageprojects>=0.15.0", # https://github.com/jedie/manageprojects
|
||||
"manageprojects", # https://github.com/jedie/manageprojects
|
||||
"pip-tools", # https://github.com/jazzband/pip-tools/
|
||||
"tblib", # https://github.com/ionelmc/python-tblib
|
||||
"tox", # https://github.com/tox-dev/tox
|
||||
|
@ -45,12 +45,6 @@ dev = [
|
|||
# https://github.com/pycqa/isort
|
||||
# https://github.com/pygments/pygments
|
||||
"darker[flynt, isort, color]",
|
||||
|
||||
# indirect depencies added because of bug:
|
||||
# https://github.com/pypa/pip/issues/9644 / https://github.com/jazzband/pip-tools/issues/1866
|
||||
# to avoid errors like:
|
||||
# In --require-hashes mode, all requirements must have their versions pinned with ==. These do not: ...
|
||||
"tomli", # Only needed for Python <3.11
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
|
@ -72,6 +66,9 @@ include = ["pyinventory_ynh*"]
|
|||
[tool.setuptools.dynamic]
|
||||
version = {attr = "pyinventory_ynh.__version__"}
|
||||
|
||||
[ynh-integration]
|
||||
local_settings_source = "pyinventory_ynh/tests/local_settings_source.py"
|
||||
|
||||
|
||||
[tool.darker]
|
||||
src = ['.']
|
||||
|
@ -127,7 +124,7 @@ exclude_lines = [
|
|||
legacy_tox_ini = """
|
||||
[tox]
|
||||
isolated_build = True
|
||||
envlist = py{312,311,310,39}
|
||||
envlist = py{312,311}
|
||||
skip_missing_interpreters = True
|
||||
|
||||
[testenv]
|
||||
|
@ -158,6 +155,9 @@ initial_revision = "b204761"
|
|||
initial_date = 2022-12-21T20:25:20+01:00
|
||||
cookiecutter_template = "https://github.com/jedie/cookiecutter_templates/"
|
||||
cookiecutter_directory = "yunohost_django_package"
|
||||
applied_migrations = [
|
||||
"7271d4c", # 2023-12-29T21:57:47+01:00
|
||||
]
|
||||
|
||||
[manageprojects.cookiecutter_context.cookiecutter]
|
||||
project_name = "PyInventory"
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -34,16 +34,109 @@ XDG_CACHE_HOME="$data_dir/.cache/"
|
|||
log_path=/var/log/$app
|
||||
log_file="${log_path}/${app}.log"
|
||||
|
||||
py_required_version=3.11.7
|
||||
|
||||
#=================================================
|
||||
# PYTHON HELPER
|
||||
# Borrowed from:
|
||||
# https://github.com/YunoHost-Apps/homeassistant_ynh/blob/master/scripts/_common.sh
|
||||
#=================================================
|
||||
|
||||
# Install specific python version
|
||||
# usage: myynh_install_python --python="3.8.6"
|
||||
# | arg: -p, --python= - the python version to install
|
||||
myynh_install_python () {
|
||||
# Declare an array to define the options of this helper.
|
||||
local legacy_args=u
|
||||
local -A args_array=( [p]=python= )
|
||||
local python
|
||||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
# Check python version from APT
|
||||
local py_apt_version=$(python3 --version | cut -d ' ' -f 2)
|
||||
|
||||
# Usefull variables
|
||||
local python_major=${python%.*}
|
||||
|
||||
# Check existing built version of python in /usr/local/bin
|
||||
if [ -e "/usr/local/bin/python$python_major" ]
|
||||
then
|
||||
local py_built_version=$(/usr/local/bin/python$python_major --version \
|
||||
| cut -d ' ' -f 2)
|
||||
else
|
||||
local py_built_version=0
|
||||
fi
|
||||
|
||||
# Compare version
|
||||
if $(dpkg --compare-versions $py_apt_version ge $python)
|
||||
then
|
||||
# APT >= Required
|
||||
ynh_print_info --message="Using provided python3..."
|
||||
|
||||
py_app_version="python3"
|
||||
|
||||
else
|
||||
# Either python already built or to build
|
||||
if $(dpkg --compare-versions $py_built_version ge $python)
|
||||
then
|
||||
# Built >= Required
|
||||
ynh_print_info --message="Using already used python3 built version..."
|
||||
|
||||
py_app_version="/usr/local/bin/python${py_built_version%.*}"
|
||||
|
||||
else
|
||||
# APT < Minimal & Actual < Minimal => Build & install Python into /usr/local/bin
|
||||
ynh_print_info --message="Building python (may take a while)..."
|
||||
|
||||
# Store current direcotry
|
||||
local MY_DIR=$(pwd)
|
||||
|
||||
# Create a temp direcotry
|
||||
tmpdir="$(mktemp --directory)"
|
||||
cd "$tmpdir"
|
||||
|
||||
# Download
|
||||
wget --output-document="Python-$python.tar.xz" \
|
||||
"https://www.python.org/ftp/python/$python/Python-$python.tar.xz" 2>&1
|
||||
|
||||
# Extract
|
||||
tar xf "Python-$python.tar.xz"
|
||||
|
||||
# Install
|
||||
cd "Python-$python"
|
||||
./configure --enable-optimizations
|
||||
ynh_exec_warn_less make -j4
|
||||
ynh_exec_warn_less make altinstall
|
||||
|
||||
# Go back to working directory
|
||||
cd "$MY_DIR"
|
||||
|
||||
# Clean
|
||||
ynh_secure_remove "$tmpdir"
|
||||
|
||||
# Set version
|
||||
py_app_version="/usr/local/bin/python$python_major"
|
||||
fi
|
||||
fi
|
||||
# Save python version in settings
|
||||
ynh_app_setting_set --app=$app --key=python --value="$python"
|
||||
}
|
||||
|
||||
#=================================================
|
||||
# HELPERS
|
||||
#=================================================
|
||||
|
||||
myynh_setup_python_venv() {
|
||||
# Check Python version & compile the required one if needed:
|
||||
myynh_install_python --python="$py_required_version"
|
||||
|
||||
# Always recreate everything fresh with current python version
|
||||
ynh_secure_remove "$data_dir/venv"
|
||||
|
||||
# Create the virtual environment:
|
||||
# Skip pip because of: https://github.com/YunoHost/issues/issues/1960
|
||||
python3 -m venv --without-pip "$data_dir/venv"
|
||||
ynh_exec_as $app $py_app_version -m venv --without-pip "$data_dir/venv"
|
||||
|
||||
chown -c -R "$app:" "$data_dir"
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue