Skip to content

Commit 478c93a

Browse files
committed
refactor: introduce bundled/libs/tool folders and move python source to src folder
this is to prepare the splitting of one big python package to several smaller packages, i.e. to install the robotcode.debugger standalone without other dependencies
1 parent c464edc commit 478c93a

File tree

131 files changed

+310
-123
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+310
-123
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,4 +290,6 @@ report.html
290290
.robotcode_cache/
291291

292292
# ruff
293-
.ruff_cache/
293+
.ruff_cache/
294+
295+
bundled/libs

.vscodeignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,6 @@ doc
5454

5555
.pre-commit-config.yaml
5656
.devcontainer
57+
58+
src
59+
bundled/libs/bin

bundled/tool/check_robot_version.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import os
2+
import pathlib
3+
import site
4+
import sys
5+
6+
7+
def update_sys_path(path_to_add: str, strategy: str) -> None:
8+
if path_to_add not in sys.path and pathlib.Path(path_to_add).is_dir():
9+
if any(p for p in pathlib.Path(path_to_add).iterdir() if p.suffix == ".pth"):
10+
site.addsitedir(path_to_add)
11+
return
12+
13+
if strategy == "useBundled":
14+
sys.path.insert(0, path_to_add)
15+
elif strategy == "fromEnvironment":
16+
sys.path.append(path_to_add)
17+
18+
19+
if __name__ == "__main__":
20+
# Ensure that we can import LSP libraries, and other bundled libraries.
21+
update_sys_path(
22+
os.fspath(pathlib.Path(__file__).parent.parent / "libs"),
23+
os.getenv("LS_IMPORT_STRATEGY", "useBundled"),
24+
)
25+
26+
# Run the language server.
27+
from robotcode.language_server.robotframework.utils.version import get_robot_version
28+
29+
print(get_robot_version() >= (4, 0))
File renamed without changes.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import os
2+
import pathlib
3+
import site
4+
import sys
5+
6+
7+
def update_sys_path(path_to_add: str, strategy: str) -> None:
8+
if path_to_add not in sys.path and pathlib.Path(path_to_add).is_dir():
9+
if any(p for p in pathlib.Path(path_to_add).iterdir() if p.suffix == ".pth"):
10+
site.addsitedir(path_to_add)
11+
return
12+
13+
if strategy == "useBundled":
14+
sys.path.insert(0, path_to_add)
15+
elif strategy == "fromEnvironment":
16+
sys.path.append(path_to_add)
17+
18+
19+
if __name__ == "__main__":
20+
# Ensure that we can import LSP libraries, and other bundled libraries.
21+
update_sys_path(
22+
os.fspath(pathlib.Path(__file__).parent.parent.parent.parent / "libs"),
23+
os.getenv("LS_IMPORT_STRATEGY", "useBundled"),
24+
)
25+
26+
from robotcode.debugger.launcher.cli import main
27+
28+
main()
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import os
2+
import pathlib
3+
import site
4+
import sys
5+
6+
7+
def update_sys_path(path_to_add: str, strategy: str) -> None:
8+
if path_to_add not in sys.path and pathlib.Path(path_to_add).is_dir():
9+
if any(p for p in pathlib.Path(path_to_add).iterdir() if p.suffix == ".pth"):
10+
site.addsitedir(path_to_add)
11+
return
12+
13+
if strategy == "useBundled":
14+
sys.path.insert(0, path_to_add)
15+
elif strategy == "fromEnvironment":
16+
sys.path.append(path_to_add)
17+
18+
19+
if __name__ == "__main__":
20+
# Ensure that we can import LSP libraries, and other bundled libraries.
21+
update_sys_path(
22+
os.fspath(pathlib.Path(__file__).parent.parent.parent / "libs"),
23+
os.getenv("LS_IMPORT_STRATEGY", "useBundled"),
24+
)
25+
26+
# Run the language server.
27+
from robotcode.language_server.cli import main
28+
29+
main()

pyproject.toml

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ rest = ["docutils"]
7272

7373

7474
[tool.hatch.version]
75-
path = "robotcode/__version__.py"
75+
path = "src/robotcode/__version__.py"
7676

7777

7878
[tool.hatch.build.targets.sdist]
79-
only-include = ["robotcode", "CHANGELOG.md"]
79+
only-include = ["src", "CHANGELOG.md"]
8080

8181

8282
[tool.hatch.envs.default]
@@ -177,19 +177,10 @@ build_command = "pip install hatch && hatch build"
177177
[tool.black]
178178
line-length = 120
179179
target-version = ['py38']
180-
exclude = '''
180+
extend-exclude = '''
181181
(
182182
/(
183-
\.eggs # exclude a few common directories in the
184-
| \.git # root of the project
185-
| \.mypy_cache
186-
| \.tox
187-
| \.venv
188-
| \.hatch
189-
| build
190-
| dist
191-
| out
192-
| playground
183+
| bundled/libs
193184
)/
194185
)
195186
'''
@@ -225,27 +216,9 @@ fail_under = 40
225216
[tool.ruff]
226217
line-length = 120
227218
target-version = "py38"
228-
exclude = [
229-
".bzr",
230-
".direnv",
231-
".eggs",
232-
".git",
233-
".hg",
234-
".mypy_cache",
235-
".nox",
236-
".pants.d",
237-
".ruff_cache",
238-
".svn",
239-
".tox",
240-
".venv",
241-
"__pypackages__",
242-
"_build",
243-
"buck-out",
244-
"build",
245-
"dist",
246-
"node_modules",
247-
"venv",
248-
".hatch",
219+
src = ["src"]
220+
extend-exclude = [
221+
"bundled/libs",
249222
]
250223
ignore = ["E741", "N805", "N999"]
251224
select = [
@@ -295,7 +268,7 @@ select = [
295268

296269
[tool.mypy]
297270
python_version = 3.8
298-
271+
pretty = true
299272
strict = true
300273
warn_redundant_casts = true
301274
warn_unused_ignores = true
@@ -314,6 +287,7 @@ exclude = [
314287
"out",
315288
"playground",
316289
"scripts",
290+
"bundled/libs",
317291
]
318292

319293

robotcode/analyzer/__main__.py

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

0 commit comments

Comments
 (0)