vault backup: 2025-01-10 13:43:35

This commit is contained in:
deng 2025-01-10 13:43:35 +08:00
parent 6f1a9d3321
commit 22a4841d61
2 changed files with 33 additions and 6 deletions

View File

@ -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",

View File

@ -14,6 +14,32 @@ tags:
- Abstract
- 在將Python專案打包時會遇到填寫依賴套件及其版本的問題開發者必須逐一測試Python版本與依賴套件版本之間甚至是跨平台不同組合的可運行性而Nox正是為了可以將此流程自動化而生
- Concept
- Steps
- Note
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')
```