From 22a4841d61dc38d3f1cfac0ec3f1fc88a41c9e0c Mon Sep 17 00:00:00 2001 From: deng Date: Fri, 10 Jan 2025 13:43:35 +0800 Subject: [PATCH] vault backup: 2025-01-10 13:43:35 --- .obsidian/workspace-mobile.json | 9 +++++---- 組織/EverfortuneAI/{Note} Nox.md | 30 ++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/.obsidian/workspace-mobile.json b/.obsidian/workspace-mobile.json index d1d064a..5326b37 100644 --- a/.obsidian/workspace-mobile.json +++ b/.obsidian/workspace-mobile.json @@ -13,12 +13,12 @@ "state": { "type": "markdown", "state": { - "file": "組織/EverfortuneAI/{Note} Packaging Python Project.md", + "file": "組織/EverfortuneAI/{Note} Nox.md", "mode": "source", "source": false }, "icon": "lucide-file", - "title": "{Note} Packaging Python Project" + "title": "{Note} Nox" } } ] @@ -140,13 +140,14 @@ "canvas:Create new canvas": false, "daily-notes:Open today's daily note": false, "templates:Insert template": false, - "command-palette:Open command palette": false + "command-palette:Open command palette": false, + "obsidian-git:Open Git source control": false } }, "active": "e0251782d53c0c60", "lastOpenFiles": [ - "README.md", "組織/EverfortuneAI/{Note} Packaging Python Project.md", + "README.md", "Test.md", "組織/EverfortuneAI/resources/should_setup_py_be_deleted.png", "組織/EverfortuneAI/resources", diff --git a/組織/EverfortuneAI/{Note} Nox.md b/組織/EverfortuneAI/{Note} Nox.md index c191629..008c158 100644 --- a/組織/EverfortuneAI/{Note} Nox.md +++ b/組織/EverfortuneAI/{Note} Nox.md @@ -14,6 +14,32 @@ tags: - Abstract - 在將Python專案打包時會遇到填寫依賴套件及其版本的問題,開發者必須逐一測試Python版本與依賴套件版本之間(甚至是跨平台)不同組合的可運行性,而Nox正是為了可以將此流程自動化而生 -- Concept - Steps -- Note \ No newline at end of file + 1. 在虛擬環境中安裝Nox(`pip install nox`) + 2. 在Package資料夾中產生*noxfile.py* 並撰寫測試程式碼(範例程式碼可見Note) + 3. 於終端機輸入`nox` 開始進行測試 +- Note + - 以下為*noxfile.py*範例程式碼(透過環境是否能順利執行單元測試來判別套件之間的匹配性) + +```python +# noxfile.py +# +# author: deng +# date : 20250110 + +import nox + + +@nox.session(python=['3.10', '3.11', '3.12']) +@nox.parametrize('numpy', ['1.26', '2.0']) +@nox.parametrize('scikit_learn', ['1.5', '1.6']) +def test_flexibility(session, numpy, scikit_learn): + + # Install package dependencies + session.install(f'numpy=={numpy}') + session.install(f'scikit-learn=={scikit_learn}') + + # Test + session.install('pytest') + session.run('pytest') +``` \ No newline at end of file