Skip to content

Commit b37a87c

Browse files
committed
Fix saving dumped config if target dir doesn't exist. Add create_dir method in ifilemanager. Install dependency in dev_workspace env also if they exist already
1 parent 9bfcbd4 commit b37a87c

12 files changed

Lines changed: 138 additions & 60 deletions

File tree

.python-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ With FineCode you can:
2323
dev_workspace = ["finecode==0.2.*"]
2424
```
2525

26-
1.1.2 Create dev_workspace venv: `python -m venv .venvs/dev_workspace` (https://docs.python.org/3/library/venv.html#creating-virtual-environments )
26+
1.1.2 Create dev_workspace venv: `python -m venv .venvs/dev_workspace` ([Python Docs](https://docs.python.org/3/library/venv.html#creating-virtual-environments ))
2727

2828
1.1.3 Activate this venv and install dependencies from `dev_workspace` group:
2929
```
@@ -45,10 +45,10 @@ NOTE: `pip install` supports `--group` parameter since pip 25.1. Make sure you h
4545

4646
For list of presets from FineCode authors see 'Presets' section below.
4747

48-
1.2.1 Run `prepare_env` finecode action:
48+
1.2.1 Run `prepare_envs` finecode command:
4949

5050
```bash
51-
python -m finecode run prepare_env
51+
python -m finecode prepare_envs
5252
```
5353

5454
1.3 Enable finecode and preset

extensions/fine_python_pip/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ requires-python = ">=3.11, < 3.14"
88
dependencies = ["finecode_extension_api==0.1.0"]
99

1010
[dependency-groups]
11-
dev_workspace = ["finecode==0.2.0"]
11+
dev_workspace = ["finecode==0.2.*"]
1212
dev_no_runtime = ["finecode_dev_common_preset==0.1.*"]
1313

1414
[tool.finecode]

extensions/fine_python_virtualenv/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies = [
1111
]
1212

1313
[dependency-groups]
14-
dev_workspace = ["finecode==0.2.0"]
14+
dev_workspace = ["finecode==0.2.*"]
1515
dev_no_runtime = ["finecode_dev_common_preset==0.1.*"]
1616

1717
[tool.finecode]

finecode_extension_api/src/finecode_extension_api/interfaces/ifilemanager.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,6 @@ async def get_file_version(self, file_path: Path) -> str:
1010
...
1111

1212
async def save_file(self, file_path: Path, file_content) -> None: ...
13+
14+
async def create_dir(self, dir_path: Path, create_parents: bool = True, exist_ok: bool = True):
15+
...

poetry.toml

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

pyproject.toml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
[project]
22
name = "finecode"
3-
version = "0.2.0"
4-
# dynamic version from setuptools-scm is not compatible with poetry, because it requires explicit version in pyproject.toml. Will be used after migration from poetry.
5-
# dynamic = ["version"]
3+
dynamic = ["version"]
64
description = ""
75
authors = [{ name = "Vladyslav Hnatiuk", email = "aders1234@gmail.com" }]
86
readme = "README.md"
@@ -17,10 +15,17 @@ dependencies = [
1715
"pygls==2.0.0-a2",
1816
"finecode_extension_api==0.1.0",
1917
"ordered-set==4.1.*",
18+
"mcp==1.9.*",
19+
"fine_python_virtualenv @ git+https://github.com/finecode-dev/finecode.git#subdirectory=extensions/fine_python_virtualenv",
20+
"fine_python_pip @ git+https://github.com/finecode-dev/finecode.git#subdirectory=extensions/fine_python_pip",
2021
]
2122

2223
[dependency-groups]
23-
dev_workspace = ["build==1.2.2.post1"]
24+
dev_workspace = ["build==1.2.2.post1", "finecode==0.2.*"]
25+
dev = [{ include-group = "runtime" }, "pytest==7.4.*", "debugpy==1.8.*"]
26+
dev_no_runtime = [
27+
"fine_python_import_linter @ git+https://github.com/finecode-dev/finecode.git#subdirectory=extensions/fine_python_import_linter",
28+
]
2429

2530
[build-system]
2631
requires = ["setuptools>=64", "setuptools-scm>=8"]
@@ -29,13 +34,8 @@ build-backend = "setuptools.build_meta"
2934
[tool.poetry]
3035
packages = [{ include = "finecode", from = "src" }]
3136

32-
[tool.poetry.group.dev.dependencies]
33-
pytest = "^7.4.3"
34-
finecode_dev_common_preset = { path = "./finecode_dev_common_preset", develop = true }
35-
fine_python_import_linter = { git = "https://github.com/finecode-dev/finecode.git", subdirectory = "extensions/fine_python_import_linter" }
36-
anyio = "^4.4.0"
37-
debugpy = "^1.8.9"
38-
37+
# TODO: intall finecode_dev_common_preset as a dependency from local path using finecode?
38+
# TODO: add import linter handler to lint action
3939

4040
[tool.finecode]
4141
presets = [{ source = "finecode_dev_common_preset" }]

src/finecode/extension_runner/action_handlers/dump_config_save.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ async def run(
2424
self, payload: dump_config_action.DumpConfigRunPayload, run_context: dump_config_action.DumpConfigRunContext
2525
) -> dump_config_action.DumpConfigRunResult:
2626
raw_config_str = tomlkit.dumps(run_context.raw_config_dump)
27+
target_file_dir_path = payload.target_file_path.parent
2728

29+
await self.file_manager.create_dir(dir_path=target_file_dir_path)
2830
await self.file_manager.save_file(
2931
file_path=payload.target_file_path, file_content=raw_config_str
3032
)

src/finecode/extension_runner/cli.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
from pathlib import Path
3+
from importlib import metadata
34

45
import click
56
from loguru import logger
@@ -8,7 +9,13 @@
89
from finecode.extension_runner import global_state
910

1011

11-
@click.command()
12+
@click.group()
13+
def main():
14+
"""FineCode Extension Runner CLI"""
15+
pass
16+
17+
18+
@main.command()
1219
@click.option("--trace", "trace", is_flag=True, default=False)
1320
@click.option("--debug", "debug", is_flag=True, default=False)
1421
@click.option("--debug-port", "debug_port", type=int, default=5680)
@@ -19,7 +26,7 @@
1926
required=True,
2027
)
2128
@click.option("--env-name", "env_name", type=str, default="unknown")
22-
def main(trace: bool, debug: bool, debug_port: int, project_path: Path, env_name: str):
29+
def start(trace: bool, debug: bool, debug_port: int, project_path: Path, env_name: str):
2330
if debug is True:
2431
import debugpy
2532

@@ -40,5 +47,12 @@ def main(trace: bool, debug: bool, debug_port: int, project_path: Path, env_name
4047
runner_start.start_runner_sync(env_name)
4148

4249

50+
@main.command()
51+
def version():
52+
"""Show version information"""
53+
package_version = metadata.version('finecode')
54+
click.echo(f'FineCode Extension Runner {package_version}')
55+
56+
4357
if __name__ == "__main__":
4458
main()

src/finecode/extension_runner/impls/file_manager.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ async def save_file(self, file_path: Path, file_content: str) -> None:
7575
with open(file_path, "w") as f:
7676
f.write(file_content)
7777

78+
async def create_dir(self, dir_path: Path, create_parents: bool = True, exist_ok: bool = True):
79+
# currently only local file system is supported
80+
dir_path.mkdir(parents=create_parents, exist_ok=exist_ok)
81+
7882
# helper methods
7983
def read_content_file_from_fs(self, file_path: Path) -> str:
8084
# don't use this method directly, use `get_content` instead

0 commit comments

Comments
 (0)