Skip to content

Commit

Permalink
feat: support parse version from src/package/__init__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
waketzheng committed Oct 31, 2024
1 parent 63acc0c commit 2076ba1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
run: |
python -m pip install --upgrade pip pdm poetry
poetry config virtualenvs.create false
poetry self add poetry-version-plugin
poetry self add poetry-plugin-version
poetry self add poetry-dynamic-versioning
pdm config --global venv.with_pip true
git config --global user.email "waketzheng@gmail.com"
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## 0.11

### [0.11.1](Unreleased)

- Support src/package structure for fast bump and fast tag

### [0.11.0](../../releases/tag/v0.10.0) - 2024-10-29

- Support uv
Expand Down
2 changes: 1 addition & 1 deletion fast_dev_cli/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.11.0"
__version__ = "0.11.1"
13 changes: 7 additions & 6 deletions fast_dev_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,13 @@ def read_version_from_file(
if work_dir is None:
work_dir = Project.get_work_dir()
package_dir = work_dir / package_name
init_file = package_dir / "__init__.py"
if not init_file.exists():
init_file = work_dir / "app" / init_file.name
if not init_file.exists():
secho("WARNING: __init__.py file does not exist!")
return "0.0.0"
if (
not (init_file := package_dir / "__init__.py").exists()
and not (init_file := work_dir / "src" / package_name / init_file.name).exists()
and not (init_file := work_dir / "app" / init_file.name).exists()
):
secho("WARNING: __init__.py file does not exist!")
return "0.0.0"
pattern = re.compile(r"__version__\s*=")
for line in init_file.read_text().splitlines():
if pattern.match(line):
Expand Down

0 comments on commit 2076ba1

Please sign in to comment.