mirror of
https://github.com/kristoferssolo/Tetris.git
synced 2025-10-21 20:00:35 +00:00
feat: make installable
This commit is contained in:
parent
eefa176228
commit
fa31b192e7
@ -1,20 +1,36 @@
|
||||
[build-system]
|
||||
requires = ["setuptools>=42.0", "wheel"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "tetris"
|
||||
version = "0.1.0"
|
||||
description = "Tetris game with AI"
|
||||
description = "Tetris game"
|
||||
authors = [{ name = "Kristofers Solo", email = "dev@kristofers.xyz" }]
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.11"
|
||||
license = { text = "GPLv3" }
|
||||
license = { file = "LICENSE" }
|
||||
dependencies = [
|
||||
"attrs==23.1.0",
|
||||
"loguru==0.7.2",
|
||||
"neat-python==0.92",
|
||||
"numpy==1.26.3",
|
||||
"pygame-ce==2.4.0",
|
||||
"toml==0.10.2",
|
||||
]
|
||||
keywords = ["tetris", "game", "pygame"]
|
||||
classifiers = [
|
||||
"Development Status :: 3 - Alpha",
|
||||
"License :: OSI Approved :: GPLv3 License",
|
||||
"Programming Language :: Python :: 3 :: Only",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
"Programming Language :: Python :: 3.12",
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
Repository = "https://github.com/kristoferssolo/Tetris"
|
||||
|
||||
[tool.mypy]
|
||||
mypy_path = "src"
|
||||
check_untyped_defs = true
|
||||
disallow_any_generics = true
|
||||
ignore_missing_imports = true
|
||||
@ -32,7 +48,8 @@ line-length = 120
|
||||
indent-width = 4
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = ["I"]
|
||||
extend-select = ["I"]
|
||||
preview = true
|
||||
|
||||
[tool.ruff.format]
|
||||
quote-style = "double"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
attrs>=23.1.0
|
||||
loguru>=0.7.2
|
||||
neat-python>=0.92
|
||||
numpy>=1.26.3
|
||||
pygame-ce>=2.4.0
|
||||
attrs==23.1.0
|
||||
loguru==0.7.2
|
||||
numpy==1.26.3
|
||||
pygame-ce==2.4.0
|
||||
toml==0.10.2
|
||||
.
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
mypy>=1.8.0
|
||||
pytest>=7.4.3
|
||||
ruff>=0.1.9
|
||||
mypy==1.8.0
|
||||
pytest==7.4.3
|
||||
ruff==0.1.9
|
||||
|
||||
0
tetris/__init__.py
Normal file
0
tetris/__init__.py
Normal file
75
tetris/__main__.py
Normal file
75
tetris/__main__.py
Normal file
@ -0,0 +1,75 @@
|
||||
#!/usr/bin/env python
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
from loguru import logger
|
||||
|
||||
parser = argparse.ArgumentParser(description="Tetris game with AI")
|
||||
group = parser.add_mutually_exclusive_group()
|
||||
group.add_argument(
|
||||
"-d",
|
||||
"--debug",
|
||||
action="store_true",
|
||||
help="Debug",
|
||||
)
|
||||
|
||||
group.add_argument(
|
||||
"-v",
|
||||
"--verbose",
|
||||
action="store_true",
|
||||
help="Verbose",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"-g",
|
||||
"--graphic",
|
||||
action="store_true",
|
||||
help="Run app with GUI [Default]",
|
||||
)
|
||||
|
||||
|
||||
def setup_logger(level: str = "warning") -> None:
|
||||
from utils import BASE_PATH
|
||||
|
||||
logger.remove()
|
||||
logger.add(
|
||||
sink=sys.stdout,
|
||||
format="<green>{time}</green> | <level>{level}</level> | <level>{message}</level>",
|
||||
level=level.upper(),
|
||||
colorize=True,
|
||||
)
|
||||
|
||||
logger.add(
|
||||
BASE_PATH / ".logs" / "teris.log",
|
||||
format="{time} | {level} | {message}",
|
||||
level="DEBUG" if level.upper() == "DEBUG" else "INFO",
|
||||
rotation="10 MB",
|
||||
compression="zip",
|
||||
)
|
||||
|
||||
|
||||
@logger.catch
|
||||
def run() -> None:
|
||||
import game
|
||||
from utils import GameMode
|
||||
|
||||
logger.debug("Launching the game")
|
||||
game.Main(GameMode.PLAYER).run()
|
||||
|
||||
|
||||
def main(args: argparse.ArgumentParser) -> None:
|
||||
if args.debug:
|
||||
level = "debug"
|
||||
elif args.verbose:
|
||||
level = "info"
|
||||
else:
|
||||
level = "warning"
|
||||
|
||||
setup_logger(level)
|
||||
|
||||
run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = parser.parse_args()
|
||||
main(args)
|
||||
Loading…
Reference in New Issue
Block a user