From 36e8fea1eceb4687217918f5328251a9a59f2f68 Mon Sep 17 00:00:00 2001 From: "Wu, Zhenyu" Date: Tue, 9 Apr 2024 16:08:05 +0800 Subject: [PATCH] :package: Publish this project to PYPI --- .gitignore | 126 ++++++++++++++++++ README.md | 5 +- main.py | 6 - pyproject.toml | 55 ++++++++ {source => super_mario}/__init__.py | 0 source/main.py => super_mario/__main__.py | 4 + .../components/__init__.py | 0 {source => super_mario}/components/box.py | 0 {source => super_mario}/components/brick.py | 0 {source => super_mario}/components/coin.py | 0 {source => super_mario}/components/enemy.py | 0 {source => super_mario}/components/info.py | 0 {source => super_mario}/components/player.py | 2 +- {source => super_mario}/components/powerup.py | 0 {source => super_mario}/components/stuff.py | 0 {source => super_mario}/constants.py | 0 .../data/maps/level_1.json | 0 .../data/maps/level_2.json | 0 .../data/maps/level_3.json | 0 .../data/maps/level_4.json | 0 .../data/player/luigi.json | 0 .../data/player/mario.json | 0 .../resources}/graphics/enemies.png | Bin .../resources}/graphics/item_objects.png | Bin .../resources}/graphics/level_1.png | Bin .../resources}/graphics/level_2.png | Bin .../resources}/graphics/level_3.png | Bin .../resources}/graphics/level_4.png | Bin .../resources}/graphics/mario_bros.png | Bin .../resources}/graphics/smb_enemies_sheet.png | Bin .../resources}/graphics/text_images.png | Bin .../resources}/graphics/tile_set.png | Bin .../resources}/graphics/title_screen.png | Bin {source => super_mario}/setup.py | 2 +- {source => super_mario}/states/__init__.py | 0 {source => super_mario}/states/level.py | 2 +- {source => super_mario}/states/load_screen.py | 0 {source => super_mario}/states/main_menu.py | 0 {source => super_mario}/tools.py | 0 39 files changed, 192 insertions(+), 10 deletions(-) create mode 100644 .gitignore delete mode 100644 main.py create mode 100644 pyproject.toml rename {source => super_mario}/__init__.py (100%) rename source/main.py => super_mario/__main__.py (92%) rename {source => super_mario}/components/__init__.py (100%) rename {source => super_mario}/components/box.py (100%) rename {source => super_mario}/components/brick.py (100%) rename {source => super_mario}/components/coin.py (100%) rename {source => super_mario}/components/enemy.py (100%) rename {source => super_mario}/components/info.py (100%) rename {source => super_mario}/components/player.py (99%) rename {source => super_mario}/components/powerup.py (100%) rename {source => super_mario}/components/stuff.py (100%) rename {source => super_mario}/constants.py (100%) rename {source => super_mario}/data/maps/level_1.json (100%) rename {source => super_mario}/data/maps/level_2.json (100%) rename {source => super_mario}/data/maps/level_3.json (100%) rename {source => super_mario}/data/maps/level_4.json (100%) rename {source => super_mario}/data/player/luigi.json (100%) rename {source => super_mario}/data/player/mario.json (100%) rename {resources => super_mario/resources}/graphics/enemies.png (100%) rename {resources => super_mario/resources}/graphics/item_objects.png (100%) rename {resources => super_mario/resources}/graphics/level_1.png (100%) rename {resources => super_mario/resources}/graphics/level_2.png (100%) rename {resources => super_mario/resources}/graphics/level_3.png (100%) rename {resources => super_mario/resources}/graphics/level_4.png (100%) rename {resources => super_mario/resources}/graphics/mario_bros.png (100%) rename {resources => super_mario/resources}/graphics/smb_enemies_sheet.png (100%) rename {resources => super_mario/resources}/graphics/text_images.png (100%) rename {resources => super_mario/resources}/graphics/tile_set.png (100%) rename {resources => super_mario/resources}/graphics/title_screen.png (100%) rename {source => super_mario}/setup.py (76%) rename {source => super_mario}/states/__init__.py (100%) rename {source => super_mario}/states/level.py (99%) rename {source => super_mario}/states/load_screen.py (100%) rename {source => super_mario}/states/main_menu.py (100%) rename {source => super_mario}/tools.py (100%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e85b2d4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,126 @@ +# create by https://github.com/iamcco/coc-gitignore (Tue Apr 09 2024 15:59:42 GMT+0800 (China Standard Time)) +# Python.gitignore: +# 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/ +pip-wheel-metadata/ +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 +.hypothesis/ +.pytest_cache/ + +# 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 +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.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 + +# celery beat schedule file +celerybeat-schedule + +# 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/ diff --git a/README.md b/README.md index 8e84a14..b8c7dec 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,10 @@ A improved supermario game based on https://github.com/justinmeister/Mario-Level * Python-Pygame 1.9 # How To Start Game -$ python main.py +$ python -m super_mario +# or +$ pip install super-mario-game +$ super-mario # How to Play * use LEFT/RIGHT/DOWN key to control player diff --git a/main.py b/main.py deleted file mode 100644 index 9421809..0000000 --- a/main.py +++ /dev/null @@ -1,6 +0,0 @@ -import pygame as pg -from source.main import main - -if __name__=='__main__': - main() - pg.quit() \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..1b3ad39 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,55 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" + +# https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html +[project] +name = "super-mario-game" +version = "0.0.1" +description = "a simple SuperMario game" +readme = "README.md" +requires-python = ">= 3.7" +keywords = ["pygame"] +dependencies = ["pygame >= 1.9"] +classifiers = [ + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "Topic :: Software Development :: Build Tools", + "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX", + "Operating System :: Unix", + "Operating System :: MacOS", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: Implementation :: CPython", + "Programming Language :: Python :: Implementation :: PyPy", +] + +[[project.authors]] +name = "marblexu" +email = "47616581+marblexu@users.noreply.github.com" + +[project.license] +text = "MIT" + +[project.urls] +Homepage = "https://github.com/marblexu/PythonSuperMario" +Download = "https://github.com/marblexu/PythonSuperMario/releases" +"Bug Report" = "https://github.com/marblexu/PythonSuperMario/issues" +Source = "https://github.com/marblexu/PythonSuperMario" + +[project.scripts] +super-mario = "super_mario.__main__:main" + +[tool.setuptools.packages.find] +include = ["super_mario*"] + +[tool.setuptools.package-data] +super_mario = ["data/**", "resources/**"] diff --git a/source/__init__.py b/super_mario/__init__.py similarity index 100% rename from source/__init__.py rename to super_mario/__init__.py diff --git a/source/main.py b/super_mario/__main__.py similarity index 92% rename from source/main.py rename to super_mario/__main__.py index 5bdcedf..094fb74 100644 --- a/source/main.py +++ b/super_mario/__main__.py @@ -14,3 +14,7 @@ def main(): c.TIME_OUT: load_screen.TimeOut()} game.setup_states(state_dict, c.MAIN_MENU) game.main() + + +if __name__ == '__main__': + main() diff --git a/source/components/__init__.py b/super_mario/components/__init__.py similarity index 100% rename from source/components/__init__.py rename to super_mario/components/__init__.py diff --git a/source/components/box.py b/super_mario/components/box.py similarity index 100% rename from source/components/box.py rename to super_mario/components/box.py diff --git a/source/components/brick.py b/super_mario/components/brick.py similarity index 100% rename from source/components/brick.py rename to super_mario/components/brick.py diff --git a/source/components/coin.py b/super_mario/components/coin.py similarity index 100% rename from source/components/coin.py rename to super_mario/components/coin.py diff --git a/source/components/enemy.py b/super_mario/components/enemy.py similarity index 100% rename from source/components/enemy.py rename to super_mario/components/enemy.py diff --git a/source/components/info.py b/super_mario/components/info.py similarity index 100% rename from source/components/info.py rename to super_mario/components/info.py diff --git a/source/components/player.py b/super_mario/components/player.py similarity index 99% rename from source/components/player.py rename to super_mario/components/player.py index 1f1f819..a1ff4ec 100644 --- a/source/components/player.py +++ b/super_mario/components/player.py @@ -41,7 +41,7 @@ def restart(self): def load_data(self): player_file = str(self.player_name) + '.json' - file_path = os.path.join('source', 'data', 'player', player_file) + file_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'data', 'player', player_file) f = open(file_path) self.player_data = json.load(f) diff --git a/source/components/powerup.py b/super_mario/components/powerup.py similarity index 100% rename from source/components/powerup.py rename to super_mario/components/powerup.py diff --git a/source/components/stuff.py b/super_mario/components/stuff.py similarity index 100% rename from source/components/stuff.py rename to super_mario/components/stuff.py diff --git a/source/constants.py b/super_mario/constants.py similarity index 100% rename from source/constants.py rename to super_mario/constants.py diff --git a/source/data/maps/level_1.json b/super_mario/data/maps/level_1.json similarity index 100% rename from source/data/maps/level_1.json rename to super_mario/data/maps/level_1.json diff --git a/source/data/maps/level_2.json b/super_mario/data/maps/level_2.json similarity index 100% rename from source/data/maps/level_2.json rename to super_mario/data/maps/level_2.json diff --git a/source/data/maps/level_3.json b/super_mario/data/maps/level_3.json similarity index 100% rename from source/data/maps/level_3.json rename to super_mario/data/maps/level_3.json diff --git a/source/data/maps/level_4.json b/super_mario/data/maps/level_4.json similarity index 100% rename from source/data/maps/level_4.json rename to super_mario/data/maps/level_4.json diff --git a/source/data/player/luigi.json b/super_mario/data/player/luigi.json similarity index 100% rename from source/data/player/luigi.json rename to super_mario/data/player/luigi.json diff --git a/source/data/player/mario.json b/super_mario/data/player/mario.json similarity index 100% rename from source/data/player/mario.json rename to super_mario/data/player/mario.json diff --git a/resources/graphics/enemies.png b/super_mario/resources/graphics/enemies.png similarity index 100% rename from resources/graphics/enemies.png rename to super_mario/resources/graphics/enemies.png diff --git a/resources/graphics/item_objects.png b/super_mario/resources/graphics/item_objects.png similarity index 100% rename from resources/graphics/item_objects.png rename to super_mario/resources/graphics/item_objects.png diff --git a/resources/graphics/level_1.png b/super_mario/resources/graphics/level_1.png similarity index 100% rename from resources/graphics/level_1.png rename to super_mario/resources/graphics/level_1.png diff --git a/resources/graphics/level_2.png b/super_mario/resources/graphics/level_2.png similarity index 100% rename from resources/graphics/level_2.png rename to super_mario/resources/graphics/level_2.png diff --git a/resources/graphics/level_3.png b/super_mario/resources/graphics/level_3.png similarity index 100% rename from resources/graphics/level_3.png rename to super_mario/resources/graphics/level_3.png diff --git a/resources/graphics/level_4.png b/super_mario/resources/graphics/level_4.png similarity index 100% rename from resources/graphics/level_4.png rename to super_mario/resources/graphics/level_4.png diff --git a/resources/graphics/mario_bros.png b/super_mario/resources/graphics/mario_bros.png similarity index 100% rename from resources/graphics/mario_bros.png rename to super_mario/resources/graphics/mario_bros.png diff --git a/resources/graphics/smb_enemies_sheet.png b/super_mario/resources/graphics/smb_enemies_sheet.png similarity index 100% rename from resources/graphics/smb_enemies_sheet.png rename to super_mario/resources/graphics/smb_enemies_sheet.png diff --git a/resources/graphics/text_images.png b/super_mario/resources/graphics/text_images.png similarity index 100% rename from resources/graphics/text_images.png rename to super_mario/resources/graphics/text_images.png diff --git a/resources/graphics/tile_set.png b/super_mario/resources/graphics/tile_set.png similarity index 100% rename from resources/graphics/tile_set.png rename to super_mario/resources/graphics/tile_set.png diff --git a/resources/graphics/title_screen.png b/super_mario/resources/graphics/title_screen.png similarity index 100% rename from resources/graphics/title_screen.png rename to super_mario/resources/graphics/title_screen.png diff --git a/source/setup.py b/super_mario/setup.py similarity index 76% rename from source/setup.py rename to super_mario/setup.py index fccaa67..229a860 100644 --- a/source/setup.py +++ b/super_mario/setup.py @@ -11,4 +11,4 @@ SCREEN = pg.display.set_mode(c.SCREEN_SIZE) SCREEN_RECT = SCREEN.get_rect() -GFX = tools.load_all_gfx(os.path.join("resources","graphics")) \ No newline at end of file +GFX = tools.load_all_gfx(os.path.join(os.path.dirname(__file__), "resources","graphics")) diff --git a/source/states/__init__.py b/super_mario/states/__init__.py similarity index 100% rename from source/states/__init__.py rename to super_mario/states/__init__.py diff --git a/source/states/level.py b/super_mario/states/level.py similarity index 99% rename from source/states/level.py rename to super_mario/states/level.py index 1ffe7b0..a0688eb 100644 --- a/source/states/level.py +++ b/super_mario/states/level.py @@ -39,7 +39,7 @@ def startup(self, current_time, persist): def load_map(self): map_file = 'level_' + str(self.game_info[c.LEVEL_NUM]) + '.json' - file_path = os.path.join('source', 'data', 'maps', map_file) + file_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'data', 'maps', map_file) f = open(file_path) self.map_data = json.load(f) f.close() diff --git a/source/states/load_screen.py b/super_mario/states/load_screen.py similarity index 100% rename from source/states/load_screen.py rename to super_mario/states/load_screen.py diff --git a/source/states/main_menu.py b/super_mario/states/main_menu.py similarity index 100% rename from source/states/main_menu.py rename to super_mario/states/main_menu.py diff --git a/source/tools.py b/super_mario/tools.py similarity index 100% rename from source/tools.py rename to super_mario/tools.py