fast-dev-cli 0.23.1__tar.gz → 0.23.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fast-dev-cli
3
- Version: 0.23.1
3
+ Version: 0.23.2
4
4
  Summary: Python project development tool.
5
5
  Author-Email: Waket Zheng <waketzheng@gmail.com>>
6
6
  Classifier: Development Status :: 4 - Beta
@@ -0,0 +1 @@
1
+ __version__ = "0.23.2"
@@ -148,15 +148,15 @@ class Shell:
148
148
  if isinstance(command, str):
149
149
  cs = shlex.split(command)
150
150
  if "shell" not in self._kw and not (set(self._cmd) & {"|", ">", "&"}):
151
- command = self.extend_user(cs)
151
+ command = self.expand_user(cs)
152
152
  elif any(i.startswith("~") for i in cs):
153
153
  command = re.sub(r" ~", " " + os.path.expanduser("~"), command)
154
154
  else:
155
- command = self.extend_user(command)
155
+ command = self.expand_user(command)
156
156
  return command
157
157
 
158
158
  @staticmethod
159
- def extend_user(cs: list[str]) -> list[str]:
159
+ def expand_user(cs: list[str]) -> list[str]:
160
160
  if cs[0] == "echo":
161
161
  return cs
162
162
  for i, c in enumerate(cs):
@@ -255,28 +255,18 @@ def read_version_from_file(
255
255
  secho(f"WARNING: can not find 'version' item in {version_file}!")
256
256
  return "0.0.0"
257
257
  pattern = re.compile(r"__version__\s*=")
258
- for line in Path(version_file).read_text("utf-8").splitlines():
258
+ all_lines = Path(version_file).read_text("utf-8").strip().splitlines()
259
+ for line in all_lines:
259
260
  if pattern.match(line):
260
261
  return _parse_version(line, pattern)
261
- # TODO: remove or refactor the following lines.
262
- if work_dir is None:
263
- work_dir = Project.get_work_dir()
264
- package_dir = work_dir / package_name
265
- if (
266
- not (init_file := package_dir / "__init__.py").exists()
267
- and not (init_file := work_dir / "src" / package_name / init_file.name).exists()
268
- and not (init_file := work_dir / "app" / init_file.name).exists()
269
- ):
270
- secho("WARNING: __init__.py file does not exist!")
262
+ else:
263
+ pattern = re.compile(r"VERSION\s*=")
264
+ for line in all_lines:
265
+ if pattern.match(line):
266
+ return _parse_version(line, pattern)
267
+ secho(f"WARNING: can not find version pattern in {version_file}!")
271
268
  return "0.0.0"
272
269
 
273
- pattern = re.compile(r"__version__\s*=")
274
- for line in init_file.read_text("utf-8").splitlines():
275
- if pattern.match(line):
276
- return _parse_version(line, pattern)
277
- secho(f"WARNING: can not find '__version__' var in {init_file}!")
278
- return "0.0.0"
279
-
280
270
 
281
271
  def _get_frontend_version() -> tuple[Path, str] | None:
282
272
  try:
@@ -438,7 +428,7 @@ class BumpUp(DryRun):
438
428
 
439
429
  @staticmethod
440
430
  def parse_dynamic_version(
441
- toml_text: str,
431
+ toml_text: str | None,
442
432
  context: dict[str, Any],
443
433
  work_dir: Path | None = None,
444
434
  ) -> str | None:
@@ -455,6 +445,8 @@ class BumpUp(DryRun):
455
445
  # version = { source = "file", path = "fast_dev_cli/__init__.py" }
456
446
  v_key = "version = "
457
447
  p_key = 'path = "'
448
+ if toml_text is None:
449
+ toml_text = Project.load_toml_text()
458
450
  for line in toml_text.splitlines():
459
451
  if not line.startswith(v_key):
460
452
  continue
@@ -470,10 +462,20 @@ class BumpUp(DryRun):
470
462
  toml_text: str | None = None,
471
463
  work_dir: Path | None = None,
472
464
  package_name: str | None = None,
465
+ context: dict | None = None,
473
466
  ) -> str:
474
- if toml_text is None:
475
- toml_text = Project.load_toml_text()
476
- context = tomllib.loads(toml_text)
467
+ if context is None:
468
+ if toml_text is None:
469
+ toml_text = Project.load_toml_text()
470
+ context = tomllib.loads(toml_text)
471
+ is_dynamic_version = False
472
+ with contextlib.suppress(KeyError):
473
+ if "version" in context["project"]["dynamic"]:
474
+ is_dynamic_version = True
475
+ if is_dynamic_version:
476
+ if filename := cls.parse_dynamic_version(toml_text, context, work_dir):
477
+ return filename
478
+ yellow_warn("Failed to find version file for this dynamic version project.")
477
479
  by_version_plugin = False
478
480
  try:
479
481
  ver = context["project"]["version"]
@@ -29,7 +29,7 @@ dependencies = [
29
29
  "typer>=0.24.0,<1",
30
30
  "tomli >=2.0.1,<3; python_version < '3.11'",
31
31
  ]
32
- version = "0.23.1"
32
+ version = "0.23.2"
33
33
 
34
34
  [project.urls]
35
35
  Homepage = "https://github.com/waketzheng/fast-dev-cli"
@@ -52,7 +52,8 @@ fast = "fast_dev_cli.cli:main"
52
52
 
53
53
  [dependency-groups]
54
54
  dev = [
55
- "asynctor>=0.10.0",
55
+ "asynctor>=0.13.0",
56
+ "httpx2>=2.5.0",
56
57
  ]
57
58
 
58
59
  [build-system]
@@ -1 +0,0 @@
1
- __version__ = "0.23.1"
File without changes
File without changes