From 1f26d485f57201b0be3ed036ba2816f6b5982f85 Mon Sep 17 00:00:00 2001 From: Lertsenem Date: Wed, 22 Jul 2020 18:11:43 +0200 Subject: [PATCH] Fix Windows msi and exe builds --- setup.py | 136 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 73 insertions(+), 63 deletions(-) diff --git a/setup.py b/setup.py index 2410894..6316708 100644 --- a/setup.py +++ b/setup.py @@ -1,94 +1,104 @@ import distutils, distutils.util import os import setuptools +import sys import lokrez, lokrez.version -if os.name == "nt": - import cx_Freeze - -author = "Lertsenem" -mail = "lertsenem@lertsenem.com" - # Load README for long_description with open("README.adoc", "r") as fh: long_description = fh.read() +# Windows build if os.name == "nt": - enterprise = "Smash@Lyon" + import cx_Freeze + arch = distutils.util.get_platform().split("-")[-1] + build_exe_options = { "packages": ["os"], "include_msvcr": True, + "include_files": [ "lokrez/data", "lokrez/templates", "lokrez/queries" ], + "includes": ["idna.idnadata"], # Because of cx-freeze bug } + bdist_msi_options = { "upgrade_code": "{123456789-1337-8483-ABCD-DEADBEEFCAFE}", "add_to_path": True, "initial_target_dir": r"[LocalAppDataFolder]\{}\{}" \ .format( - enterprise, + lokrez.version.ENTITY, lokrez.version.NAME, ), } - options = { - "build_exe": build_exe_options, - "bdist_msi": bdist_msi_options, - }, - base = None - executables = [ - cx_Freeze.Executable( - script = "__init__.py", - targetName = "{}.exe".format(lokrez.version.NAME), - base = base, - ) - ], + cx_Freeze.setup( + name = lokrez.version.NAME, + version = lokrez.version.__version__.replace("dev", "1337"), + author = lokrez.version.AUTHOR, + author_email = lokrez.version.AUTHOR_EMAIL, + description = lokrez.version.DESCRIPTION, + install_requires = [ + "jinja2", + "requests", + "appdirs", + ], + options = { + "build_exe": build_exe_options, + "bdist_msi": bdist_msi_options, + }, - setup = cx_Freeze.setup + executables = [ + cx_Freeze.Executable( + script = "lokrez/__main__.py", + targetName = "{}.exe".format(lokrez.version.NAME), + base = base, + ), + ], + ) -else: - options = None - executables = None - setup = setuptools.setup + sys.exit(0) -setup( - name = lokrez.version.NAME, - version = lokrez.__version__, - author = author, - author_email = mail, - description = "A smash.gg-connected local results generator for SSBU", - long_description = long_description, - long_description_content_type = "text/asciidoc", - url = "https://git.lertsenem.com/lertsenem/ssbu_lokrez", - packages = ["lokrez"], - install_requires = [ - "jinja2", - "requests", - ], - license = "MIT", - classifiers = [ - "Programming Language :: Python :: 3", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - "Intended Audience :: Smash Bros Ultimate Players", - ], - python_requires = ">=3.5", - keywords = "smash ultimate local results esport smashgg", +# Linux build +if os.name == "posix": + + setuptools.setup( + name = lokrez.version.NAME, + version = lokrez.__version__, + author = lokrez.version.AUTHOR, + author_email = lokrez.version.AUTHOR_EMAIL, + description = lokrez.version.DESCRIPTION, + long_description = long_description, + long_description_content_type = "text/asciidoc", + url = lokrez.version.URL, + packages = ["lokrez"], + install_requires = [ + "jinja2", + "requests", + "appdirs", + ], + license = lokrez.version.__license__, + classifiers = [ + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Intended Audience :: Smash Bros Ultimate Players", + ], + python_requires = ">=3.5", + keywords = "smash ultimate local results esport smashgg", # data_files = ("res", ["res/playerskinsdb.json"]) - package_data = { - "lokrez": [ - "data/*.json", - "queries/*.gql", - "templates/*/*.j2", - ], - }, - entry_points = { - "console_scripts": [ - "lokrez = lokrez:main", - ], - }, - options = options, - executables = executables, - ) + package_data = { + "lokrez": [ + "data/*.json", + "queries/*.gql", + "templates/*/*.j2", + ], + }, + entry_points = { + "console_scripts": [ + "lokrez = lokrez:main", + ], + }, + )