Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add experimental macos support #195

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
3e2e221
Windows shouldn't use FUSE anymore anyways
kubilus1 Dec 24, 2022
c99db64
Double check scenery setups
kubilus1 Dec 24, 2022
0ff0b08
Make sure we are using the current scenery dir
kubilus1 Dec 24, 2022
c21e79e
Read current config
kubilus1 Dec 24, 2022
a001714
Merge branch 'main' into macos
kubilus1 Dec 25, 2022
2d6f080
Merge branch 'main' into macos
kubilus1 Jun 4, 2023
43cc3ae
Required updates.
kubilus1 Jun 4, 2023
372858f
Attempt a CI build
kubilus1 Jun 4, 2023
63a6ffd
Install tooling
kubilus1 Jun 4, 2023
5861536
Fix build target
kubilus1 Jun 4, 2023
703f7d5
Include tk
kubilus1 Jun 5, 2023
2450171
Setup python-tk
kubilus1 Jun 5, 2023
69d4d90
Find tcl
kubilus1 Jun 5, 2023
532a0d2
Find tcl
kubilus1 Jun 5, 2023
418e01f
Find tcl
kubilus1 Jun 5, 2023
0bc7876
Find tcl
kubilus1 Jun 5, 2023
1d61b17
Find tcl
kubilus1 Jun 5, 2023
ad0d916
Updated MacOS changes against the latest main branch
SFAntti Sep 9, 2023
3ead635
stb loading fails diagnostics check on macos
SFAntti Sep 9, 2023
f9cabab
Merge branch 'main' into macos
kubilus1 Oct 17, 2023
60944a6
Merge branch 'macos' of github.com:kubilus1/autoortho into macos
kubilus1 Oct 17, 2023
4e71f32
Add imageio
kubilus1 Oct 17, 2023
b78384e
Universal binary for aoimage.dylib
SFAntti Oct 18, 2023
f2a3257
Merge pull request #382 from SFAntti/main
kubilus1 Oct 18, 2023
8cc56f3
Merge branch 'macos' into macos_prmerge
kubilus1 Oct 18, 2023
ff472eb
Merge pull request #422 from kubilus1/macos_prmerge
kubilus1 Oct 18, 2023
a1d8a5f
Test
kubilus1 Oct 18, 2023
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
42 changes: 42 additions & 0 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,48 @@ jobs:
tag_name: ${{ inputs.relname }}
prerelease: ${{ inputs.prerelease }}

build-macos:
runs-on: macos-latest

env:
VERNAME: ${{ inputs.version }}

steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v3
with:
python-version: '3.10'

- name: Setup
run: |
brew install [email protected]
python3.10 -m pip install -U -r requirements.txt
python3.10 -m pip install -U -r requirements-build.txt

- name: Optionally set internal version separately
if: ${{ inputs.internalver != '' }}
run: |
echo "${{ inputs.internalver }}" > autoortho/.version

- name: Build
run: |
make osx_bin VERSION=${{ env.VERNAME }}

- name: Save artifact
uses: actions/upload-artifact@v3
with:
name: macosbin
path: autoortho_osx_*.bin

- name: Release
if: ${{ inputs.relname != '' }}
uses: softprops/action-gh-release@v1
with:
files: autoortho_osx_*.bin
tag_name: ${{ inputs.relname }}
prerelease: ${{ inputs.prerelease }}


build-windows:
runs-on: windows-latest
Expand Down
21 changes: 20 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,30 @@ jobs:
cd autoortho
pytest --log-level=DEBUG -v test_getortho.py test_pydds.py test_downloader.py

test-macos:
runs-on: macos-latest

steps:
- uses: actions/checkout@v3

- uses: actions/setup-python@v3
with:
python-version: '3.10'

- name: Setup
run: |
python3.10 -m pip install -U pytest
python3.10 -m pip install -U -r requirements.txt

- name: Test
run: |
cd autoortho
pytest --log-level=DEBUG -v test_getortho.py test_pydds.py test_downloader.py


test-windows:
runs-on: windows-latest


steps:
- uses: actions/checkout@v3

Expand Down
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,22 @@ bin: autoortho/.version
--onefile \
./autoortho/__main__.py -o autoortho_lin.bin

