Skip to content

Commit 2579888

Browse files
authored
pyminimal: rework
1 parent d784082 commit 2579888

18 files changed

Lines changed: 606 additions & 114 deletions

File tree

3rdparty/python/black.lock

Lines changed: 513 additions & 0 deletions
Large diffs are not rendered by default.

3rdparty/python/default.lock

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
// This lockfile was autogenerated by Pants. To regenerate, run:
22
//
3-
// ./pants generate-lockfiles --resolve=python-default
3+
// pants generate-lockfiles --resolve=python-default
44
//
55
// --- BEGIN PANTS LOCKFILE METADATA: DO NOT EDIT OR REMOVE ---
66
// {
7-
// "version": 2,
7+
// "version": 3,
88
// "valid_for_interpreter_constraints": [
99
// "CPython>=3.7"
1010
// ],
11-
// "generated_with_requirements": []
11+
// "generated_with_requirements": [],
12+
// "manylinux": "manylinux2014",
13+
// "requirement_constraints": [],
14+
// "only_binary": [],
15+
// "no_binary": []
1216
// }
1317
// --- END PANTS LOCKFILE METADATA ---
1418

@@ -18,14 +22,10 @@
1822
"allow_wheels": true,
1923
"build_isolation": true,
2024
"constraints": [],
21-
"locked_resolves": [
22-
{
23-
"locked_requirements": [],
24-
"platform_tag": null
25-
}
26-
],
25+
"locked_resolves": [],
2726
"path_mappings": {},
28-
"pex_version": "2.1.102",
27+
"pex_version": "2.1.137",
28+
"pip_version": "23.1.2",
2929
"prefer_older_binary": false,
3030
"requirements": [],
3131
"requires_python": [

3rdparty/python/isort.lock

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

BUILD.pants

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ pex_binary(
22
name="pyminimal",
33
entry_point="plugins/pyminimal.py",
44
dependencies=[
5-
"plugins/pyminimal.py",
5+
"plugins/pyminimal.py:sources",
66
"tmpy:sources",
77
],
88
)
@@ -58,3 +58,9 @@ pex_binary(
5858
dependencies=["tmpy:sources", "tmpy/sympy:sources"],
5959
resolve="sympy_req",
6060
)
61+
62+
python_requirement(
63+
name="black",
64+
requirements=["black==22.1.0", "click<8.1"],
65+
resolve="black",
66+
)

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ bin/lint
2020
bin/format
2121

2222
# For other GNU TeXmacs distributions like Mogan Research
23-
TEXMACS_HOME_PATH=~/.Xmacs ./pants run cli:install -- pymarkup
23+
# you can make a symbol link
24+
25+
# macOS
26+
ln -s $HOME/.TeXmacs/plugins $HOME/Library/Application\ Support/XmacsLabs/
27+
# Linux
28+
ln -s $HOME/.TeXmacs/plugins $HOME/.local/share/XmacsLabs/
2429
```
2530
## Contributing
2631
Please report bugs to the GNU TeXmacs [forum](http://forum.texmacs.cn/c/devel/pluginsinpython) for this project.

cli/install.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ def install(name):
2222
print(f"Removing existing {str(plugin)}")
2323
shutil.rmtree(str(plugin))
2424

25-
print(f"Packaging: ./pants package //:{name}")
26-
subprocess.run(["./pants", "package", f"//:{name}"])
25+
print(f"Packaging: pants package //:{name}")
26+
subprocess.run(["pants", "package", f"//:{name}"])
2727

2828
print(f"Installing: {str(plugin)}")
2929
shutil.copytree(f"plugins/{name}", str(plugin))

pants.toml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@ concurrent = true
77

88
backend_packages = [
99
"pants.backend.python",
10-
"pants.backend.python.lint.docformatter",
1110
"pants.backend.python.lint.black",
12-
"pants.backend.python.lint.flake8",
13-
"pants.backend.python.lint.isort",
1411
]
1512

1613
[source]
@@ -33,8 +30,8 @@ enable_resolves = true
3330
[python.resolves]
3431
sympy_req = "3rdparty/python/sympy.lock"
3532
python-default = "3rdparty/python/default.lock"
36-
isort = "3rdparty/python/isort.lock"
33+
black= "3rdparty/python/black.lock"
3734

38-
[isort]
39-
args = ["--profile black", "--order-by-type"]
40-
install_from_resolve = "isort"
35+
[black]
36+
install_from_resolve = "black"
37+
requirements= ["//:black"]

plugins/BUILD.pants

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ python_requirement(
44
resolve="sympy_req",
55
)
66

7-
python_sources()
7+
python_sources(name="sources", resolve="python-default")

plugins/graphviz.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,23 @@
88
# It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
99
# in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
1010

11-
from tmpy.graph.graphviz import Graphviz
1211
from tmpy.protocol import DATA_COMMAND, flush_prompt, flush_verbatim
1312

13+
from tmpy.graph.graphviz import Graphviz
14+
1415
graphs = list(
1516
map(
1617
lambda x: Graphviz(x),
17-
["dot", "neato", "twopi", "circo", "fdp", "sfdp", "patchwork", "osage"],
18+
[
19+
"dot",
20+
"neato",
21+
"twopi",
22+
"circo",
23+
"fdp",
24+
"sfdp",
25+
"patchwork",
26+
"osage",
27+
],
1828
)
1929
)
2030
graph_names = list(map(lambda x: x.name, graphs))
@@ -62,7 +72,9 @@ def unigraph(text):
6272
if text.startswith("%"):
6373
unigraph(text)
6474
elif text == "help":
65-
flush_verbatim("[help, " + ", ".join(str(x) for x in graph_names) + "]\n")
75+
flush_verbatim(
76+
"[help, " + ", ".join(str(x) for x in graph_names) + "]\n"
77+
)
6678
current.greet()
6779
elif text in graph_names:
6880
current = graphs[graph_names.index(text)]

plugins/pyminimal/progs/init-pyminimal.scm

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,18 @@
1313

1414
(define (python-launcher)
1515
(if (url-exists? "$TEXMACS_HOME_PATH/plugins/pyminimal")
16-
(string-append "python3 " (getenv "TEXMACS_HOME_PATH")
17-
"/plugins/pyminimal/bin/pyminimal.pex")
18-
(string-append "python3 " (getenv "TEXMACS_PATH")
19-
"/plugins/pyminimal/bin/pyminimal.pex")))
16+
(string-append "python3 "
17+
(string-quote
18+
(url->string
19+
(string->url
20+
"$TEXMACS_HOME_PATH/plugins/pyminimal/bin/pyminimal.pex"))))
21+
(string-append "python3 "
22+
(string-quote
23+
(url->string
24+
(string->url
25+
"$TEXMACS_PATH/plugins/pyminimal/bin/pyminimal.pex"))))))
2026

2127
(plugin-configure pyminimal
22-
(:require (url-exists-in-path? "python"))
28+
(:require (url-exists-in-path? "python3"))
2329
(:launch ,(python-launcher))
2430
(:session "PyMinimal"))

0 commit comments

Comments
 (0)