Skip to content

Commit da4dc54

Browse files
authored
Refactor pip install (flagos-ai#1109)
### PR Category <!-- One of [ Train | Inference | Compress | Serve | RL | Core | Hardware | CICD | Tools | Others ] --> Tools ### PR Types <!-- One of [ User Experience | New Features | Bug Fixes | Improvements | Performance | Breaking Change| Deprecations | Test Case | Docs | Others ] --> Improvements ### PR Description <!-- Describe what you’ve done --> Refactor the installation process for FlagScale to make it easier for users to install with pip. `FLAGSCALE_PLATFORM=cuda FLAGSCALE_TASK=train pip install --no-build-isolation . -vvv`
1 parent 344817a commit da4dc54

20 files changed

Lines changed: 1101 additions & 364 deletions

File tree

.coveragerc

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/workflows/unit_tests_common.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ jobs:
162162
${INSTALL_DIR:+--install-dir "$INSTALL_DIR"} \
163163
--no-system --no-dev --no-base --no-task \
164164
--src-deps megatron-lm \
165+
--pip-deps typer \
165166
--retry-count 3
166167
167168
# Copy test data (keep existing logic)

__init__.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +0,0 @@
1-
import os
2-
import sys
3-
4-
# Add parent directory to path to import version
5-
_parent_dir = os.path.dirname(os.path.abspath(__file__))
6-
if _parent_dir not in sys.path:
7-
sys.path.insert(0, _parent_dir)
8-
9-
from version import FLAGSCALE_VERSION
10-
11-
__version__ = FLAGSCALE_VERSION

flagscale/__init__.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
def _get_version() -> str:
2+
"""Get version from importlib.metadata or parse pyproject.toml as fallback."""
3+
try:
4+
from importlib.metadata import version
5+
6+
return version("flagscale")
7+
except Exception:
8+
pass
9+
10+
# Fallback: parse pyproject.toml for development mode (Python 3.11+)
11+
try:
12+
from pathlib import Path
13+
14+
import tomllib
15+
16+
pyproject_path = Path(__file__).parent.parent / "pyproject.toml"
17+
if pyproject_path.exists():
18+
with open(pyproject_path, "rb") as f:
19+
data = tomllib.load(f)
20+
return data.get("project", {}).get("version", "0.0.0")
21+
except Exception:
22+
pass
23+
24+
return "0.0.0"
25+
26+
27+
__version__ = _get_version()

0 commit comments

Comments
 (0)