mirror of
https://github.com/quantum5/2048.git
synced 2025-04-24 20:41:57 -04:00
Add ability to be packaged.
This commit is contained in:
parent
9c8d8366c9
commit
eb3f804ce5
|
@ -1,14 +1,4 @@
|
|||
"""This module makes the package executable"""
|
||||
from .main import main
|
||||
|
||||
from .main import run_game
|
||||
import os
|
||||
|
||||
|
||||
def main():
|
||||
"""Execute the game and store state in the current directory."""
|
||||
run_game(data_dir=os.getcwd())
|
||||
|
||||
|
||||
# Run the main function if this file is executed directly.
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
import os
|
||||
|
||||
import errno
|
||||
import pygame
|
||||
from appdirs import user_data_dir
|
||||
|
||||
from .game import Game2048
|
||||
from .manager import GameManager
|
||||
|
@ -19,8 +21,12 @@ def run_game(game_class=Game2048, title='2048: In Python!', data_dir=None):
|
|||
os.environ['SDL_VIDEODRIVER'] = 'windib'
|
||||
|
||||
if data_dir is None:
|
||||
# Use current directory for now.
|
||||
data_dir = os.getcwd()
|
||||
data_dir = user_data_dir(appauthor='Quantum', appname='2048', roaming=True)
|
||||
try:
|
||||
os.makedirs(data_dir)
|
||||
except OSError as e:
|
||||
if e.errno != errno.EEXIST:
|
||||
raise
|
||||
|
||||
screen = pygame.display.set_mode((game_class.WIDTH, game_class.HEIGHT))
|
||||
manager = GameManager(Game2048, screen,
|
||||
|
|
40
setup.py
Normal file
40
setup.py
Normal file
|
@ -0,0 +1,40 @@
|
|||
from setuptools import setup
|
||||
|
||||
|
||||
setup(
|
||||
name='2048',
|
||||
version='0.1',
|
||||
packages=['_2048'],
|
||||
package_data={
|
||||
'_2048': ['*.ttf'],
|
||||
},
|
||||
|
||||
entry_points={
|
||||
'console_scripts': [
|
||||
'2048 = _2048.main:main',
|
||||
],
|
||||
'gui_scripts': [
|
||||
'2048w = _2048.main:main'
|
||||
]
|
||||
|
||||
},
|
||||
install_requires=['pygame', 'appdirs'],
|
||||
|
||||
author='quantum',
|
||||
author_email='quantum2048@gmail.com',
|
||||
url='https://github.com/quantum5/2048',
|
||||
description="Quantum's version of the 2048 game, with multi-instance support,"
|
||||
'restored from an old high school project.',
|
||||
keywords='2048 pygame',
|
||||
classifiers=[
|
||||
'Development Status :: 3 - Beta',
|
||||
'Environment :: Win32 (MS Windows)',
|
||||
'Environment :: X11 Applications',
|
||||
'Intended Audience :: End Users/Desktop',
|
||||
'License :: OSI Approved :: GNU Affero General Public License v3',
|
||||
'Operating System :: Microsoft :: Windows',
|
||||
'Operating System :: POSIX :: Linux',
|
||||
'Programming Language :: Python',
|
||||
'Topic :: Games/Entertainment',
|
||||
],
|
||||
)
|
Loading…
Reference in a new issue