Wrote a new setup file (by using cx_freeze)

This commit is contained in:
Manuel Cortez 2019-12-16 16:52:59 -06:00
parent 246a10535c
commit b845e751aa
4 changed files with 49 additions and 123 deletions

View File

@ -65,10 +65,10 @@ build_script:
- "cd ..\\src" - "cd ..\\src"
- "%CMD_IN_ENV% python ..\\doc\\generator.py" - "%CMD_IN_ENV% python ..\\doc\\generator.py"
# Build distributable files. # Build distributable files.
- "%CMD_IN_ENV% pyinstaller main.spec" - "%CMD_IN_ENV% python setup.py build"
- "cd dist\\TWBlue" - "cd dist"
# Zip it all. # Zip it all.
- cmd: 7z a ..\..\..\snapshot_python3.zip * - cmd: 7z a ..\..\snapshot_python3.zip *
artifacts: artifacts:
- path: snapshot_python3.zip - path: snapshot_python3.zip

View File

@ -24,7 +24,7 @@ python-vlc
pypiwin32 pypiwin32
certifi certifi
backports.functools_lru_cache backports.functools_lru_cache
pyinstaller cx_freeze
git+https://github.com/manuelcortez/twython git+https://github.com/manuelcortez/twython
git+https://github.com/manuelcortez/libloader git+https://github.com/manuelcortez/libloader
git+https://github.com/manuelcortez/platform_utils git+https://github.com/manuelcortez/platform_utils

View File

@ -7,13 +7,13 @@ from . import fix_arrow # A few new locales for Three languages in arrow.
from . import fix_libloader # Regenerates comcache properly. from . import fix_libloader # Regenerates comcache properly.
from . import fix_urllib3_warnings # Avoiding some SSL warnings related to Twython. from . import fix_urllib3_warnings # Avoiding some SSL warnings related to Twython.
from . import fix_win32com from . import fix_win32com
from . import fix_requests #fix cacert.pem location for TWBlue binary copies #from . import fix_requests #fix cacert.pem location for TWBlue binary copies
def setup(): def setup():
fix_arrow.fix() fix_arrow.fix()
if hasattr(sys, "frozen"): if hasattr(sys, "frozen"):
fix_libloader.fix() fix_libloader.fix()
fix_win32com.fix() fix_win32com.fix()
fix_requests.fix() # fix_requests.fix()
# else: # else:
# fix_requests.fix(False) # fix_requests.fix(False)
fix_urllib3_warnings.fix() fix_urllib3_warnings.fix()

View File

