fast-dev-cli 0.24.3__tar.gz → 0.25.0__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.24.3
3
+ Version: 0.25.0
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.25.0"
@@ -1230,50 +1230,54 @@ class LintCode(DryRun):
1230
1230
  should_run_by_tool = with_prefix
1231
1231
  requires_mypy = any(tool.startswith("mypy") for tool in tools)
1232
1232
  global_mypy = False
1233
- if requires_mypy and Path.home().joinpath(".local/bin/mypy").exists():
1234
- global_mypy = True
1235
- mypy_opt = "--python-executable=.venv/bin/python"
1236
- for i, t in enumerate(tools):
1237
- if t.startswith("mypy"):
1238
- if mypy_opt not in t:
1239
- tools[i] = t + " " + mypy_opt
1240
- break
1241
- if requires_mypy and not should_run_by_tool:
1242
- if is_venv() and Path(sys.argv[0]).parent != Path.home().joinpath(
1243
- ".local/bin"
1244
- ): # Virtual environment activated and fast-dev-cli is installed in it
1245
- if not ruff_exists:
1246
- should_run_by_tool = True
1247
- command = "pipx install ruff"
1248
- if shutil.which("pipx") is None:
1249
- ensure_pipx = "pip install --user pipx\n pipx ensurepath\n "
1250
- command = ensure_pipx + command
1251
- elif prefer_uv_tool():
1252
- command = "uv tool install ruff"
1253
- yellow_warn(
1254
- "You may need to run the following command"
1255
- f" to install ruff:\n\n {command}\n"
1256
- )
1257
- elif global_mypy:
1258
- should_run_by_tool = True
1259
- elif cls.missing_mypy_exec():
1260
- should_run_by_tool = True
1261
- if check_call('python -c "import fast_dev_cli"'):
1262
- command = "python -m pip install -U mypy"
1233
+ if requires_mypy:
1234
+ # TODO: move this long logic to a single function
1235
+ local_bin = Path.home().joinpath(".local/bin")
1236
+ if local_bin.joinpath("mypy").exists():
1237
+ global_mypy = True
1238
+ mypy_opt = "--python-executable=.venv/bin/python"
1239
+ for i, t in enumerate(tools):
1240
+ if t.startswith("mypy"):
1241
+ if mypy_opt not in t:
1242
+ tools[i] = t + " " + mypy_opt
1243
+ break
1244
+ if not should_run_by_tool:
1245
+ if is_venv() and Path(sys.argv[0]).parent != local_bin:
1246
+ # Virtual environment activated and fast-dev-cli is installed in it
1247
+ if not ruff_exists:
1248
+ should_run_by_tool = True
1249
+ command = "pipx install ruff"
1250
+ if shutil.which("pipx") is None:
1251
+ ensure_pipx = (
1252
+ "pip install --user pipx\n pipx ensurepath\n "
1253
+ )
1254
+ command = ensure_pipx + command
1255
+ elif prefer_uv_tool():
1256
+ command = "uv tool install ruff"
1263
1257
  yellow_warn(
1264
1258
  "You may need to run the following command"
1265
- f" to install lint tools:\n\n {command}\n"
1259
+ f" to install ruff:\n\n {command}\n"
1266
1260
  )
1267
- elif tool == ToolOption.default:
1268
- root = Project.get_work_dir(allow_cwd=True)
1269
- if py := shutil.which("python"):
1270
- try:
1271
- Path(py).relative_to(root)
1272
- except ValueError:
1273
- # Virtual environment not activated
1261
+ elif global_mypy:
1274
1262
  should_run_by_tool = True
1275
- else:
1276
- should_run_by_tool = True
1263
+ elif cls.missing_mypy_exec():
1264
+ should_run_by_tool = True
1265
+ if check_call('python -c "import fast_dev_cli"'):
1266
+ command = "python -m pip install -U mypy"
1267
+ yellow_warn(
1268
+ "You may need to run the following command"
1269
+ f" to install lint tools:\n\n {command}\n"
1270
+ )
1271
+ elif tool == ToolOption.default:
1272
+ root = Project.get_work_dir(allow_cwd=True)
1273
+ if py := shutil.which("python"):
1274
+ try:
1275
+ Path(py).relative_to(root)
1276
+ except ValueError:
1277
+ # Virtual environment not activated
1278
+ should_run_by_tool = True
1279
+ else:
1280
+ should_run_by_tool = True
1277
1281
  if should_run_by_tool and tool:
1278
1282
  if tool == ToolOption.default:
1279
1283
  tool = Project.get_manage_tool() or ""
@@ -1581,18 +1585,34 @@ class Publish:
1581
1585
  twine = "python -m build && twine upload"
1582
1586
 
1583
1587
  @classmethod
1584
- def gen(cls) -> str:
1585
- if tool := Project.get_manage_tool():
1588
+ def gen(cls, tool: str, verbose: bool) -> str:
1589
+ if tool == "auto":
1590
+ tool = Project.get_manage_tool() or ""
1591
+ if tool:
1592
+ if tool == "uv":
1593
+ envs = ["UV_PUBLISH_INDEX", "UV_PUBLISH_URL", "UV_PUBLISH_TOKEN"]
1594
+ if not any(os.getenv(i) for i in envs):
1595
+ if verbose:
1596
+ yellow_warn(f"Skip uv publish as envs ({envs}) not set")
1597
+ return "uv build"
1598
+ elif tool == "pdm":
1599
+ env = "PDM_PUBLISH_REPO"
1600
+ if not os.getenv(env):
1601
+ if verbose:
1602
+ yellow_warn(f"Skip pdm publish as env ({env}) not set")
1603
+ return "pdm build"
1586
1604
  return cls.CommandEnum[tool]
1587
1605
  return cls.CommandEnum.twine
1588
1606
 
1589
1607
 
1590
1608
  @cli.command()
1591
1609
  def upload(
1610
+ verbose: bool = False,
1611
+ tool: str = ToolOption,
1592
1612
  dry: bool = DryOption,
1593
1613
  ) -> None:
1594
1614
  """Shortcut for package publish"""
1595
- cmd = Publish.gen()
1615
+ cmd = Publish.gen(tool, verbose)
1596
1616
  exit_if_run_failed(cmd, dry=dry)
1597
1617
 
1598
1618
 
@@ -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.24.3"
32
+ version = "0.25.0"
33
33
 
34
34
  [project.urls]
35
35
  Homepage = "https://github.com/waketzheng/fast-dev-cli"
@@ -1 +0,0 @@
1
- __version__ = "0.24.3"
File without changes
File without changes