From 5786e77258006da048bffd41b9e1cee66e42fc97 Mon Sep 17 00:00:00 2001 From: Solirs Date: Tue, 27 Jun 2023 15:44:15 +0200 Subject: [PATCH] Add proper build system and setuptools --- .gitignore | 162 ++++++++++++++++++++++++++++++++++++++- freefang/__init__.py | 0 freefang/freefang_net.py | 4 +- freefang/main.py | 10 +-- freefang/models.py | 2 +- freefang/server.py | 8 +- pyproject.toml | 3 + setup.py | 10 ++- 8 files changed, 182 insertions(+), 17 deletions(-) create mode 100644 freefang/__init__.py create mode 100644 pyproject.toml diff --git a/.gitignore b/.gitignore index 1306dd0..68bc17f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,160 @@ -/freefang/__pycache__ -/freefang/tests/gametest2.sh \ No newline at end of file +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ + +# PyCharm +# JetBrains specific template is maintained in a separate JetBrains.gitignore that can +# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +# and can be added to the global gitignore or merged into this file. For a more nuclear +# option (not recommended) you can uncomment the following to ignore the entire idea folder. +#.idea/ diff --git a/freefang/__init__.py b/freefang/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/freefang/freefang_net.py b/freefang/freefang_net.py index 19b333d..c4923b0 100644 --- a/freefang/freefang_net.py +++ b/freefang/freefang_net.py @@ -1,6 +1,6 @@ import struct -import freefang_utils as utils -import packets +import freefang.freefang_utils as utils +import freefang.packets as packets def readlength(con): # Read the length of the packet prepended to it unpack = con.recv(4) diff --git a/freefang/main.py b/freefang/main.py index 0de53fc..d703ed9 100644 --- a/freefang/main.py +++ b/freefang/main.py @@ -1,13 +1,13 @@ import socket import json -import models -import freefang_utils as utils -import freefang_net as net -import packets +import freefang.models as models +import freefang.freefang_utils as utils +import freefang.freefang_net as net +import freefang.packets as packets import uuid import threading import select -import roles +import freefang.roles as roles import time import struct import argparse diff --git a/freefang/models.py b/freefang/models.py index 2913466..136108a 100644 --- a/freefang/models.py +++ b/freefang/models.py @@ -2,7 +2,7 @@ try: from freefang.roles import * import freefang.freefang_net as fn - import freefang.packets + import freefang.packets as packets import freefang.freefang_utils as utils except ImportError: from roles import * diff --git a/freefang/server.py b/freefang/server.py index 2ba57f9..3ed9d70 100644 --- a/freefang/server.py +++ b/freefang/server.py @@ -1,13 +1,13 @@ import socket import json -import models -import freefang_utils as utils -import freefang_net as net +import freefang.models as models +import freefang.freefang_utils as utils +import freefang.freefang_net as net import packets import uuid import threading import select -import roles +import freefang.roles as roles import time import struct diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..ea4ae45 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools"] +build-backend = 'setuptools.build_meta' diff --git a/setup.py b/setup.py index 3c56638..c57645b 100644 --- a/setup.py +++ b/setup.py @@ -4,9 +4,13 @@ name='FreeFang', version='0.1.0', author='FreeFang Development Team', - description='', + description='A libre implementation of the Werewolf game, also known as Mafia.', packages=find_packages(), - install_requires=[ - ], + entry_points={ + 'console_scripts': [ + 'freefang-server = freefang.main:main', + ], + }, + )