onionshare/desktop/setup-freeze.py

164 lines
5.1 KiB
Python
Raw Normal View History

2021-12-21 17:16:10 -05:00
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
OnionShare | https://onionshare.org/
2022-01-16 19:15:49 -05:00
Copyright (C) 2014-2022 Micah Lee, et al. <micah@micahflee.com>
2021-12-21 17:16:10 -05:00
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import os
2021-12-23 14:58:07 -05:00
import sys
2021-12-22 15:04:44 -05:00
import platform
2021-12-23 14:58:07 -05:00
import shutil
2021-12-22 15:04:44 -05:00
import cx_Freeze
2021-12-21 17:16:10 -05:00
from cx_Freeze import setup, Executable
from setuptools import find_packages
2021-12-21 17:16:10 -05:00
2021-12-22 15:04:44 -05:00
# Discover the version
2021-12-21 17:16:10 -05:00
with open(os.path.join("..", "cli", "onionshare_cli", "resources", "version.txt")) as f:
version = f.read().strip()
# change a version like 2.6.dev1 to just 2.6, for cx_Freeze's sake
last_digit = version[-1]
if version.endswith(f".dev{last_digit}"):
2022-06-20 00:18:49 -04:00
version = version[0:-5]
2021-12-22 15:04:44 -05:00
# Build
include_files = [(os.path.join("..", "LICENSE"), "LICENSE")]
if platform.system() == "Windows":
include_msvcr = True
2022-10-02 15:18:46 -04:00
gui_base = "Win32GUI"
# gui_base = None
2021-12-22 17:04:34 -05:00
exec_icon = os.path.join("onionshare", "resources", "onionshare.ico")
2021-12-22 15:04:44 -05:00
elif platform.system() == "Darwin":
2022-10-23 12:13:51 -04:00
import PySide6
import shiboken6
2021-12-22 15:04:44 -05:00
include_msvcr = False
gui_base = None
2021-12-22 17:04:34 -05:00
exec_icon = None
2021-12-22 15:04:44 -05:00
include_files += [
(
2023-05-21 14:54:06 -04:00
os.path.join(PySide6.__path__[0], "libpyside6.abi3.6.5.dylib"),
"libpyside6.abi3.6.5.dylib",
2021-12-22 15:04:44 -05:00
),
(
2023-05-21 14:54:06 -04:00
os.path.join(shiboken6.__path__[0], "libshiboken6.abi3.6.5.dylib"),
"libshiboken6.abi3.6.5.dylib",
2021-12-22 15:04:44 -05:00
),
]
2021-12-23 14:58:07 -05:00
elif platform.system() == "Linux":
include_msvcr = False
gui_base = None
exec_icon = None
if not shutil.which("patchelf"):
print("Install the patchelf package")
sys.exit()
2021-12-21 17:16:10 -05:00
setup(
name="onionshare",
version=version,
description="Securely and anonymously share files, host websites, and chat with friends using the Tor network",
packages=find_packages(
where=".",
include=["onionshare"],
exclude=["package", "screenshots", "scripts", "tests"],
),
2021-12-21 17:16:10 -05:00
options={
2021-12-22 17:04:34 -05:00
# build_exe, for Windows and macOS
2021-12-21 17:16:10 -05:00
"build_exe": {
"packages": [
"cffi",
"engineio",
"engineio.async_drivers.gevent",
"engineio.async_drivers.gevent_uwsgi",
"gevent",
"jinja2.ext",
"onionshare",
"onionshare_cli",
2022-10-23 12:13:51 -04:00
"PySide6",
"PySide6.QtCore",
"PySide6.QtGui",
"PySide6.QtWidgets",
2021-12-22 15:04:44 -05:00
],
"excludes": [
"test",
"tkinter",
2022-10-23 12:13:51 -04:00
"PySide6.Qt3DAnimation",
"PySide6.Qt3DCore",
"PySide6.Qt3DExtras",
"PySide6.Qt3DInput",
"PySide6.Qt3DLogic",
"PySide6.Qt3DRender",
"PySide6.QtCharts",
"PySide6.QtConcurrent",
"PySide6.QtDataVisualization",
"PySide6.QtHelp",
"PySide6.QtLocation",
"PySide6.QtMultimedia",
"PySide6.QtMultimediaWidgets",
"PySide6.QtNetwork",
"PySide6.QtOpenGL",
"PySide6.QtOpenGLFunctions",
"PySide6.QtPositioning",
"PySide6.QtPrintSupport",
"PySide6.QtQml",
"PySide6.QtQuick",
"PySide6.QtQuickControls2",
"PySide6.QtQuickWidgets",
"PySide6.QtRemoteObjects",
"PySide6.QtScript",
"PySide6.QtScriptTools",
"PySide6.QtScxml",
"PySide6.QtSensors",
"PySide6.QtSerialPort",
"PySide6.QtSql",
"PySide6.QtTest",
"PySide6.QtTextToSpeech",
"PySide6.QtUiTools",
"PySide6.QtWebChannel",
"PySide6.QtWebEngine",
"PySide6.QtWebEngineCore",
"PySide6.QtWebEngineWidgets",
"PySide6.QtWebSockets",
"PySide6.QtXml",
"PySide6.QtXmlPatterns",
2021-12-21 17:16:10 -05:00
],
2021-12-22 15:04:44 -05:00
"include_files": include_files,
"include_msvcr": include_msvcr,
2021-12-22 17:04:34 -05:00
},
# bdist_mac, making the macOS app bundle
"bdist_mac": {
"iconfile": os.path.join("onionshare", "resources", "onionshare.icns"),
"bundle_name": "OnionShare",
2021-12-22 17:04:34 -05:00
},
2021-12-21 17:16:10 -05:00
},
executables=[
Executable(
"package/onionshare.py",
2021-12-22 15:04:44 -05:00
base=gui_base,
2021-12-22 17:04:34 -05:00
icon=exec_icon,
2021-12-21 17:16:10 -05:00
),
Executable(
"package/onionshare-cli.py",
base=None,
2021-12-22 17:04:34 -05:00
icon=exec_icon,
2021-12-21 17:16:10 -05:00
),
],
)