Skip to content

Commit

Permalink
packaging for pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
Trilarion committed Dec 4, 2016
1 parent fc186dc commit 26e55e5
Show file tree
Hide file tree
Showing 32 changed files with 103 additions and 37 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Python

__pycache__
*.egg-info

# Sphinx Doc

Expand Down
3 changes: 2 additions & 1 deletion .idea/Imperialism Remake.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified data/scenarios/core/Europe1814.scenario
Binary file not shown.
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
PyYAML>=3.1
PyQt5>=5.6
.
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[bdist_wheel]
python-tag = py3
64 changes: 63 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,65 @@
"""
Setup
Setup
"""

from setuptools import setup, find_packages
import os
import imperialism_remake.version as vs

HERE = os.path.abspath(os.path.dirname(__file__))

CLASSIFIERS = ['Development Status :: 2 - Pre-Alpha',
'Intended Audience :: End Users/Desktop',
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
'Operating System :: OS Independent',
'Programming Language :: Python :: 3',
'Topic :: Games/Entertainment :: Turn Based Strategy']

KEYWORDS = 'imperialism remake turn based strategy game open source'

def get_long_description():
"""
Get the long description from the README file.
"""
with open(os.path.join(HERE, 'README.md'), encoding='utf-8') as f:
return f.read()

def get_data_files():
"""
Get the list of data files (full content of data directory).
"""
data_files = []
for dirpath, dirnames, filenames in os.walk(os.path.join(HERE, 'data')):
if filenames:
destination = os.path.relpath(dirpath, HERE)
names = [os.path.join(destination, name) for name in filenames]
data_files.append((destination,names))
return data_files

def get_data_files2():
data_files = []
for dirpath, dirnames, filenames in os.walk(os.path.join(HERE, 'data')):
if filenames:
destination = os.path.relpath(dirpath, HERE)
names = [os.path.join(destination, name) for name in filenames]
data_files.append(names)
return data_files

if __name__ == "__main__":
setup(name='imperialism_remake',
version=vs.__version__,
description='Open source remake of Imperialism',
long_description=get_long_description(),
url='http://remake.twelvepm.de/',
author='Trilarion',
author_email='pypi@twelvepm.de',
license='GPL',
classifiers=CLASSIFIERS,
keywords=KEYWORDS,
package_dir={'':'source'},
packages=find_packages(where=os.path.join(HERE, 'source')),
install_requires=['PyYAML>=3.1', 'PyQt5>=5.6'],
#data_files=get_data_files(),
package_data={'imperialism_remake': 'data'},
entry_points={'console_scripts': ['imperialism_remake_start=imperialism_remake.imperialism_remake:main']},
zip_safe=False)
3 changes: 3 additions & 0 deletions source/imperialism_remake/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Package imperialism_remake
"""
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def __init__(self):
self.default = None


Options = Option.__members__ # dictionary of name, Enum-value pairs
Options = list(Option)

#: default values for the Options
Option.LOCALSERVER_OPEN.default = False
Expand Down
File renamed without changes.
File renamed without changes.
37 changes: 15 additions & 22 deletions source/base/tools.py → source/imperialism_remake/base/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,19 @@ def load_options(file_name):
global options
options = utils.read_as_yaml(file_name)

# if for some reason no dict, make it a dict
if type(options) is not dict:
options = {}

# delete entries that are not in Constants.Options
for key in list(options.keys()):
if key not in constants.Options:
del options[key]
for option in options.keys():
if option not in constants.Options:
del options[option]

# copy values that are in Constants.Options but not here
for key in constants.Options:
if key not in options:
options[key] = constants.Options[key].default

# main window bounding rectangle, convert from list to QRect
rect = get_option(constants.Option.MAINWINDOW_BOUNDS)
if rect is not None:
set_option(constants.Option.MAINWINDOW_BOUNDS, QtCore.QRect(*rect))

for option in constants.Options:
if option not in options:
options[option] = option.default

def get_option(option):
"""
Expand All @@ -114,7 +112,8 @@ def get_option(option):
:param option:
:return:
"""
return options[option.name]

return options[option]


def set_option(option, value):
Expand All @@ -124,7 +123,8 @@ def set_option(option, value):
:param option:
:param value:
"""
options[option.name] = value

