Skip to content

Commit

Permalink
Added Mac installer script (creates a .pkg)
Browse files Browse the repository at this point in the history
  • Loading branch information
goodtimes-code committed Mar 2, 2024
1 parent f81653f commit c17f448
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,11 @@ See *config_laser1.txt* for more optional settings.
- /effect/color_change/[r, g, b]
- 0 to 255: color intensity of red, green and blue

# Run installer (create binary)
## For Mac & Linux
- `cd osc-receiver`
- `venv/bin/pyinstaller --onefile --paths=venv/lib/python3.12/site-packages main.py`
- Run binary: `/dist/main`
# Create installer
## For Mac
- Increase version number in `make_installer_mac.sh`
- Run: `make_installer_mac.sh`
- Find Mac package in `dist/osc2laser.pkg`

# Support & Community
Join our [Community](https://community.goodtimes.technology/c/osc2laser/5) to discuss your ideas and issues.
Expand Down
10 changes: 10 additions & 0 deletions osc-receiver/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@
import configparser
import global_data

# Set the working directory to the directory of the executable
if getattr(sys, 'frozen', False):
# If the application is frozen (packaged by PyInstaller), set the working directory to the executable's directory
application_path = os.path.dirname(sys.executable)
else:
# If the application is not frozen, assume it's running from the source code directory
application_path = os.path.dirname(os.path.abspath(__file__))

os.chdir(application_path)

# Initialization
logging.basicConfig(encoding='utf-8', level=logging.DEBUG)

Expand Down
38 changes: 38 additions & 0 deletions osc-receiver/make_installer_mac.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/Bash
venv/bin/pyinstaller --onefile --paths=venv/lib/python3.12/site-packages main.py

mkdir -p dist/osc2laser.app/Contents/MacOS

mv dist/main dist/osc2laser.app/Contents/MacOS/osc2laser
chmod +x dist/osc2laser.app/Contents/MacOS/osc2laser

cp config_laser1.txt dist/osc2laser.app/Contents/MacOS/
cp libHeliosDacAPI.so dist/osc2laser.app/Contents/MacOS/

cat > dist/osc2laser.app/Contents/Info.plist <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
<string>osc2laser</string>
<key>CFBundleExecutable</key>
<string>osc2laser</string>
<key>CFBundleIdentifier</key>
<string>tchnology.goodtimes.osc2laser</string>
<key>CFBundleName</key>
<string>osc2laser</string>
<key>CFBundleVersion</key>
<string>1.0.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
</dict>
</plist>
EOF

# hdiutil create -volname "osc2laser" -srcfolder dist/osc2laser.app -ov -format UDZO dist/osc2laser.dmg

pkgbuild --component dist/osc2laser.app --install-location /Applications dist/osc2laser.pkg

# Otherwise the .pkg won't install to /Applications
rm -Rf dist/osc2laser.app

0 comments on commit c17f448

Please sign in to comment.