Skip to content

Commit b099aad

Browse files
authored
Make pyproject.toml work with uv sync (#1942)
* Add uv-compatible pyproject.toml * Mention uv in readme * Adjust comment * Add bash syntax highlighting * Adjust grammar * Add uv run to README * Make black happy
1 parent 781b1d4 commit b099aad

File tree

11 files changed

+1250
-45
lines changed

11 files changed

+1250
-45
lines changed

README.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,29 @@ Your contribution will be greatly appreciated and help me continue to develop th
3030

3131

3232
### Project setup
33-
```
34-
pip3 install -r requirements.txt --user // Install python requirements
35-
yarn install // Install node requirements
36-
yarn dev // Compile typescript files to javascript
37-
yarn md // Compile md files to html
33+
```bash
34+
# Install python requirements
35+
pip3 install -r requirements.txt --user
36+
# Alternatively, use uv to install python requirements in a virtual env
37+
uv sync
38+
39+
yarn install # Install node requirements
40+
yarn dev # Compile typescript files to javascript
41+
yarn md # Compile md files to html
3842
```
3943

4044
### Start server
41-
```
45+
```bash
4246
python3 server/server.py
4347
```
48+
Or if `uv` is used
49+
```bash
50+
uv run server/server.py
51+
```
4452

4553
### Docker setup
4654
If you want to avoid installing dependencies (mongo, node, python) you can instead run the server locally in docker using compose. To start it, simply run:
47-
```
55+
```bash
4856
docker compose up --build
4957
```
5058
This recompiles the frontend and starts the server and DB. Once it is up, you can connect to `localhost:8080` in your browser.

pyproject.toml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,38 @@
1+
[project]
2+
name = "pychess-variants"
3+
version = "0.1.0"
4+
description = "Add your description here"
5+
readme = "README.md"
6+
requires-python = ">=3.13"
7+
dependencies = [
8+
"aiohttp==3.12.15",
9+
"aiohttp-jinja2==1.6",
10+
"aiohttp-remotes==1.3.0",
11+
"aiohttp-session==2.12.1",
12+
"aiohttp-sse==2.2.0",
13+
"aiomonitor==0.7.1",
14+
"black==25.1.0",
15+
"brotli==1.1.0",
16+
"cryptography==45.0.6",
17+
"discord-py==2.6.2",
18+
"dnspython==2.7.0",
19+
"flake8==7.3.0",
20+
"jinja2==3.1.6",
21+
"minify-html==0.16.4",
22+
"mongomock-motor==0.0.36",
23+
"motor==3.7.1",
24+
"mypy==1.17.1",
25+
"objgraph==3.6.2",
26+
"pre-commit>=4.3.0",
27+
"pyffish==0.0.88",
28+
"pyffish-alice==0.0.2",
29+
"pymongo==4.14.1",
30+
"pyopenssl==25.1.0",
31+
"python-gettext==5.0",
32+
"rustworkx==0.17.1",
33+
"sortedcollections==2.1.0",
34+
"tzdata==2025.2",
35+
]
36+
137
[tool.black]
238
line-length = 100

server/bugchess/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,7 @@ def __init__(
15941594
fen: Optional[str] = STARTING_FEN,
15951595
*,
15961596
chess960: bool = False,
1597-
board_id: Optional[int] = None
1597+
board_id: Optional[int] = None,
15981598
) -> None:
15991599
BaseBoard.__init__(self, None)
16001600

@@ -2543,7 +2543,7 @@ def chess960_pos(
25432543
*,
25442544
ignore_turn: bool = False,
25452545
ignore_castling: bool = False,
2546-
ignore_counters: bool = True
2546+
ignore_counters: bool = True,
25472547
) -> Optional[int]:
25482548
"""
25492549
Gets the Chess960 starting position index between 0 and 956
@@ -2648,7 +2648,7 @@ def epd(
26482648
shredder: bool = False,
26492649
en_passant: str = "legal",
26502650
promoted: Optional[bool] = None,
2651-
**operations: Union[None, str, int, float, Move, Iterable[Move]]
2651+
**operations: Union[None, str, int, float, Move, Iterable[Move]],
26522652
) -> str:
26532653
"""
26542654
Gets an EPD representation of the current position.

server/bugchess/converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def __init__(
3131
columns: Optional[int] = 80,
3232
headers: bool = True,
3333
comments: bool = True,
34-
variations: bool = True
34+
variations: bool = True,
3535
):
3636
self.columns = columns
3737
self.headers = headers

server/bugchess/engine.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def run_in_background(
160160
coroutine: "Callable[[concurrent.futures.Future[T]], Coroutine[Any, Any, None]]",
161161
*,
162162
debug: bool = False,
163-
_policy_lock: threading.Lock = threading.Lock()
163+
_policy_lock: threading.Lock = threading.Lock(),
164164
) -> T:
165165
"""
166166
Runs ``coroutine(future)`` in a new event loop on a background thread.
@@ -306,7 +306,7 @@ def __init__(
306306
black_clock: Optional[float] = None,
307307
white_inc: Optional[float] = None,
308308
black_inc: Optional[float] = None,
309-
remaining_moves: Optional[int] = None
309+
remaining_moves: Optional[int] = None,
310310
):
311311
self.time = time
312312
self.depth = depth
@@ -355,7 +355,7 @@ def __init__(
355355
info: Optional[InfoDict] = None,
356356
*,
357357
draw_offered: bool = False,
358-
resigned: bool = False
358+
resigned: bool = False,
359359
) -> None:
360360
self.move = move
361361
self.ponder = ponder
@@ -804,7 +804,7 @@ async def play(
804804
info: Info = INFO_NONE,
805805
ponder: bool = False,
806806
root_moves: Optional[Iterable[chess.Move]] = None,
807-
options: ConfigMapping = {}
807+
options: ConfigMapping = {},
808808
) -> PlayResult:
809809
"""
810810
Play a position.
@@ -840,7 +840,7 @@ async def analyse(
840840
game: object = None,
841841
info: Info = INFO_ALL,
842842
root_moves: Optional[Iterable[chess.Move]] = None,
843-
options: ConfigMapping = {}
843+
options: ConfigMapping = {},
844844
) -> Union[List[InfoDict], InfoDict]:
845845
"""
846846
Analyses a position and returns a dictionary of
@@ -893,7 +893,7 @@ async def analysis(
893893
game: object = None,
894894
info: Info = INFO_ALL,
895895
root_moves: Optional[Iterable[chess.Move]] = None,
896-
options: ConfigMapping = {}
896+
options: ConfigMapping = {},
897897
) -> "AnalysisResult":
898898
"""
899899
Starts analysing a position.
@@ -935,7 +935,7 @@ async def popen(
935935
*,
936936
setpgrp: bool = False,
937937
loop=None,
938-
**kwargs: Any
938+
**kwargs: Any,
939939
) -> Tuple[asyncio.SubprocessTransport, EngineProtocolT]:
940940
if not isinstance(command, list):
941941
command = [command]
@@ -1264,7 +1264,7 @@ def _go(
12641264
*,
12651265
root_moves: Optional[Iterable[chess.Move]] = None,
12661266
ponder: bool = False,
1267-
infinite: bool = False
1267+
infinite: bool = False,
12681268
) -> None:
12691269
builder = ["go"]
12701270
if ponder:
@@ -1312,7 +1312,7 @@ async def play(
13121312
info: Info = INFO_NONE,
13131313
ponder: bool = False,
13141314
root_moves: Optional[Iterable[chess.Move]] = None,
1315-
options: ConfigMapping = {}
1315+
options: ConfigMapping = {},
13161316
) -> PlayResult:
13171317
class Command(BaseCommand[UciProtocol, PlayResult]):
13181318
def start(self, engine: UciProtocol) -> None:
@@ -1415,7 +1415,7 @@ async def analysis(
14151415
game: object = None,
14161416
info: Info = INFO_ALL,
14171417
root_moves: Optional[Iterable[chess.Move]] = None,
1418-
options: Mapping[str, Union[str]] = {}
1418+
options: Mapping[str, Union[str]] = {},
14191419
) -> "AnalysisResult":
14201420
class Command(BaseCommand[UciProtocol, AnalysisResult]):
14211421
def start(self, engine: UciProtocol) -> None:
@@ -1898,7 +1898,7 @@ async def play(
18981898
info: Info = INFO_NONE,
18991899
ponder: bool = False,
19001900
root_moves: Optional[Iterable[chess.Move]] = None,
1901-
options: ConfigMapping = {}
1901+
options: ConfigMapping = {},
19021902
) -> PlayResult:
19031903
if root_moves is not None:
19041904
raise EngineError(
@@ -2070,7 +2070,7 @@ async def analysis(
20702070
game: object = None,
20712071
info: Info = INFO_ALL,
20722072
root_moves: Optional[Iterable[chess.Move]] = None,
2073-
options: ConfigMapping = {}
2073+
options: ConfigMapping = {},
20742074
) -> "AnalysisResult":
20752075
if multipv is not None:
20762076
raise EngineError("xboard engine does not support multipv")
@@ -2529,7 +2529,7 @@ def __init__(
25292529
transport: asyncio.SubprocessTransport,
25302530
protocol: EngineProtocol,
25312531
*,
2532-
timeout: Optional[float] = 10.0
2532+
timeout: Optional[float] = 10.0,
25332533
) -> None:
25342534
self.transport = transport
25352535
self.protocol = protocol
@@ -2600,7 +2600,7 @@ def play(
26002600
info: Info = INFO_NONE,
26012601
ponder: bool = False,
26022602
root_moves: Optional[Iterable[chess.Move]] = None,
2603-
options: ConfigMapping = {}
2603+
options: ConfigMapping = {},
26042604
) -> PlayResult:
26052605
with self._not_shut_down():
26062606
coro = asyncio.wait_for(
@@ -2627,7 +2627,7 @@ def analyse(
26272627
game: object = None,
26282628
info: Info = INFO_ALL,
26292629
root_moves: Optional[Iterable[chess.Move]] = None,
2630-
options: ConfigMapping = {}
2630+
options: ConfigMapping = {},
26312631
) -> Union[InfoDict, List[InfoDict]]:
26322632
with self._not_shut_down():
26332633
coro = asyncio.wait_for(
@@ -2654,7 +2654,7 @@ def analysis(
26542654
game: object = None,
26552655
info: Info = INFO_ALL,
26562656
root_moves: Optional[Iterable[chess.Move]] = None,
2657-
options: ConfigMapping = {}
2657+
options: ConfigMapping = {},
26582658
) -> "SimpleAnalysisResult":
26592659
with self._not_shut_down():
26602660
coro = asyncio.wait_for(
@@ -2701,7 +2701,7 @@ def popen(
27012701
timeout: Optional[float] = 10.0,
27022702
debug: bool = False,
27032703
setpgrp: bool = False,
2704-
**popen_args: Any
2704+
**popen_args: Any,
27052705
) -> "SimpleEngine":
27062706
async def background(future: "concurrent.futures.Future[SimpleEngine]") -> None:
27072707
transport, protocol = await Protocol.popen(command, setpgrp=setpgrp, **popen_args)
@@ -2725,7 +2725,7 @@ def popen_uci(
27252725
timeout: Optional[float] = 10.0,
27262726
debug: bool = False,
27272727
setpgrp: bool = False,
2728-
**popen_args: Any
2728+
**popen_args: Any,
27292729
) -> "SimpleEngine":
27302730
"""
27312731
Spawns and initializes an UCI engine.
@@ -2743,7 +2743,7 @@ def popen_xboard(
27432743
timeout: Optional[float] = 10.0,
27442744
debug: bool = False,
27452745
setpgrp: bool = False,
2746-
**popen_args: Any
2746+
**popen_args: Any,
27472747
) -> "SimpleEngine":
27482748
"""
27492749
Spawns and initializes an XBoard engine.

server/bugchess/pgn.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ def add_variation(
300300
*,
301301
comment: str = "",
302302
starting_comment: str = "",
303-
nags: Iterable[int] = ()
303+
nags: Iterable[int] = (),
304304
) -> "GameNode":
305305
"""Creates a child node with the given attributes."""
306306
node = type(self).dangling_node()
@@ -337,7 +337,7 @@ def add_line(
337337
*,
338338
comment: str = "",
339339
starting_comment: str = "",
340-
nags: Iterable[int] = ()
340+
nags: Iterable[int] = (),
341341
) -> "GameNode":
342342
"""
343343
Creates a sequence of child nodes for the given list of moves.
@@ -581,7 +581,7 @@ class Headers(MutableMapping[str, str]):
581581
def __init__(
582582
self,
583583
data: Optional[Union[Mapping[str, str], Iterable[Tuple[str, str]]]] = None,
584-
**kwargs: str
584+
**kwargs: str,
585585
) -> None:
586586
self._tag_roster = {} # type: Dict[str, str]
587587
self._others = {} # type: Dict[str, str]
@@ -1042,7 +1042,7 @@ def __init__(
10421042
columns: Optional[int] = 80,
10431043
headers: bool = True,
10441044
comments: bool = True,
1045-
variations: bool = True
1045+
variations: bool = True,
10461046
):
10471047
self.columns = columns
10481048
self.headers = headers
@@ -1186,7 +1186,7 @@ def __init__(
11861186
columns: Optional[int] = 80,
11871187
headers: bool = True,
11881188
comments: bool = True,
1189-
variations: bool = True
1189+
variations: bool = True,
11901190
):
11911191
super().__init__(columns=columns, headers=headers, comments=comments, variations=variations)
11921192
self.handle = handle

server/bugchess/polyglot.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ def __call__(self, board: chess.Board) -> int:
882882
def zobrist_hash(
883883
board: chess.Board,
884884
*,
885-
_hasher: Callable[[chess.Board], int] = ZobristHasher(POLYGLOT_RANDOM_ARRAY)
885+
_hasher: Callable[[chess.Board], int] = ZobristHasher(POLYGLOT_RANDOM_ARRAY),
886886
) -> int:
887887
"""
888888
Calculates the Polyglot Zobrist hash of the position.
@@ -993,7 +993,7 @@ def find_all(
993993
board: Union[chess.Board, int],
994994
*,
995995
minimum_weight: int = 1,
996-
exclude_moves: Container[chess.Move] = ()
996+
exclude_moves: Container[chess.Move] = (),
997997
) -> Iterator[Entry]:
998998
"""Seeks a specific position and yields corresponding entries."""
999999
try:
@@ -1039,7 +1039,7 @@ def find(
10391039
board: Union[chess.Board, int],
10401040
*,
10411041
minimum_weight: int = 1,
1042-
exclude_moves: Container[chess.Move] = ()
1042+
exclude_moves: Container[chess.Move] = (),
10431043
) -> Entry:
10441044
"""
10451045
Finds the main entry for the given position or Zobrist hash.
@@ -1068,7 +1068,7 @@ def get(
10681068
default: Optional[Entry] = None,
10691069
*,
10701070
minimum_weight: int = 1,
1071-
exclude_moves: Container[chess.Move] = ()
1071+
exclude_moves: Container[chess.Move] = (),
10721072
) -> Optional[Entry]:
10731073
try:
10741074
return self.find(board, minimum_weight=minimum_weight, exclude_moves=exclude_moves)
@@ -1081,7 +1081,7 @@ def choice(
10811081
*,
10821082
minimum_weight: int = 1,
10831083
exclude_moves: Container[chess.Move] = (),
1084-
random=random
1084+
random=random,
10851085
) -> Entry:
10861086
"""
10871087
Uniformly selects a random entry for the given position.
@@ -1106,7 +1106,7 @@ def weighted_choice(
11061106
board: Union[chess.Board, int],
11071107
*,
11081108
exclude_moves: Container[chess.Move] = (),
1109-
random=random
1109+
random=random,
11101110
) -> Entry:
11111111
"""
11121112
Selects a random entry for the given position, distributed by the

server/bugchess/svg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def board(
265265
size: Optional[int] = None,
266266
style: Optional[str] = None,
267267
base_svg: Optional[ET.Element] = None,
268-
add_definitions: bool = True
268+
add_definitions: bool = True,
269269
) -> str:
270270
"""
271271
Renders a board with pieces and/or selected squares as an SVG image.

server/bugchess/syzygy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3531,7 +3531,7 @@ def open_tablebase(
35313531
load_wdl: bool = True,
35323532
load_dtz: bool = True,
35333533
max_fds: Optional[int] = 128,
3534-
VariantBoard: Type[bugchess.Board] = bugchess.Board
3534+
VariantBoard: Type[bugchess.Board] = bugchess.Board,
35353535
) -> Tablebase:
35363536
"""
35373537
Opens a collection of tables for probing. See

0 commit comments

Comments
 (0)