Skip to content

Instantly share code, notes, and snippets.

@alptugan
Last active April 21, 2019 03:20
Show Gist options
  • Save alptugan/9bee8ca021d8ee6e96d05e0581b341f5 to your computer and use it in GitHub Desktop.
Save alptugan/9bee8ca021d8ee6e96d05e0581b341f5 to your computer and use it in GitHub Desktop.
Python Scripts
Reference:
https://www.metachris.com/2015/11/create-standalone-mac-os-x-applications-with-python-and-py2app/
// Create virtual environment
virtualenv venv
. venv/bin/activate
// Install py2app
pip install -U git+https://github.com/metachris/py2app.git@master
py2applet --make-setup app_name.py
// This creates a setup.py file as following
"""
This is a setup.py script generated by py2applet
Usage:
python setup.py py2app
"""
from setuptools import setup
APP = ['infostationBeta.py']
DATA_FILES = []
APP_NAME = 'YOUR_APP_NAME'
OPTIONS = {'argv_emulation': True,
'iconfile': 'infostation_logo.icns',
'plist': {
'CFBundleName': APP_NAME,
'CFBundleDisplayName': APP_NAME,
'CFBundleGetInfoString': "Send messages to dot matrix led",
'CFBundleIdentifier': "com.filikatasarim.infostation",
'CFBundleVersion': "0.1.0",
'CFBundleShortVersionString': "0.1.0",
'NSHumanReadableCopyright': u"Copyright © 2017, Filika Interactive, All Rights Reserved"
}
}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
python setup.py py2app -A
rm -rf build dist
python setup.py py2app
def get_ip_address(ifname):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
return socket.inet_ntoa(fcntl.ioctl(
s.fileno(),
0x8915, # SIOCGIFADDR
struct.pack('256s', ifname[:15])
)[20:24])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment