Skip to content

Commit 1069070

Browse files
committed
fix: 修复workflow虚拟环境和测试路径问题
1 parent 440f0e7 commit 1069070

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

.github/workflows/publish-pypi.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,30 @@ jobs:
3030
with:
3131
python-version: '3.10'
3232

33+
- name: Create virtual environment
34+
run: python -m venv .venv
35+
3336
- name: Install dependencies
3437
run: |
38+
source .venv/bin/activate
3539
python -m pip install --upgrade pip
3640
pip install build twine
3741
3842
- name: Run tests
3943
run: |
44+
source .venv/bin/activate
4045
pip install -r requirements.txt
4146
python test/test_basic.py
4247
4348
- name: Build package
44-
run: python -m build
49+
run: |
50+
source .venv/bin/activate
51+
python -m build
4552
4653
- name: Check distribution
47-
run: twine check dist/*
54+
run: |
55+
source .venv/bin/activate
56+
twine check dist/*
4857
4958
- name: Upload artifacts
5059
uses: actions/upload-artifact@v4

python/test/test_basic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
import sys
1111
import os
1212

13-
# 添加src目录到Python路径
14-
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "."))
13+
# 添加python目录到Python路径(test的上一级目录)
14+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
1515

1616
try:
1717
from src.service.serversvc.server_service import MeterServerService

0 commit comments

Comments
 (0)