diff --git a/pyfa.spec b/pyfa.spec index 33fb64e0a..45bb92df6 100644 --- a/pyfa.spec +++ b/pyfa.spec @@ -1,124 +1,38 @@ -# -*- mode: python -*- - -import os -from itertools import chain -import subprocess -import requests.certs -import platform - -os_name = platform.system() -block_cipher = None - -added_files = [ - ('imgs/gui/*.png', 'imgs/gui'), - ('imgs/gui/*.gif', 'imgs/gui'), - ('imgs/icons/*.png', 'imgs/icons'), - ('imgs/renders/*.png', 'imgs/renders'), - ('service/jargon/*.yaml', 'service/jargon'), - ('locale', 'locale'), - (requests.certs.where(), '.'), # is this needed anymore? - ('eve.db', '.'), - ('README.md', '.'), - ('LICENSE', '.'), - ('version.yml', '.'), -] - -icon = None -pathex = [] -upx = True -debug = False - -if os_name == 'Windows': - added_files.extend([ - ('dist_assets/win/pyfa.ico', '.'), - ('dist_assets/win/pyfa.exe.manifest', '.'), - ]) - - icon = 'dist_assets/win/pyfa.ico' - - pathex.extend([ - # Need this, see https://github.com/pyinstaller/pyinstaller/issues/1566 - # To get this, download and install windows 10 SDK - # If not building on Windows 10, this might be optional - r'C:\Program Files (x86)\Windows Kits\10\Redist\ucrt\DLLs\x86' - ]) - -if os_name == 'Darwin': - added_files.extend([ - ('dist_assets/win/pyfa.ico', '.'), # osx only - ]) - - icon = 'dist_assets/mac/pyfa.icns' - -import_these = [ - 'numpy.core._dtype_ctypes', # https://github.com/pyinstaller/pyinstaller/issues/3982 - 'sqlalchemy.ext.baked', # windows build doesn't launch without if when using sqlalchemy 1.3.x - 'pkg_resources.py2_warn' # issue 2156 -] - -# Walk directories that do dynamic importing -paths = ('eos/db/migrations', 'service/conversions') -for root, folders, files in chain.from_iterable(os.walk(path) for path in paths): - for file_ in files: - if file_.endswith(".py") and not file_.startswith("_"): - mod_name = "{}.{}".format( - root.replace("/", "."), - file_.split(".py")[0], - ) - import_these.append(mod_name) - -a = Analysis(['pyfa.py'], - pathex= pathex, - binaries=[], - datas=added_files, - hiddenimports=import_these, - hookspath=['dist_assets/pyinstaller_hooks'], - runtime_hooks=[], - excludes=['Tkinter'], - win_no_prefer_redirects=False, - win_private_assemblies=False, - cipher=block_cipher) - -pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) - +# -*- mode: python ; coding: utf-8 -*- + + +a = Analysis( + ['pyfa.py'], + pathex=[], + binaries=[], + datas=[], + hiddenimports=[], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + noarchive=False, + optimize=0, +) +pyz = PYZ(a.pure) exe = EXE( pyz, a.scripts, - exclude_binaries=True, - name='pyfa', - debug=debug, - strip=False, - upx=upx, - icon= icon, - # version='win-version-info.txt', - console=False, - contents_directory='app', -) - -coll = COLLECT( - exe, a.binaries, - a.zipfiles, a.datas, - strip=False, - upx=upx, + [], name='pyfa', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, ) - -if platform.system() == 'Darwin': - info_plist = { - 'NSHighResolutionCapable': 'True', - 'NSPrincipalClass': 'NSApplication', - 'CFBundleName': 'pyfa', - 'CFBundleDisplayName': 'pyfa', - 'CFBundleIdentifier': 'org.pyfaorg.pyfa', - 'CFBundleVersion': '1.2.3', - 'CFBundleShortVersionString': '1.2.3', - } - app = BUNDLE(exe, - name='pyfa.app', - icon=icon, - bundle_identifier=None, - info_plist=info_plist - ) diff --git a/pyoxidizer.bzl b/pyoxidizer.bzl new file mode 100644 index 000000000..90e36f378 --- /dev/null +++ b/pyoxidizer.bzl @@ -0,0 +1,68 @@ +# The following is a build configuration for the PyOxidizer tool. +# It is used to build self-contained executables of Python applications. +# For more info, see: https://pyoxidizer.readthedocs.io/en/stable/ + +def make_exe(): + """ + Defines the executable that will be built. + """ + dist = dists.get_python_distribution( + python_version="3.11", + flavor="standalone_static", + ) + + # Configure the Python interpreter. + python_config = dist.make_python_config() + python_config.run_module = "pyfa" + # To run GUI apps on macOS, we need to run in a specific mode. + python_config.macos_bundle_info_plist = { + "CFBundleIdentifier": "org.pyfa.pyfa", + "CFBundleName": "pyfa", + "CFBundleExecutable": "pyfa", + } + + + # Create the executable definition. + exe = dist.to_python_executable( + name="pyfa", + config=python_config, + ) + + # Add Python source files from the project. + # We recursively glob for all .py files and add them. + exe.add_python_resources(exe.find_python_resources( + search_path=["."], + exclude_matches=[ + "tests/*", + "scripts/*", + "_development/*", + "dist_assets/*", + "*.spec", + "tox.ini", + ] + )) + + # Add data files. Based on `pyfa.spec`. + exe.add_data_files([ + ("imgs", "imgs"), + ("locale", "locale"), + ("staticdata", "staticdata"), + ("cacert.pem", "cacert.pem"), + ("LICENSE", "LICENSE"), + ("version.yml", "version.yml"), + ]) + + return exe + +def make_install(): + """ + Defines what happens during `pyoxidizer install`. + """ + install = default_install_maker() + install.add_executable(make_exe()) + return install + +# Register our targets. The `default=True` means `pyoxidizer build` will +# run the `install` target by default. +register_target("exe", make_exe) +register_target("install", make_install, default=True) diff --git a/requirements.txt b/requirements.txt index 46ed9241b..e604c1c05 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -wxPython==4.2.1 +wxPython==4.2.2 logbook==1.7.0.post0 numpy==1.26.2 matplotlib==3.8.2 diff --git a/requirements_no_wx.txt b/requirements_no_wx.txt new file mode 100644 index 000000000..138903c96 --- /dev/null +++ b/requirements_no_wx.txt @@ -0,0 +1,14 @@ +logbook==1.7.0.post0 +numpy==1.26.2 +matplotlib==3.8.2 +python-dateutil==2.8.2 +requests==2.31.0 +sqlalchemy==1.4.50 +cryptography==42.0.4 +markdown2==2.4.11 +packaging==23.2 +roman==4.1 +beautifulsoup4==4.12.2 +pyyaml==6.0.1 +python-jose==3.3.0 +requests-cache==1.1.1 diff --git a/requirements_test.txt b/requirements_test.txt new file mode 100644 index 000000000..8a5acce89 --- /dev/null +++ b/requirements_test.txt @@ -0,0 +1 @@ +logbook==1.7.0.post0 diff --git a/tox.ini b/tox.ini index 002e3fea8..e42a1fa49 100644 --- a/tox.ini +++ b/tox.ini @@ -3,11 +3,11 @@ envlist = pep8 skipsdist = True [testenv] -passenv = CI TRAVIS TRAVIS_* +passenv = CI,TRAVIS,TRAVIS_* deps = -rrequirements.txt -rrequirements_test.txt -basepython = python3.8 +basepython = python3.12 commands = py.test -vv --cov Pyfa tests2/ [testenv:pep8]