Skip to content

Commit 086a429

Browse files
authored
add sub-package (#1036)
1 parent b4b564d commit 086a429

File tree

3 files changed

+35
-15
lines changed

3 files changed

+35
-15
lines changed

.github/workflows/main.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,16 @@ jobs:
367367

368368
- name: Build
369369
run: |
370-
pip install build
370+
pip install build tomlkit
371+
cp pyproject.toml pyproject.toml.backup
372+
python scripts/generate_toml_optional_deps.py --split
371373
python -m build --config-setting=skbuild.wheel.cmake=false
374+
mv pyproject.toml.backup pyproject.toml
372375
373376
- name: Test installing built package
374-
run: pip install dist/lazyllm*.whl
377+
run: |
378+
pip install dist/lazyllm*.whl
379+
pip install "$(ls dist/lazyllm*.whl)[online-advanced]"
375380
376381
- name: Test import
377382
working-directory: /tmp

.github/workflows/publish_release.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,12 @@ jobs:
155155

156156
- name: Build default wheel
157157
run: |
158-
pip install build
158+
pip install build tomlkit
159+
cp pyproject.toml pyproject.toml.backup
160+
python scripts/generate_toml_optional_deps.py --split
159161
python -m build --config-setting=skbuild.wheel.cmake=false
160162
ls -la dist/
163+
mv pyproject.toml.backup pyproject.toml
161164
162165
- name: Upload source_code
163166
uses: actions/upload-artifact@v4
@@ -211,9 +214,12 @@ jobs:
211214

212215
- name: Build wheel
213216
run: |
214-
pip install cibuildwheel
217+
pip install cibuildwheel tomlkit
218+
cp pyproject.toml pyproject.toml.backup
219+
python scripts/generate_toml_optional_deps.py --split
215220
cibuildwheel --output-dir repaired_wheel
216221
ls -la repaired_wheel/
222+
mv pyproject.toml.backup pyproject.toml
217223
env:
218224
CIBW_BUILD_VERBOSITY: 1
219225

scripts/generate_toml_optional_deps.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
'''
55
from pathlib import Path
66
import tomlkit
7+
import sys
78

89
def expand_caret(version: str) -> str:
910
'''
@@ -45,6 +46,13 @@ def normalize_version(version: str) -> str:
4546
return version
4647

4748

49+
def make_subgroup(project, name, deps):
50+
arr = tomlkit.array()
51+
arr.multiline(True)
52+
for dep in sorted(deps):
53+
arr.append(dep)
54+
project['optional-dependencies'][name] = arr
55+
4856
def main():
4957
path = Path('pyproject.toml')
5058
if not path.exists():
@@ -57,23 +65,24 @@ def main():
5765

5866
poetry_optional_deps = doc['tool']['poetry']['dependencies']
5967

60-
proj_optional_deps = []
68+
split = 'split' in sys.argv[1:] or '--split' in sys.argv[1:]
69+
proj_optional_deps = {} if split else []
6170

6271
for name, spec in poetry_optional_deps.items():
6372
version = normalize_version(spec['version'])
64-
proj_optional_deps.append(f'{name}{version}')
73+
if split:
74+
proj_optional_deps[name] = f'{name}{version}'
75+
else:
76+
proj_optional_deps.append(f'{name}{version}')
6577

66-
project = doc['project']
6778
project['optional-dependencies'] = tomlkit.table()
6879

69-
arr = tomlkit.array()
70-
arr.multiline(True)
71-
for dep in sorted(proj_optional_deps):
72-
arr.append(dep)
73-
74-
project = doc['project']
75-
project['optional-dependencies'] = tomlkit.table()
76-
project['optional-dependencies']['optional'] = arr
80+
if split:
81+
extras = doc['tool']['poetry']['extras']
82+
for k, vs in extras.items():
83+
make_subgroup(project, k, [proj_optional_deps[v] for v in vs])
84+
else:
85+
make_subgroup(project, 'optional', proj_optional_deps)
7786

7887
# remove poetry sections
7988
doc['tool'].pop('poetry', None)

0 commit comments

Comments
 (0)