1
0
Fork 0
mirror of synced 2024-05-19 12:02:54 +12:00

split build into setup.py and freeze.py

This commit is contained in:
ChemicalXandco 2021-05-08 16:47:49 +01:00
parent 0b31fe9ee2
commit 887dcf6ff7
3 changed files with 117 additions and 70 deletions

View file

@ -46,7 +46,7 @@ jobs:
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: Update AUR package
pyinstaller-windows:
cx-freeze-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
@ -58,7 +58,7 @@ jobs:
pip3 install cx_Freeze setuptools wheel
pip3 install -r requirements.txt
- name: Build
run: python3 setup.py bdist_msi
run: python3 freeze.py bdist_msi
- name: Upload files to GitHub
uses: svenstaro/upload-release-action@2.2.1
with:

82
freeze.py Normal file
View file

@ -0,0 +1,82 @@
import sys
from cx_Freeze import setup, Executable
from rare import __version__
# Packages to include
python_packages = [
"PyQt5",
'requests',
'PIL',
'qtawesome',
'notifypy',
'psutil',
'pypresence',
]
# Modules to include
python_modules = []
base = None
name = None
build_options = {}
build_exe_options = {}
shortcutName = None
shortcutDir = None
bdist_msi_options = None
src_files = []
external_so_files = []
if sys.platform == 'win32':
base = 'Win32GUI'
name = 'Rare.exe'
shortcut_table = [
('DesktopShortcut', # Shortcut
'DesktopFolder', # Directory
'Rare', # Name
'TARGETDIR', # Component
'[TARGETDIR]'+name, # Target
None, # Arguments
'A gui for Legendary.', # Description
None, # Hotkey
None, # Icon
None, # IconIndex
None, # ShowCmd
'TARGETDIR' # Working Directory
)]
msi_data = {"Shortcut": shortcut_table}
bdist_msi_options = {'data': msi_data, "all_users": True}
build_options["bdist_msi"] = bdist_msi_options
else:
name = 'Rare'
src_files += [
'LICENSE',
'README.md',
'rare/styles/Logo.ico',
]
# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options["packages"] = python_packages
build_exe_options["include_files"] = src_files + external_so_files
build_exe_options["includes"] = python_modules
build_exe_options["excludes"] = ["setuptools", "tkinter", "pkg_resources"]
# Set options
build_options["build_exe"] = build_exe_options
setup(name = 'Rare',
version = __version__,
description = 'A gui for Legendary.',
options = build_options,
executables = [
Executable('rare/__main__.py',
targetName=name,
icon='rare/styles/Logo.ico',
base=base,
shortcutName=shortcutName,
shortcutDir=shortcutDir,
),
],
)

101
setup.py
View file

@ -1,74 +1,39 @@
import sys
import setuptools
from cx_Freeze import setup, Executable
from rare import __version__ as version
import rare
with open("README.md", "r") as fh:
long_description = fh.read()
opts = {
'packages': [
'requests',
'PIL',
'qtawesome',
'notifypy',
'psutil',
'pypresence',
setuptools.setup(
name="Rare",
version=version,
author="Dummerle",
license="GPL-3",
description="A gui for Legendary",
long_description=long_description,
long_description_content_type="text/markdown",
include_package_data=True,
url="https://github.com/Dummerle/Rare",
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
"Operating System :: OS Independent"
],
'zip_include_packages': [
'PyQt5.QtCore',
'PyQt5.QtGui',
'PyQt5.QtWidgets',
],
'include_files': [
'LICENSE',
'README.MD',
'rare/styles/Logo.ico',
],
}
setup_options = {'build_exe': opts}
base = None
name = None
shortcutName = None
shortcutDir = None
bdist_msi_options = None
if sys.platform == 'win32':
base = 'Win32GUI'
name = 'Rare.exe'
shortcut_table = [
('DesktopShortcut', # Shortcut
'DesktopFolder', # Directory
'Rare', # Name
'TARGETDIR', # Component
'[TARGETDIR]'+name, # Target
None, # Arguments
'A gui for Legendary.', # Description
None, # Hotkey
None, # Icon
None, # IconIndex
None, # ShowCmd
'TARGETDIR' # Working Directory
)]
msi_data = {"Shortcut": shortcut_table}
bdist_msi_options = {'data': msi_data}
setup_options.update({"bdist_msi": bdist_msi_options})
else:
name = 'Rare'
setup(name = 'Rare',
version = rare.__version__,
description = 'A gui for Legendary.',
options = setup_options,
setup_requires=[
'cx_Freeze',
],
executables = [
Executable('rare/__main__.py',
targetName=name,
icon='rare/styles/Logo.ico',
base=base,
shortcutName=shortcutName,
shortcutDir=shortcutDir,
),
python_requires=">=3.8",
entry_points=dict(console_scripts=["rare=rare.__main__:main"]),
install_requires=[
"requests<3.0",
"pillow",
"setuptools",
"wheel",
"PyQt5",
"QtAwesome",
"notify-py",
"psutil",
"pypresence"
],
)