Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 30 additions & 116 deletions pyfa.spec
Original file line number Diff line number Diff line change
@@ -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
)
68 changes: 68 additions & 0 deletions pyoxidizer.bzl
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 14 additions & 0 deletions requirements_no_wx.txt
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions requirements_test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
logbook==1.7.0.post0
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down