174 lines
5.4 KiB
Python
174 lines
5.4 KiB
Python
import distutils, distutils.util
|
|
import msilib
|
|
import os
|
|
import pathlib
|
|
import setuptools
|
|
import sys
|
|
|
|
import lokrez, lokrez.version
|
|
|
|
# Load README for long_description
|
|
with open("README.adoc", "r") as fh:
|
|
long_description = fh.read()
|
|
|
|
# Windows build
|
|
if os.name == "nt":
|
|
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(
|
|
lokrez.version.ENTITY,
|
|
lokrez.version.NAME,
|
|
),
|
|
}
|
|
|
|
base = None
|
|
|
|
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,
|
|
},
|
|
|
|
executables = [
|
|
cx_Freeze.Executable(
|
|
script = "lokrez/__main__.py",
|
|
targetName = "{}.exe".format(lokrez.version.NAME),
|
|
base = base,
|
|
),
|
|
],
|
|
)
|
|
|
|
|
|
# -------------------------------------------------------------------------
|
|
# Modifications to allow for a non-admin-required msi
|
|
print("modifying final msi '{}' for standard user installation" \
|
|
.format(msi_filepath))
|
|
if not msi_filepath.exists():
|
|
print("msi file does not exist")
|
|
else:
|
|
try:
|
|
db = msilib.OpenDatabase(
|
|
str(msi_filepath),
|
|
msilib.MSIDBOPEN_TRANSACT,
|
|
)
|
|
|
|
si = db.GetSummaryInformation(20)
|
|
cur_wc = si.GetProperty(msilib.PID_WORDCOUNT)
|
|
si.SetProperty(
|
|
msilib.PID_WORDCOUNT,
|
|
cur_wc | 0b1000,
|
|
)
|
|
si.SetProperty(
|
|
msilib.PID_AUTHOR,
|
|
"{} - {}" \
|
|
.format(
|
|
lokrez.version.ENTITY,
|
|
lokrez.version.AUTHOR,
|
|
),
|
|
)
|
|
si.Persist()
|
|
|
|
# Install for the current user only
|
|
vi = db.OpenView(
|
|
"DELETE FROM `Property` WHERE `Property`.`Property` = " \
|
|
"'ALLUSERS'",
|
|
)
|
|
vi.Execute(None)
|
|
vi.Close()
|
|
|
|
# Add the manufacturer name
|
|
vi = db.OpenView(
|
|
"UPDATE `Property` SET `Property`.`Value`='{} - {}' WHERE " \
|
|
"`Property`.`Property` = 'Manufacturer'" \
|
|
.format(
|
|
lokrez.version.ENTITY,
|
|
lokrez.version.AUTHOR,
|
|
),
|
|
)
|
|
vi.Execute(None)
|
|
vi.Close()
|
|
|
|
# Update Path env variable for the user only
|
|
vi = db.OpenView(
|
|
"UPDATE `Environment` SET `Environment`.`Name`='=-Path' " \
|
|
"WHERE `Environment`.`Environment` = 'E_PATH'",
|
|
)
|
|
vi.Execute(None)
|
|
vi.Close()
|
|
|
|
db.Commit()
|
|
db.Close()
|
|
|
|
except Exception as e:
|
|
print("fail")
|
|
print(str(e))
|
|
print(e.args)
|
|
raise
|
|
|
|
sys.exit(0)
|
|
|
|
# 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",
|
|
],
|
|
},
|
|
)
|