Skip to content

Commit d63a5bd

Browse files
committed
restructed src according to installation using hatch
1 parent 1c1deb1 commit d63a5bd

6 files changed

Lines changed: 40 additions & 11 deletions

File tree

pyproject.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[build-system]
2+
requires = ["hatchling", "hatch-vcs"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "slithbot"
7+
dynamic = ["version"]
8+
license = "MIT"
9+
dependencies = [
10+
"numpy == 2.3.5",
11+
"pygame == 2.6.1",
12+
"pyyaml == 6.0.3"
13+
]
14+
15+
[tool.hatch.version]
16+
source = "vcs"
17+
18+
[project.scripts]
19+
slithbot-run = "slithbot.main:main" # main function within slithbot/main.py
20+
21+

requirements.txt

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

src/game.py renamed to src/slithbot/game.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import random
44
import numpy as np
55
from typing import List, Tuple, Dict, Optional
6-
from utils import *
6+
from slithbot.utils import *
77

88
# Colors
99
BACKGROUND = (45, 52, 54)
Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,23 @@
77
# Initialize Pygame
88
pygame.init()
99

10-
from game import SlitherGame
10+
from slithbot.game import SlitherGame
1111

1212
# from a supplied path, reads the config yaml, and returns a dict
1313
def load_config(config_path: str) -> dict:
1414
with open(Path(config_path)) as f:
1515
return yaml.safe_load(f)
1616

17-
def main(config_path: str):
17+
# this function will be called when the slithbot-run script will be executed from the terminal. argv will
18+
# hold all the argument values (including this script's name)
19+
def main():
20+
21+
argv = sys.argv
22+
# ensure that exactly one argument was supplied (so something like $slithbot-run config.yaml).
23+
if len(argv) != 2:
24+
raise Exception(f'\n Exactly 1 argument (location of config file) should be supplied to slithbot-run. You supplied {len(argv)-1} arguments! \n Example usage: \n $ slithbot-run config/base.yaml')
25+
26+
config_path = argv[1]
1827
config = load_config(config_path)
1928
game = SlitherGame(config)
2029

@@ -39,9 +48,10 @@ def main(config_path: str):
3948
game.close()
4049

4150

42-
if __name__ == "__main__":
43-
if len(sys.argv) != 2:
44-
print("Usage: python scripts/run_simulation.py <config.yaml>")
45-
sys.exit(1)
46-
main(sys.argv[1])
47-
# main(config_path='/Users/shashankkatiyar/Documents/github_repos/slithbot/config/base.yaml')
51+
# TO REMOVE
52+
# if __name__ == "__main__":
53+
# if len(sys.argv) != 2:
54+
# print("Usage: python scripts/run_simulation.py <config.yaml>")
55+
# sys.exit(1)
56+
# main(sys.argv[1])
57+
# # main(config_path='/Users/shashankkatiyar/Documents/github_repos/slithbot/config/base.yaml')
File renamed without changes.

0 commit comments

Comments
 (0)