@ -1,131 +1,57 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" Setup file to create executables and distribute the source code of this application. Don't forget this file! """ import sys
############################################################
# Copyright (c) 2014 José Manuel Delicado Alcolea <jmdaweb@gmail.com>
# Copyright (c) 2013, 2014 Manuel Eduardo Cortéz Vallejo <manuel@manuelcortez.net>
#
# 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 2 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/>.
#
############################################################
from setuptools import setup, find_packages
import py2exe
import os
import gettext
import application import application
import platform import platform
from glob import glob import os
import wx from cx_Freeze import setup, Executable
from requests import certs from requests import certs
def get_architecture_files(): def get_architecture_files():
if platform.architecture()[0][:2] == "32": if platform.architecture()[0][:2] == "32":
return [ return ["../windows-dependencies/x86/oggenc2.exe", "../windows-dependencies/x86/bootstrap.exe", "../windows-dependencies/x86/libvlc.dll", "../windows-dependencies/x86/libvlccore.dll", "../windows-dependencies/x86/plugins"]
("", ["../windows-dependencies/x86/oggenc2.exe", "../windows-dependencies/x86/bootstrap.exe", "../windows-dependencies/x86/libvlc.dll", "../windows-dependencies/x86/libvlccore.dll"]),
("Microsoft.VC90.CRT", glob("../windows-dependencies/x86/Microsoft.VC90.CRT/*")),
("Microsoft.VC90.MFC", glob("../windows-dependencies/x86/Microsoft.VC90.MFC/*")),
("plugins", glob("../windows-dependencies/x86/plugins/*/*.dll")),]
elif platform.architecture()[0][:2] == "64": elif platform.architecture()[0][:2] == "64":
return [ return ["../windows-dependencies/x64/oggenc2.exe", "../windows-dependencies/x64/bootstrap.exe", "../windows-dependencies/x64/libvlc.dll", "../windows-dependencies/x64/libvlccore.dll", "../windows-dependencies/x64/plugins"]
("", ["../windows-dependencies/x64/oggenc2.exe", "../windows-dependencies/x64/bootstrap.exe", "../windows-dependencies/x64/libvlc.dll", "../windows-dependencies/x64/libvlccore.dll"]),
("Microsoft.VC90.CRT", glob("../windows-dependencies/x64/Microsoft.VC90.CRT/*")),
("Microsoft.VC90.MFC", glob("../windows-dependencies/x64/Microsoft.VC90.MFC/*")),
("plugins", glob("../windows-dependencies/x64/plugins/*/*.dll")),]
def get_data(): def find_sound_lib_datafiles():
import os
import platform
import sound_lib import sound_lib
import enchant path = os.path.join(sound_lib.__path__[0], 'lib')
if platform.architecture()[0] == '32bit' or platform.system() == 'Darwin':
arch = 'x86'
else:
arch = 'x64'
dest_dir = os.path.join('sound_lib', 'lib', arch)
source = os.path.join(path, arch)
return (source, dest_dir)
def find_accessible_output2_datafiles():
import os
import accessible_output2 import accessible_output2
return [ path = os.path.join(accessible_output2.__path__[0], 'lib')
("", ["conf.defaults", "app-configuration.defaults", "icon.ico"]), dest_dir = os.path.join('accessible_output2', 'lib')
("", [certs.where()]), return (path, dest_dir)
("keys/lib", glob("keys/lib/*.dll")),
("keymaps", glob("keymaps/*.keymap")),
]+get_sounds()+get_locales()+get_documentation()+sound_lib.find_datafiles()+accessible_output2.find_datafiles()+enchant.utils.win32_data_files()+get_architecture_files()+wx_files()+get_dictionaries()
def get_dictionaries(): base = None
return [("share/enchant/myspell", glob("../windows-dependencies/dictionaries/*"))] if sys.platform == 'win32':
base = 'Win32GUI'
def get_documentation (): build_exe_options = dict(
answer = [("documentation", ["documentation/license.txt"])] build_exe="dist",
depth = 20 optimize=1,
for root, dirs, files in os.walk('documentation'): include_msvcr=True,
if depth == 0: zip_include_packages=["accessible_output2", "sound_lib", "arrow"],
break include_files=["icon.ico", "conf.defaults", "app-configuration.defaults", "keymaps", "locales", "sounds", "documentation", ("keys\lib", "keys"), find_sound_lib_datafiles(), find_accessible_output2_datafiles()]+get_architecture_files(),
new = (root, glob(os.path.join(root, "*.html"))) packages=["wxUI"],
answer.append(new) )
depth -= 1
return answer executables = [
Executable('main.py', base=base, targetName="twblue")
def get_sounds(): ]
answer = []
depth = 10 setup(name=application.name,
for root, dirs, files in os.walk('sounds'): version=application.version,
if depth == 0: description=application.description,
break options = {"build_exe": build_exe_options},
new = (root, glob(os.path.join(root, "*.ogg"))) executables=executables
answer.append(new)
depth -= 1
return answer
def get_locales():
answer = []
for root, dirs, files in os.walk('locales'):
new = (root, glob(os.path.join(root, '*.mo')))
answer.append(new)
return answer
def wx_files():
wxDir=wx.__path__[0]
localeMoFiles=set()
for f in glob("locales/*/LC_MESSAGES"):
g=f.replace("locales", "locale")
wxMoFile=os.path.join(wxDir,g,"wxstd.mo")
if os.path.isfile(wxMoFile):
localeMoFiles.add((f,(wxMoFile,)))
lang=os.path.split(os.path.split(f)[0])[1]
if '_' in lang:
lang=lang.split('_')[0]
f=os.path.join('locale',lang,'lc_messages')
g=f.replace("locale", "locales")
wxMoFile=os.path.join(wxDir,f,"wxstd.mo")
if os.path.isfile(wxMoFile):
localeMoFiles.add((g,(wxMoFile,)))
return list(localeMoFiles)
if __name__ == '__main__':
setup(
name = application.name,
author = u", ".join(application.authors),
author_email = application.authorEmail,
version = application.version,
url = application.url,
packages= find_packages(),
data_files = get_data(),
options = {
'py2exe': {
'optimize':2,
'packages': ["pubsub", "pubsub.core", "pubsub.core.kwargs", "dbhash", "oauthlib.oauth1.rfc5849.endpoints.resource", "oauthlib.oauth2.rfc6749.endpoints.resource"],
'dll_excludes': ["MPR.dll", "api-ms-win-core-apiquery-l1-1-0.dll", "api-ms-win-core-console-l1-1-0.dll", "api-ms-win-core-delayload-l1-1-1.dll", "api-ms-win-core-errorhandling-l1-1-1.dll", "api-ms-win-core-file-l1-2-0.dll", "api-ms-win-core-handle-l1-1-0.dll", "api-ms-win-core-heap-obsolete-l1-1-0.dll", "api-ms-win-core-libraryloader-l1-1-1.dll", "api-ms-win-core-localization-l1-2-0.dll", "api-ms-win-core-processenvironment-l1-2-0.dll", "api-ms-win-core-processthreads-l1-1-1.dll", "api-ms-win-core-profile-l1-1-0.dll", "api-ms-win-core-registry-l1-1-0.dll", "api-ms-win-core-synch-l1-2-0.dll", "api-ms-win-core-sysinfo-l1-2-0.dll", "api-ms-win-security-base-l1-2-0.dll", "api-ms-win-core-heap-l1-2-0.dll", "api-ms-win-core-interlocked-l1-2-0.dll", "api-ms-win-core-localization-obsolete-l1-1-0.dll", "api-ms-win-core-string-l1-1-0.dll", "api-ms-win-core-string-obsolete-l1-1-0.dll", "WLDAP32.dll", "MSVCP90.dll", "CRYPT32.dll", "mfc90.dll"],
'compressed': True
},
},
windows = [
{
'script': 'main.py',
'dest_base': 'TWBlue',
}
],
install_requires = [
]
) )