Fix Windows msi and exe builds

master
Lertsenem 2020-07-22 18:11:43 +02:00
parent c9bc474477
commit 1f26d485f5
1 changed files with 73 additions and 63 deletions

136
setup.py
View File

@ -1,94 +1,104 @@
import distutils, distutils.util import distutils, distutils.util
import os import os
import setuptools import setuptools
import sys
import lokrez, lokrez.version import lokrez, lokrez.version
if os.name == "nt":
import cx_Freeze
author = "Lertsenem"
mail = "lertsenem@lertsenem.com"
# Load README for long_description # Load README for long_description
with open("README.adoc", "r") as fh: with open("README.adoc", "r") as fh:
long_description = fh.read() long_description = fh.read()
# Windows build
if os.name == "nt": if os.name == "nt":
enterprise = "Smash@Lyon" import cx_Freeze
arch = distutils.util.get_platform().split("-")[-1] arch = distutils.util.get_platform().split("-")[-1]
build_exe_options = { build_exe_options = {
"packages": ["os"], "packages": ["os"],
"include_msvcr": True, "include_msvcr": True,
"include_files": [ "lokrez/data", "lokrez/templates", "lokrez/queries" ],
"includes": ["idna.idnadata"], # Because of cx-freeze bug
} }
bdist_msi_options = { bdist_msi_options = {
"upgrade_code": "{123456789-1337-8483-ABCD-DEADBEEFCAFE}", "upgrade_code": "{123456789-1337-8483-ABCD-DEADBEEFCAFE}",
"add_to_path": True, "add_to_path": True,
"initial_target_dir": r"[LocalAppDataFolder]\{}\{}" \ "initial_target_dir": r"[LocalAppDataFolder]\{}\{}" \
.format( .format(
enterprise, lokrez.version.ENTITY,
lokrez.version.NAME, lokrez.version.NAME,
), ),
} }
options = {
"build_exe": build_exe_options,
"bdist_msi": bdist_msi_options,
},
base = None base = None
executables = [ cx_Freeze.setup(
cx_Freeze.Executable( name = lokrez.version.NAME,
script = "__init__.py", version = lokrez.version.__version__.replace("dev", "1337"),
targetName = "{}.exe".format(lokrez.version.NAME), author = lokrez.version.AUTHOR,
base = base, 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: sys.exit(0)
options = None
executables = None
setup = setuptools.setup
setup( # Linux build
name = lokrez.version.NAME, if os.name == "posix":
version = lokrez.__version__,
author = author, setuptools.setup(
author_email = mail, name = lokrez.version.NAME,
description = "A smash.gg-connected local results generator for SSBU", version = lokrez.__version__,
long_description = long_description, author = lokrez.version.AUTHOR,
long_description_content_type = "text/asciidoc", author_email = lokrez.version.AUTHOR_EMAIL,
url = "https://git.lertsenem.com/lertsenem/ssbu_lokrez", description = lokrez.version.DESCRIPTION,
packages = ["lokrez"], long_description = long_description,
install_requires = [ long_description_content_type = "text/asciidoc",
"jinja2", url = lokrez.version.URL,
"requests", packages = ["lokrez"],
], install_requires = [
license = "MIT", "jinja2",
classifiers = [ "requests",
"Programming Language :: Python :: 3", "appdirs",
"License :: OSI Approved :: MIT License", ],
"Operating System :: OS Independent", license = lokrez.version.__license__,
"Intended Audience :: Smash Bros Ultimate Players", classifiers = [
], "Programming Language :: Python :: 3",
python_requires = ">=3.5", "License :: OSI Approved :: MIT License",
keywords = "smash ultimate local results esport smashgg", "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"]) # data_files = ("res", ["res/playerskinsdb.json"])
package_data = { package_data = {
"lokrez": [ "lokrez": [
"data/*.json", "data/*.json",
"queries/*.gql", "queries/*.gql",
"templates/*/*.j2", "templates/*/*.j2",
], ],
}, },
entry_points = { entry_points = {
"console_scripts": [ "console_scripts": [
"lokrez = lokrez:main", "lokrez = lokrez:main",
], ],
}, },
options = options, )
executables = executables,
)