options[option] = value


def save_options(file_name):
Expand All @@ -133,13 +133,6 @@ def save_options(file_name):
:param file_name:
"""
data = options.copy()

# main window bounding rectangle, convert from QRect to list
option = constants.Option.MAINWINDOW_BOUNDS.name
if option in data:
rect = data[option]
data[option] = [rect.x(), rect.y(), rect.width(), rect.height()]

# write to file
utils.write_as_yaml(file_name, data)
utils.write_as_yaml(file_name, options)
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -309,14 +309,14 @@ def show_game_lobby_dialog(self):
lobby_widget = GameLobbyWidget()
dialog = client.graphics.GameDialog(self.main_window, lobby_widget, delete_on_close=True, title='Game Lobby', help_callback=self.show_help_browser)
dialog.setFixedSize(QtCore.QSize(900, 700))
lobby_widget.single_player_start.connect(partial(self.single_player_start, dialog))
lobby_widget.single_player_start.connect(self.single_player_start)
dialog.show()

def single_player_start(self, lobby_dialog, scenario_file, selected_nation):
def single_player_start(self, scenario_file, selected_nation):
"""
Shows the main game screen which will start a scenario file and a selected nation.
"""
lobby_dialog.close()
#lobby_dialog.close()
widget = GameMainScreen(self)
self.main_window.change_content_widget(widget)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def single_player_scenario_selection_preview(self, scenario_file):
# create single player scenario preview widget
widget = SinglePlayerScenarioPreview(scenario_file)
widget.nation_selected.connect(partial(self.single_player_start.emit, scenario_file))
#widget.nation_selected.connect(

# change content widget
self.change_content_widget(widget)
Expand Down Expand Up @@ -247,7 +248,7 @@ class SinglePlayerScenarioPreview(QtWidgets.QWidget):
"""

#: signal, emitted if a nation is selected and the start button is presed
nation_selected = QtCore.pyqtSignal(str)
nation_selected = QtCore.pyqtSignal(int)

def __init__(self, scenario_file):
"""
Expand Down Expand Up @@ -328,8 +329,6 @@ def received_preview(self, client, channel, action, message):
toolbar.addAction(qt.create_action(tools.load_ui_icon('icon.confirm.png'), 'Start selected scenario', toolbar, trigger_connection=self.start_scenario_clicked))
layout.addWidget(toolbar, 3, 0, 1, 2, alignment=QtCore.Qt.AlignRight)



# draw the map
columns = message[constants.ScenarioProperty.MAP_COLUMNS]
rows = message[constants.ScenarioProperty.MAP_ROWS]
Expand Down Expand Up @@ -400,7 +399,8 @@ def nations_list_selection_changed(self):
"""
row = self.nations_list.currentRow()
nation_id = self.nation_ids[row]
self.selected_nation = self.preview['nations'][nation_id][constants.NationProperty.NAME]
# self.selected_nation = self.preview['nations'][nation_id][constants.NationProperty.NAME]
self.selected_nation = nation_id
nation_description = self.preview['nations'][nation_id][constants.NationProperty.DESCRIPTION]
self.nation_info.setPlainText(nation_description)

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ def set_start_directory():
base_path = os.path.join(base_path, '..')


if __name__ == '__main__':

def main():
"""
Main entry point. Called from the script generated in setup.py and called when running this module with python.
"""
# test for python version
required_version = (3, 5)
if sys.version_info < required_version:
Expand Down Expand Up @@ -161,3 +164,6 @@ def set_start_directory():

# good bye message
tools.log_info('will exit soon - good bye')

if __name__ == '__main__':
main()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 26e55e5

Please sign in to comment.