autoortho_osx.bin: autoortho/.version
#python3.10 -m nuitka --verbose --verbose-output=nuitka.log
python3 -m nuitka --verbose --verbose-output=nuitka.log \
--macos-app-icon=autoortho/imgs/ao-icon.ico \
--enable-plugin=eventlet \
--enable-plugin=tk-inter \
--tcl-library-dir=/usr/local/lib/tcl8.6 \
--tk-library-dir=/usr/local/lib/tk8.6 \
--include-data-file=./autoortho/.version*=. \
--include-data-file=./autoortho/templates/*.html=templates/ \
--include-data-file=./autoortho/lib/darwin_arm/*.dylib=lib/darwin_arm/ \
--include-data-file=./autoortho/aoimage/*.dylib=aoimage/ \
--include-data-dir=./autoortho/imgs=imgs \
--onefile \
./autoortho/__main__.py -o autoortho_osx.bin

_autoortho_win.exe: autoortho/.version
python3 -m nuitka --verbose --verbose-output=nuitka.log \
--mingw64 \
Expand Down Expand Up @@ -65,6 +81,10 @@ __main__.dist: autoortho/.version
--disable-console \
./autoortho/__main__.py -o autoortho_win.exe

osx_bin: autoortho_osx_$(VERSION).bin
autoortho_osx_$(VERSION).bin: autoortho_osx.bin
mv autoortho_osx.bin $@

win_exe: AutoOrtho_win_$(VERSION).exe
AutoOrtho_win_$(VERSION).exe: __main__.dist
cp autoortho/imgs/ao-icon.ico .
Expand Down
2 changes: 2 additions & 0 deletions autoortho/aoimage/AoImage.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ def open(filename):
_aoi_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),'aoimage.so')
elif platform.system().lower() == 'windows':
_aoi_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),'aoimage.dll')
elif platform.system().lower() == 'darwin':
_aoi_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),'aoimage.dylib')
else:
log.error("System is not supported")
exit()
Expand Down
42 changes: 42 additions & 0 deletions autoortho/aoimage/Makefile.osx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.SUFFIXES: .obj

TARGET=main
JPGT=/opt/libjpeg-turbo/lib64/
#JPGT=/opt/homebrew/opt/jpeg-turbo/lib

HEADERS=$(wildcard *.h)
OBJECTS=aoimage.o


CC=gcc
LD=gcc

CFLAGS+=-O2 -arch arm64 -arch x86_64 -Wall -fPIC -fdiagnostics-color -fvisibility=hidden -I/opt/libjpeg-turbo/include/ \
$(DEFINES)

LDFLAGS=-shared -rdynamic -nodefaultlibs -arch arm64 -arch x86_64 -lpthread
#LIBS=-lturbojpeg
# Statically linked with libjpeg-turbo-3.0.1
LIBS=$(JPGT)/libturbojpeg.a
#LIBS=-L$(JPGT) -lturbojpeg

#CFLAGS+=-O2 -Wall -fPIC -fdiagnostics-color -fvisibility=hidden \
$(DEFINES)
#
#LDFLAGS=-shared -rdynamic -nodefaultlibs -lpthread
#LIBS=-L$(JPGT) -lturbojpeg

all: $(TARGET)

.c.o: $(HEADERS)
$(CC) $(CFLAGS) -c $<

main: main.c aoimage.dylib $(HEADERS)
$(CC) $(CFLAGS) -o main \
main.c aoimage.c $(LIBS)

aoimage.dylib: $(OBJECTS)
$(LD) -o aoimage.dylib $(LDFLAGS) $(OBJECTS) $(LIBS)

clean:
rm -f $(OBJECTS) $(TARGET) aoimage.dylib
Binary file added autoortho/aoimage/aoimage.dylib
Binary file not shown.
8 changes: 8 additions & 0 deletions autoortho/autoortho.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ def diagnose(CFG):
log.warning(f" Maptype: {maptype} FAILED!")
failed = True

log.info(f"Checking DDS file compression:")
dds_compressor = CFG.pydds.compressor.upper()
if dds_compressor != "ISPC" and platform.system().lower() == 'darwin':
log.warning(f" {dds_compressor} FAILED! Not supported on MacOS, use ISPC instead!")
failed = True
else:
log.info(f" {dds_compressor} OK!")

log.info("------------------------------------")
if failed:
log.warning("***************")
Expand Down
19 changes: 16 additions & 3 deletions autoortho/autoortho_fuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import logging
log = logging.getLogger(__name__)

#from fuse import FUSE, FuseOSError, Operations, fuse_get_context
from refuse.high import FUSE, FuseOSError, Operations, fuse_get_context, fuse_exit, _libfuse
#from fuse import FUSE, FuseOSError, Operations, fuse_get_context, _libfuse
from refuse.high import FUSE, FuseOSError, Operations, fuse_get_context, _libfuse

import getortho

Expand Down Expand Up @@ -283,7 +283,7 @@ def statfs(self, path):
# return dict((key, getattr(st, key)) for key in ('f_bavail', 'f_bfree',
# 'f_blocks', 'f_bsize', 'f_favail', 'f_ffree', 'f_files', 'f_flag',
# 'f_frsize', 'f_namemax'))
elif platform.system() == 'Linux':
else:
stv = os.statvfs(full_path)
#log.info(stv)
return dict((key, getattr(stv, key)) for key in ('f_bavail', 'f_bfree',
Expand Down Expand Up @@ -506,3 +506,16 @@ def run(ao, mountpoint, nothreads=False):
#direct_io=True
)
log.info(f"FUSE: Exiting mount {mountpoint}")


if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('root')
parser.add_argument('mount')
args = parser.parse_args()

logging.basicConfig(level=logging.DEBUG)
ao = AutoOrtho(args.root)

fuse = FUSE(ao, args.mount, foreground=True, allow_other=True)
12 changes: 9 additions & 3 deletions autoortho/flighttrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import json
import socket
import threading
import platform
from aoconfig import CFG
import logging
log = logging.getLogger(__name__)
Expand All @@ -23,6 +24,11 @@
app.config['SECRET_KEY'] = 'secret!'
socketio = SocketIO(app)

if platform.system().lower() == 'darwin':
local_host = '127.0.0.1'
else:
local_host = '0.0.0.0'


class FlightTracker(object):

Expand Down Expand Up @@ -192,13 +198,13 @@ def metrics():
def run():
#app.run(host='0.0.0.0', port=CFG.flightdata.webui_port, debug=CFG.general.debug, threaded=True, use_reloader=False)
log.info("Start flighttracker...")
socketio.run(app, host='0.0.0.0', port=int(CFG.flightdata.webui_port))
log.info("Exiting flighttracker ...")
socketio.run(app, host=local_host, port=int(CFG.flightdata.webui_port))
log.info("Exiting flighttracker ...")

def main():
ft.start()
try:
app.run(host='0.0.0.0', debug=False, threaded=True, use_reloader=False)
app.run(host=local_host, debug=False, threaded=True, use_reloader=False)
except KeyboardInterrupt:
print("Shutdown requested.")
finally:
Expand Down
Binary file added autoortho/lib/darwin_arm/libispc_texcomp.dylib
Binary file not shown.
Binary file added autoortho/lib/darwin_arm/libstbdxt.dylib
Binary file not shown.
10 changes: 9 additions & 1 deletion autoortho/pydds.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,19 @@
print("Windows detected")
_stb_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),'lib','windows','stb_dxt.dll')
_ispc_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),'lib','windows','ispc_texcomp.dll')
elif platform.system().lower() == 'darwin':
# Note, issues with STB so disabled for macos
# _stb_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),'lib','darwin_arm','libstbdxt.dylib')
_ispc_path = os.path.join(os.path.dirname(os.path.realpath(__file__)),'lib','darwin_arm','libispc_texcomp.dylib')
else:
print("System is not supported")
exit()

_stb = CDLL(_stb_path)
if platform.system().lower() == 'darwin':
_stb = None
else:
_stb = CDLL(_stb_path)

_ispc = CDLL(_ispc_path)

DDSD_CAPS = 0x00000001 # dwCaps/dwCaps2 is enabled.
Expand Down
1 change: 1 addition & 0 deletions requirements-build.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
nuitka==1.6.6
zstandard
ordered-set
imageio
6 changes: 6 additions & 0 deletions requirements-build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,18 @@
#
# pip-compile requirements-build.in
#
imageio==2.31.5
# via -r requirements-build.in
nuitka==1.6.6
# via -r requirements-build.in
numpy==1.26.1
# via imageio
ordered-set==4.1.0
# via
# -r requirements-build.in
# nuitka
pillow==10.1.0
# via imageio
zstandard==0.21.0
# via
# -r requirements-build.in
Expand Down