Remove folder

This commit is contained in:
Andros Fenollosa 2017-04-20 01:01:09 +02:00
parent 014ffce8ed
commit 1123666935
112 changed files with 1 additions and 9315 deletions

View File

@ -1,6 +0,0 @@
This directory contains eggs that were downloaded by setuptools to build, test, and run plug-ins.
This directory caches those eggs to prevent repeated downloads.
However, it is safe to delete this directory.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -1,313 +0,0 @@
LICENSE.txt
MANIFEST.in
README.txt
setup.cfg
setup.py
tox.ini
doc/Makefile
doc/changelog.rst
doc/conf.py
doc/dependencies.rst
doc/examples.rst
doc/faq.rst
doc/implementation.rst
doc/index.rst
doc/install.rst
doc/options.rst
doc/py2applet.rst
doc/recipes.rst
doc/tutorial.rst
doc/tweaking.rst
examples/EggInstaller/Egg.icns
examples/EggInstaller/EggInstaller.py
examples/EggInstaller/setup.py
examples/PIL/hello.py
examples/PIL/setup.py
examples/PyObjC/ICSharingWatcher/ICSharingWatcher.py
examples/PyObjC/ICSharingWatcher/TableModelAppDelegate.py
examples/PyObjC/ICSharingWatcher/leases.py
examples/PyObjC/ICSharingWatcher/setup.py
examples/PyObjC/ICSharingWatcher/MainMenu.nib/classes.nib
examples/PyObjC/ICSharingWatcher/MainMenu.nib/info.nib
examples/PyObjC/ICSharingWatcher/MainMenu.nib/keyedobjects.nib
examples/PyObjC/TinyTinyEdit/TinyTinyEdit.py
examples/PyObjC/TinyTinyEdit/setup.py
examples/PyObjC/TinyTinyEdit/MainMenu.nib/classes.nib
examples/PyObjC/TinyTinyEdit/MainMenu.nib/info.nib
examples/PyObjC/TinyTinyEdit/MainMenu.nib/objects.nib
examples/PyObjC/TinyTinyEdit/TinyTinyDocument.nib/classes.nib
examples/PyObjC/TinyTinyEdit/TinyTinyDocument.nib/info.nib
examples/PyObjC/TinyTinyEdit/TinyTinyDocument.nib/objects.nib
examples/PyObjC/pbplugin/PyTestPlugin.py
examples/PyObjC/pbplugin/setup.py
examples/PyObjC/pbplugin/test.py
examples/PyOpenGL/lesson5.py
examples/PyOpenGL/setup.py
examples/PyQt/hello_app/hello.py
examples/PyQt/hello_app/setup.py
examples/PyQt/view_app/main.py
examples/PyQt/view_app/setup.py
examples/PyQt/view_app/view.qml
examples/PySide/hello.py
examples/PySide/setup.py
examples/Tkinter/hello_tk/hello.py
examples/Tkinter/hello_tk/setup.py
examples/embedded_interpreter/simple/hello.py
examples/embedded_interpreter/simple/setup.py
examples/pkg_data/setup.py
examples/pkg_data/use_testpkg.py
examples/pkg_data/testpkg/__init__.py
examples/pkg_data/testpkg/data.txt
examples/pygame/aliens.py
examples/pygame/aliens_bootstrap.py
examples/pygame/setup.py
examples/pygame/English.lproj/aliens.icns
examples/pygame/English.lproj/MainMenu.nib/JavaCompiling.plist
examples/pygame/English.lproj/MainMenu.nib/_MainMenu_EOArchive_English.java
examples/pygame/English.lproj/MainMenu.nib/classes.nib
examples/pygame/English.lproj/MainMenu.nib/info.nib
examples/pygame/English.lproj/MainMenu.nib/keyedobjects.nib
examples/pygame/data/alien1.gif
examples/pygame/data/alien2.gif
examples/pygame/data/alien3.gif
examples/pygame/data/background.gif
examples/pygame/data/bomb.gif
examples/pygame/data/boom.wav
examples/pygame/data/car_door.wav
examples/pygame/data/explosion1.gif
examples/pygame/data/house_lo.wav
examples/pygame/data/player1.gif
examples/pygame/data/shot.gif
examples/simple/hello.py
examples/simple/setup.py
examples/structured/data/datafile.txt
examples/structured/python/myapp.py
examples/structured/python/needsthis.py
examples/structured/setup/setup.py
examples/wxPython/2.4/doodle/doodle.py
examples/wxPython/2.4/doodle/setup.py
examples/wxPython/2.4/doodle/superdoodle.py
examples/wxPython/2.5/doodle/doodle.py
examples/wxPython/2.5/doodle/setup.py
examples/wxPython/2.5/doodle/superdoodle.py
examples/wxPython/2.5/drpython/setup.py
examples/wxPython/2.5/wxGlade/README.txt
examples/wxPython/2.5/wxGlade/setup.py
examples/wxPython/2.5/wxGlade/wxGlade.py
py2app/__init__.py
py2app/build_app.py
py2app/create_appbundle.py
py2app/create_pluginbundle.py
py2app/decorators.py
py2app/filters.py
py2app/script_py2applet.py
py2app/util.py
py2app.egg-info/PKG-INFO
py2app.egg-info/SOURCES.txt
py2app.egg-info/dependency_links.txt
py2app.egg-info/entry_points.txt
py2app.egg-info/not-zip-safe
py2app.egg-info/requires.txt
py2app.egg-info/top_level.txt
py2app/apptemplate/__init__.py
py2app/apptemplate/plist_template.py
py2app/apptemplate/setup.py
py2app/apptemplate/lib/__error__.sh
py2app/apptemplate/lib/site.py
py2app/apptemplate/prebuilt/main-fat
py2app/apptemplate/prebuilt/main-fat3
py2app/apptemplate/prebuilt/main-i386
py2app/apptemplate/prebuilt/main-intel
py2app/apptemplate/prebuilt/main-ppc
py2app/apptemplate/prebuilt/main-ppc64
py2app/apptemplate/prebuilt/main-universal
py2app/apptemplate/prebuilt/main-x86_64
py2app/apptemplate/prebuilt/secondary-fat
py2app/apptemplate/prebuilt/secondary-fat3
py2app/apptemplate/prebuilt/secondary-i386
py2app/apptemplate/prebuilt/secondary-intel
py2app/apptemplate/prebuilt/secondary-ppc
py2app/apptemplate/prebuilt/secondary-ppc64
py2app/apptemplate/prebuilt/secondary-universal
py2app/apptemplate/prebuilt/secondary-x86_64
py2app/apptemplate/src/main.c
py2app/bootstrap/__init__.py
py2app/bootstrap/argv_emulation.py
py2app/bootstrap/argv_inject.py
py2app/bootstrap/boot_aliasapp.py
py2app/bootstrap/boot_aliasplugin.py
py2app/bootstrap/boot_app.py
py2app/bootstrap/boot_plugin.py
py2app/bootstrap/chdir_resource.py
py2app/bootstrap/ctypes_setup.py
py2app/bootstrap/disable_linecache.py
py2app/bootstrap/emulate_shell_environment.py
py2app/bootstrap/import_encodings.py
py2app/bootstrap/path_inject.py
py2app/bootstrap/reset_sys_path.py
py2app/bootstrap/semi_standalone_path.py
py2app/bootstrap/setup_included_subpackages.py
py2app/bootstrap/setup_pkgresource.py
py2app/bootstrap/site_packages.py
py2app/bootstrap/system_path_extras.py
py2app/bootstrap/virtualenv.py
py2app/bootstrap/virtualenv_site_packages.py
py2app/bundletemplate/__init__.py
py2app/bundletemplate/plist_template.py
py2app/bundletemplate/setup.py
py2app/bundletemplate/lib/__error__.sh
py2app/bundletemplate/lib/site.py
py2app/bundletemplate/prebuilt/main-fat
py2app/bundletemplate/prebuilt/main-fat3
py2app/bundletemplate/prebuilt/main-i386
py2app/bundletemplate/prebuilt/main-intel
py2app/bundletemplate/prebuilt/main-ppc
py2app/bundletemplate/prebuilt/main-ppc64
py2app/bundletemplate/prebuilt/main-universal
py2app/bundletemplate/prebuilt/main-x86_64
py2app/bundletemplate/src/main.m
py2app/converters/__init__.py
py2app/converters/coredata.py
py2app/converters/nibfile.py
py2app/recipes/__init__.py
py2app/recipes/cjkcodecs.py
py2app/recipes/ctypes.py
py2app/recipes/docutils.py
py2app/recipes/ftplib.py
py2app/recipes/importlib.py
py2app/recipes/lxml.py
py2app/recipes/matplotlib.py
py2app/recipes/matplotlib_prescript.py
py2app/recipes/mimetypes.py
py2app/recipes/numpy.py
py2app/recipes/os_module.py
py2app/recipes/pydoc.py
py2app/recipes/pyenchant.py
py2app/recipes/pygame.py
py2app/recipes/pyopengl.py
py2app/recipes/pyside.py
py2app/recipes/pyzmq.py
py2app/recipes/qt.conf
py2app/recipes/qt5.py
py2app/recipes/re.py
py2app/recipes/scipy.py
py2app/recipes/setuptools.py
py2app/recipes/sip.py
py2app/recipes/subprocess.py
py2app/recipes/uuid.py
py2app/recipes/virtualenv.py
py2app/recipes/wx.py
py2app/recipes/xml.py
py2app/recipes/PIL/__init__.py
py2app/recipes/PIL/prescript.py
py2app_tests/__init__.py
py2app_tests/bundle_loader.m
py2app_tests/test_app_resources.py
py2app_tests/test_app_with_ctypes.py
py2app_tests/test_app_with_scripts.py
py2app_tests/test_app_with_sharedlib.py
py2app_tests/test_argv_emulation.py
py2app_tests/test_basic_app.py
py2app_tests/test_basic_app_with_encoding.py
py2app_tests/test_basic_app_with_plugin.py
py2app_tests/test_basic_plugin.py
py2app_tests/test_compile_resources.py
py2app_tests/test_email_pkg.py
py2app_tests/test_explicit_includes.py
py2app_tests/test_filters.py
py2app_tests/test_lsenvironment.py
py2app_tests/test_package_data.py
py2app_tests/test_pkg_script.py
py2app_tests/test_plugin_with_scripts.py
py2app_tests/test_py2applet.py
py2app_tests/test_recipe_imports.py
py2app_tests/test_setup.py
py2app_tests/test_shell_environment.py
py2app_tests/tools.py
py2app_tests/app_with_data/main.icns
py2app_tests/app_with_data/main.py
py2app_tests/app_with_data/setup.py
py2app_tests/app_with_data/data1/file1.txt
py2app_tests/app_with_data/data1/file2.txt
py2app_tests/app_with_data/data1/file3.sh
py2app_tests/app_with_data/data2/source.c
py2app_tests/app_with_data/data3/source.c
py2app_tests/app_with_email/main-all.py
py2app_tests/app_with_email/main-compat.py
py2app_tests/app_with_email/main-plain.py
py2app_tests/app_with_email/setup-all.py
py2app_tests/app_with_email/setup-compat.py
py2app_tests/app_with_email/setup-plain.py
py2app_tests/app_with_environment/main.py
py2app_tests/app_with_environment/setup.py
py2app_tests/app_with_scripts/helper1.py
py2app_tests/app_with_scripts/main.py
py2app_tests/app_with_scripts/presetup.py
py2app_tests/app_with_scripts/setup.py
py2app_tests/app_with_scripts/build/libdir/libfoo.dylib.libtool.i386
py2app_tests/app_with_scripts/build/libdir/libfoo.o
py2app_tests/app_with_scripts/src/libfoo.c
py2app_tests/app_with_scripts/src/libfoo.h
py2app_tests/app_with_scripts/src/modfoo.c
py2app_tests/app_with_scripts/subdir/helper2.py
py2app_tests/app_with_shared_ctypes/main.py
py2app_tests/app_with_shared_ctypes/setup.py
py2app_tests/app_with_shared_ctypes/src/sharedlib.c
py2app_tests/app_with_shared_ctypes/src/sharedlib.h
py2app_tests/app_with_sharedlib/main.py
py2app_tests/app_with_sharedlib/mod.c
py2app_tests/app_with_sharedlib/setup.py
py2app_tests/app_with_sharedlib/src/sharedlib.c
py2app_tests/app_with_sharedlib/src/sharedlib.h
py2app_tests/argv_app/main.py
py2app_tests/argv_app/setup-with-urlscheme.py
py2app_tests/argv_app/setup.py
py2app_tests/basic_app/main.py
py2app_tests/basic_app/setup.py
py2app_tests/basic_app/package1/__init__.py
py2app_tests/basic_app/package1/subpackage/__init__.py
py2app_tests/basic_app/package1/subpackage/module.py
py2app_tests/basic_app/package2/__init__.py
py2app_tests/basic_app/package2/sub/__init__.py
py2app_tests/basic_app/package2/sub/data.dat
py2app_tests/basic_app/package3/mod.py
py2app_tests/basic_app2/main-script
py2app_tests/basic_app2/setup.py
py2app_tests/basic_app2/package1/__init__.py
py2app_tests/basic_app2/package1/subpackage/__init__.py
py2app_tests/basic_app2/package1/subpackage/module.py
py2app_tests/basic_app2/package2/__init__.py
py2app_tests/basic_app2/package2/sub/__init__.py
py2app_tests/basic_app2/package2/sub/data.dat
py2app_tests/basic_app_with_encoding/main.py
py2app_tests/basic_app_with_encoding/setup.py
py2app_tests/basic_app_with_encoding/package1/__init__.py
py2app_tests/basic_app_with_encoding/package1/subpackage/__init__.py
py2app_tests/basic_app_with_encoding/package1/subpackage/module.py
py2app_tests/basic_app_with_encoding/package2/__init__.py
py2app_tests/basic_app_with_encoding/package2/sub/__init__.py
py2app_tests/basic_app_with_encoding/package2/sub/data.dat
py2app_tests/basic_app_with_encoding/package3/mod.py
py2app_tests/basic_app_with_plugin/dummy1.qlgenerator
py2app_tests/basic_app_with_plugin/dummy2.mdimporter
py2app_tests/basic_app_with_plugin/main.py
py2app_tests/basic_app_with_plugin/setup.py
py2app_tests/basic_plugin/main.py
py2app_tests/basic_plugin/setup.py
py2app_tests/bundle_loader.dSYM/Contents/Info.plist
py2app_tests/bundle_loader.dSYM/Contents/Resources/DWARF/bundle_loader
py2app_tests/pkg_script_app/quot.py
py2app_tests/pkg_script_app/setup.py
py2app_tests/pkg_script_app/quot/__init__.py
py2app_tests/pkg_script_app/quot/queue.py
py2app_tests/plugin_with_scripts/helper1.py
py2app_tests/plugin_with_scripts/helper2.py
py2app_tests/plugin_with_scripts/main.py
py2app_tests/plugin_with_scripts/setup.py
py2app_tests/resource_compile_app/MainMenu.xib
py2app_tests/resource_compile_app/main.py
py2app_tests/resource_compile_app/setup.py
py2app_tests/shell_app/main.py
py2app_tests/shell_app/setup.py
tools/py2applet/py2applet.py
tools/py2applet/setup.py

View File

@ -1,18 +0,0 @@
[console_scripts]
py2applet = py2app.script_py2applet:main
[distutils.commands]
py2app = py2app.build_app:py2app
[distutils.setup_keywords]
app = py2app.build_app:validate_target
plugin = py2app.build_app:validate_target
[py2app.converter]
datamodel = py2app.converters.coredata:convert_datamodel
mappingmodel = py2app.converters.coredata:convert_mappingmodel
xib = py2app.converters.nibfile:convert_xib
[py2app.recipe]

View File

@ -1,3 +0,0 @@
altgraph>=0.13
modulegraph>=0.14
macholib>=1.8

View File

@ -1 +0,0 @@
py2app

View File

@ -1,34 +0,0 @@
"""
builds Mac OS X application bundles from Python scripts
New keywords for distutils' setup function specify what to build:
app
list of scripts to convert into gui app bundles
py2app options, to be specified in the options keyword to the setup function:
optimize - string or int (0, 1, or 2)
includes - list of module names to include
packages - list of packages to include with subpackages
ignores - list of modules to ignore if they are not found
excludes - list of module names to exclude
dylib_excludes - list of dylibs and/or frameworks to exclude
resources - list of additional files and folders to include
plist - Info.plist template file, dict, or plistlib.Plist
dist_dir - directory where to build the final files
Items in the macosx list can also be
dictionaries to further customize the build process. The following
keys in the dictionary are recognized, most are optional:
script (MACOSX) - list of python scripts (required)
dest_base - directory and basename for the executable
if a directory is contained, must be the same for all targets
"""
import pkg_resources
__version__ = pkg_resources.require('py2app')[0].version
# This makes the py2app command work in the distutils.core.setup() case
import setuptools

View File

@ -1,2 +0,0 @@
from . import setup
from . import plist_template

View File

@ -1,19 +0,0 @@
#!/bin/sh
#
# This is the default apptemplate error script
#
if ( test -n "$2" ) ; then
echo "$1 Error"
echo "An unexpected error has occurred during execution of the main script"
echo ""
echo "$2: $3"
echo ""
echo "See the Console for a detailed traceback."
else
echo "$1 Error"
# Usage: ERRORURL <anURL> <a button label>, this is used by the
# bundle runner to put up a dialog.
#echo "ERRORURL: http://www.python.org/ Visit the Python Website
# echo "ERRORURL: http://homepages.cwi.nl/~jack/macpython/index.html Visit the MacPython Website"
fi

View File

@ -1,132 +0,0 @@
"""
Append module search paths for third-party packages to sys.path.
This is stripped down and customized for use in py2app applications
"""
import sys
# os is actually in the zip, so we need to do this here.
# we can't call it python24.zip because zlib is not a built-in module (!)
_libdir = '/lib/python' + sys.version[:3]
_parent = '/'.join(__file__.split('/')[:-1])
if not _parent.endswith(_libdir):
_parent += _libdir
sys.path.append(_parent + '/site-packages.zip')
# Stuffit decompresses recursively by default, that can mess up py2app bundles,
# add the uncompressed site-packages to the path to compensate for that.
sys.path.append(_parent + '/site-packages')
USER_SITE=None
import os
try:
basestring
except NameError:
basestring = str
def makepath(*paths):
dir = os.path.abspath(os.path.join(*paths))
return dir, os.path.normcase(dir)
for m in sys.modules.values():
f = getattr(m, '__file__', None)
if isinstance(f, basestring) and os.path.exists(f):
m.__file__ = os.path.abspath(m.__file__)
del m
# This ensures that the initial path provided by the interpreter contains
# only absolute pathnames, even if we're running from the build directory.
L = []
_dirs_in_sys_path = {}
dir = dircase = None # sys.path may be empty at this point
for dir in sys.path:
# Filter out duplicate paths (on case-insensitive file systems also
# if they only differ in case); turn relative paths into absolute
# paths.
dir, dircase = makepath(dir)
if not dircase in _dirs_in_sys_path:
L.append(dir)
_dirs_in_sys_path[dircase] = 1
sys.path[:] = L
del dir, dircase, L
_dirs_in_sys_path = None
def _init_pathinfo():
global _dirs_in_sys_path
_dirs_in_sys_path = d = {}
for dir in sys.path:
if dir and not os.path.isdir(dir):
continue
dir, dircase = makepath(dir)
d[dircase] = 1
def addsitedir(sitedir):
global _dirs_in_sys_path
if _dirs_in_sys_path is None:
_init_pathinfo()
reset = 1
else:
reset = 0
sitedir, sitedircase = makepath(sitedir)
if not sitedircase in _dirs_in_sys_path:
sys.path.append(sitedir) # Add path component
try:
names = os.listdir(sitedir)
except os.error:
return
names.sort()
for name in names:
if name[-4:] == os.extsep + "pth":
addpackage(sitedir, name)
if reset:
_dirs_in_sys_path = None
def addpackage(sitedir, name):
global _dirs_in_sys_path
if _dirs_in_sys_path is None:
_init_pathinfo()
reset = 1
else:
reset = 0
fullname = os.path.join(sitedir, name)
try:
with open(fullname) as f:
while 1:
dir = f.readline()
if not dir:
break
if dir[0] == '#':
continue
if dir.startswith("import"):
exec(dir)
continue
if dir[-1] == '\n':
dir = dir[:-1]
dir, dircase = makepath(sitedir, dir)
if not dircase in _dirs_in_sys_path and os.path.exists(dir):
sys.path.append(dir)
_dirs_in_sys_path[dircase] = 1
except IOError:
return
if reset:
_dirs_in_sys_path = None
#sys.setdefaultencoding('utf-8')
#
# Run custom site specific code, if available.
#
try:
import sitecustomize
except ImportError:
pass
#
# Remove sys.setdefaultencoding() so that users cannot change the
# encoding after initialization. The test for presence is needed when
# this module is run as a script, because this code is executed twice.
#
if hasattr(sys, "setdefaultencoding"):
del sys.setdefaultencoding

View File

@ -1,46 +0,0 @@
import sys
import py2app
__all__ = ['infoPlistDict']
def infoPlistDict(CFBundleExecutable, plist={}):
CFBundleExecutable = CFBundleExecutable
version = sys.version[:3]
pdict = dict(
CFBundleDevelopmentRegion='English',
CFBundleDisplayName=plist.get('CFBundleName', CFBundleExecutable),
CFBundleExecutable=CFBundleExecutable,
CFBundleIconFile=CFBundleExecutable,
CFBundleIdentifier='org.pythonmac.unspecified.%s' % (''.join(CFBundleExecutable.split()),),
CFBundleInfoDictionaryVersion='6.0',
CFBundleName=CFBundleExecutable,
CFBundlePackageType='APPL',
CFBundleShortVersionString=plist.get('CFBundleVersion', '0.0'),
CFBundleSignature='????',
CFBundleVersion='0.0',
LSHasLocalizedDisplayName=False,
NSAppleScriptEnabled=False,
NSHumanReadableCopyright='Copyright not specified',
NSMainNibFile='MainMenu',
NSPrincipalClass='NSApplication',
PyMainFileNames=['__boot__'],
PyResourcePackages=[],
PyRuntimeLocations=[(s % version) for s in [
'@executable_path/../Frameworks/Python.framework/Versions/%s/Python',
'~/Library/Frameworks/Python.framework/Versions/%s/Python',
'/Library/Frameworks/Python.framework/Versions/%s/Python',
'/Network/Library/Frameworks/Python.framework/Versions/%s/Python',
'/System/Library/Frameworks/Python.framework/Versions/%s/Python',
]],
)
pdict.update(plist)
pythonInfo = pdict.setdefault('PythonInfoDict', {})
pythonInfo.update(dict(
PythonLongVersion=sys.version,
PythonShortVersion=sys.version[:3],
PythonExecutable=sys.executable,
))
py2appInfo = pythonInfo.setdefault('py2app', {}).update(dict(
version=py2app.__version__,
template='app',
))
return pdict

View File

@ -1,129 +0,0 @@
import os
import re
import sys
import distutils.sysconfig
import distutils.util
gPreBuildVariants = [
{
'name': 'main-universal',
'target': '10.5',
'cflags': '-g -isysroot /Developer/SDKs/MacOSX10.5.sdk -arch i386 -arch ppc -arch ppc64 -arch x86_64',
'cc': 'gcc-4.2',
},
{
'name': 'main-ppc64',
'target': '10.5',
'cflags': '-g -isysroot /Developer/SDKs/MacOSX10.5.sdk -arch ppc64',
'cc': 'gcc-4.2',
},
{
'name': 'main-x86_64',
'target': '10.5',
'cflags': '-g -arch x86_64',
'cc': '/usr/bin/clang',
},
{
'name': 'main-fat3',
'target': '10.5',
'cflags': '-g -isysroot / -arch i386 -arch ppc -arch x86_64',
'cc': 'gcc-4.2',
},
{
'name': 'main-intel',
'target': '10.5',
'cflags': '-g -arch i386 -arch x86_64 -fexceptions',
'cc': '/usr/bin/clang',
},
{
'name': 'main-i386',
'target': '10.4',
'cflags': '-g -arch i386',
'cc': '/usr/bin/clang',
},
{
'name': 'main-ppc',
'target': '10.3',
'cflags': '-g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc',
'cc': 'gcc-4.0',
},
{
'name': 'main-fat',
'target': '10.3',
'cflags': '-g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc',
'cc': 'gcc-4.0',
},
]
def main(all=False, arch=None, secondary=False):
basepath = os.path.dirname(__file__)
builddir = os.path.join(basepath, 'prebuilt')
if not os.path.exists(builddir):
os.makedirs(builddir)
src = os.path.join(basepath, 'src', 'main.c')
cfg = distutils.sysconfig.get_config_vars()
BASE_CFLAGS = cfg['CFLAGS']
BASE_CFLAGS = BASE_CFLAGS.replace('-dynamic', '')
while True:
x = re.sub('-arch\s+\S+', '', BASE_CFLAGS)
if x == BASE_CFLAGS:
break
BASE_CFLAGS=x
while True:
x = re.sub('-isysroot\s+\S+', '', BASE_CFLAGS)
if x == BASE_CFLAGS:
break
BASE_CFLAGS=x
if arch is None:
arch = distutils.util.get_platform().split('-')[-1]
if sys.prefix.startswith('/System') and \
sys.version_info[:2] == (2,5):
arch = "fat"
name = 'main-' + arch
root = None
if all:
for entry in gPreBuildVariants:
dest = os.path.join(builddir, entry['name'])
for replace in (0, 1):
if replace:
dest = os.path.join(builddir, entry['name'].replace('main', 'secondary'))
if not os.path.exists(dest) or (
os.stat(dest).st_mtime < os.stat(src).st_mtime):
if root is None:
fp = os.popen('xcode-select -print-path', 'r')
root = fp.read().strip()
fp.close()
print ("rebuilding %s"%(os.path.basename(dest),))
CC=os.path.join(root, 'usr', 'bin', entry['cc'])
CFLAGS = BASE_CFLAGS + ' ' + entry['cflags'].replace('@@XCODE_ROOT@@', root)
if replace:
CFLAGS += " -DPY2APP_SECONDARY"
os.environ['MACOSX_DEPLOYMENT_TARGET'] = entry['target']
os.system('"%(CC)s" -o "%(dest)s" "%(src)s" %(CFLAGS)s -framework Cocoa' % locals())
if secondary:
name = 'secondary-'
else:
name = 'main-'
dest = os.path.join(
builddir,
name + arch
)
return dest
if __name__ == '__main__':
main(all=True)

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@
""" py2app bootstrap files """

View File

@ -1,272 +0,0 @@
"""
sys.argv emulation
This module starts a basic event loop to collect file- and url-open AppleEvents. Those get
converted to strings and stuffed into sys.argv. When that is done we continue starting
the application.
This is a workaround to convert scripts that expect filenames on the command-line to work
in a GUI environment. GUI applications should not use this feature.
NOTE: This module uses ctypes and not the Carbon modules in the stdlib because the latter
don't work in 64-bit mode and are also not available with python 3.x.
"""
import sys
import os
import time
import ctypes
import struct
class AEDesc (ctypes.Structure):
_fields_ = [
('descKey', ctypes.c_int),
('descContent', ctypes.c_void_p),
]
class EventTypeSpec (ctypes.Structure):
_fields_ = [
('eventClass', ctypes.c_int),
('eventKind', ctypes.c_uint),
]
def _ctypes_setup():
carbon = ctypes.CDLL('/System/Library/Carbon.framework/Carbon')
timer_func = ctypes.CFUNCTYPE(
None, ctypes.c_void_p, ctypes.c_long)
ae_callback = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_void_p,
ctypes.c_void_p, ctypes.c_void_p)
carbon.AEInstallEventHandler.argtypes = [
ctypes.c_int, ctypes.c_int, ae_callback,
ctypes.c_void_p, ctypes.c_char ]
carbon.AERemoveEventHandler.argtypes = [
ctypes.c_int, ctypes.c_int, ae_callback,
ctypes.c_char ]
carbon.AEProcessEvent.restype = ctypes.c_int
carbon.AEProcessEvent.argtypes = [ctypes.c_void_p]
carbon.ReceiveNextEvent.restype = ctypes.c_int
carbon.ReceiveNextEvent.argtypes = [
ctypes.c_long, ctypes.POINTER(EventTypeSpec),
ctypes.c_double, ctypes.c_char,
ctypes.POINTER(ctypes.c_void_p)
]
carbon.AEGetParamDesc.restype = ctypes.c_int
carbon.AEGetParamDesc.argtypes = [
ctypes.c_void_p, ctypes.c_int, ctypes.c_int,
ctypes.POINTER(AEDesc)]
carbon.AECountItems.restype = ctypes.c_int
carbon.AECountItems.argtypes = [ ctypes.POINTER(AEDesc),
ctypes.POINTER(ctypes.c_long) ]
carbon.AEGetNthDesc.restype = ctypes.c_int
carbon.AEGetNthDesc.argtypes = [
ctypes.c_void_p, ctypes.c_long, ctypes.c_int,
ctypes.c_void_p, ctypes.c_void_p ]
carbon.AEGetDescDataSize.restype = ctypes.c_int
carbon.AEGetDescDataSize.argtypes = [ ctypes.POINTER(AEDesc) ]
carbon.AEGetDescData.restype = ctypes.c_int
carbon.AEGetDescData.argtypes = [
ctypes.POINTER(AEDesc),
ctypes.c_void_p,
ctypes.c_int,
]
carbon.FSRefMakePath.restype = ctypes.c_int
carbon.FSRefMakePath.argtypes = [ctypes.c_void_p, ctypes.c_void_p, ctypes.c_uint]
return carbon
def _run_argvemulator(timeout = 60):
# Configure ctypes
carbon = _ctypes_setup()
# Is the emulator running?
running = [True]
timeout = [timeout]
# Configure AppleEvent handlers
ae_callback = carbon.AEInstallEventHandler.argtypes[2]
kAEInternetSuite, = struct.unpack('>i', b'GURL')
kAEISGetURL, = struct.unpack('>i', b'GURL')
kCoreEventClass, = struct.unpack('>i', b'aevt')
kAEOpenApplication, = struct.unpack('>i', b'oapp')
kAEOpenDocuments, = struct.unpack('>i', b'odoc')
keyDirectObject, = struct.unpack('>i', b'----')
typeAEList, = struct.unpack('>i', b'list')
typeChar, = struct.unpack('>i', b'TEXT')
typeFSRef, = struct.unpack('>i', b'fsrf')
FALSE = b'\0'
TRUE = b'\1'
eventLoopTimedOutErr = -9875
kEventClassAppleEvent, = struct.unpack('>i', b'eppc')
kEventAppleEvent = 1
@ae_callback
def open_app_handler(message, reply, refcon):
# Got a kAEOpenApplication event, which means we can
# start up. On some OSX versions this event is even
# sent when an kAEOpenDocuments or kAEOpenURLs event
# is sent later on.
#
# Therefore don't set running to false, but reduce the
# timeout to at most two seconds beyond the current time.
timeout[0] = min(timeout[0], time.time() - start + 2)
#running[0] = False
return 0
carbon.AEInstallEventHandler(kCoreEventClass, kAEOpenApplication,
open_app_handler, 0, FALSE)
@ae_callback
def open_file_handler(message, reply, refcon):
listdesc = AEDesc()
sts = carbon.AEGetParamDesc(message, keyDirectObject, typeAEList,
ctypes.byref(listdesc))
if sts != 0:
print("argvemulator warning: cannot unpack open document event")
running[0] = False
return
item_count = ctypes.c_long()
sts = carbon.AECountItems(ctypes.byref(listdesc), ctypes.byref(item_count))
if sts != 0:
print("argvemulator warning: cannot unpack open document event")
running[0] = False
return
desc = AEDesc()
for i in range(item_count.value):
sts = carbon.AEGetNthDesc(ctypes.byref(listdesc), i+1, typeFSRef, 0, ctypes.byref(desc))
if sts != 0:
print("argvemulator warning: cannot unpack open document event")
running[0] = False
return
sz = carbon.AEGetDescDataSize(ctypes.byref(desc))
buf = ctypes.create_string_buffer(sz)
sts = carbon.AEGetDescData(ctypes.byref(desc), buf, sz)
if sts != 0:
print("argvemulator warning: cannot extract open document event")
continue
fsref = buf
buf = ctypes.create_string_buffer(1024)
sts = carbon.FSRefMakePath(ctypes.byref(fsref), buf, 1023)
if sts != 0:
print("argvemulator warning: cannot extract open document event")
continue
if sys.version_info[0] > 2:
sys.argv.append(buf.value.decode('utf-8'))
else:
sys.argv.append(buf.value)
running[0] = False
return 0
carbon.AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,
open_file_handler, 0, FALSE)
@ae_callback
def open_url_handler(message, reply, refcon):
listdesc = AEDesc()
ok = carbon.AEGetParamDesc(message, keyDirectObject, typeAEList,
ctypes.byref(listdesc))
if ok != 0:
print("argvemulator warning: cannot unpack open document event")
running[0] = False
return
item_count = ctypes.c_long()
sts = carbon.AECountItems(ctypes.byref(listdesc), ctypes.byref(item_count))
if sts != 0:
print("argvemulator warning: cannot unpack open url event")
running[0] = False
return
desc = AEDesc()
for i in range(item_count.value):
sts = carbon.AEGetNthDesc(ctypes.byref(listdesc), i+1, typeChar, 0, ctypes.byref(desc))
if sts != 0:
print("argvemulator warning: cannot unpack open URL event")
running[0] = False
return
sz = carbon.AEGetDescDataSize(ctypes.byref(desc))
buf = ctypes.create_string_buffer(sz)
sts = carbon.AEGetDescData(ctypes.byref(desc), buf, sz)
if sts != 0:
print("argvemulator warning: cannot extract open URL event")
else:
if sys.version_info[0] > 2:
sys.argv.append(buf.value.decode('utf-8'))
else:
sys.argv.append(buf.value)
running[0] = False
return 0
carbon.AEInstallEventHandler(kAEInternetSuite, kAEISGetURL,
open_url_handler, 0, FALSE)
# Remove the funny -psn_xxx_xxx argument
if len(sys.argv) > 1 and sys.argv[1].startswith('-psn_'):
del sys.argv[1]
start = time.time()
now = time.time()
eventType = EventTypeSpec()
eventType.eventClass = kEventClassAppleEvent
eventType.eventKind = kEventAppleEvent
while running[0] and now - start < timeout[0]:
event = ctypes.c_void_p()
sts = carbon.ReceiveNextEvent(1, ctypes.byref(eventType),
start + timeout[0] - now, TRUE, ctypes.byref(event))
if sts == eventLoopTimedOutErr:
break
elif sts != 0:
print("argvemulator warning: fetching events failed")
break
sts = carbon.AEProcessEvent(event)
if sts != 0:
print("argvemulator warning: processing events failed")
break
carbon.AERemoveEventHandler(kCoreEventClass, kAEOpenApplication,
open_app_handler, FALSE)
carbon.AERemoveEventHandler(kCoreEventClass, kAEOpenDocuments,
open_file_handler, FALSE)
carbon.AERemoveEventHandler(kAEInternetSuite, kAEISGetURL,
open_url_handler, FALSE)
def _argv_emulation():
import sys, os
# only use if started by LaunchServices
if os.environ.get('_PY2APP_LAUNCHED_'):
_run_argvemulator()
_argv_emulation()

View File

@ -1,7 +0,0 @@
def _argv_inject(argv):
import sys
# only use if started by LaunchServices
if len(sys.argv) > 1 and sys.argv[1].startswith('-psn'):
sys.argv[1:2] = argv
else:
sys.argv[1:1] = argv

View File

@ -1,42 +0,0 @@
import re, sys
cookie_re = re.compile(b"coding[:=]\s*([-\w.]+)")
if sys.version_info[0] == 2:
default_encoding = 'ascii'
else:
default_encoding = 'utf-8'
def guess_encoding(fp):
for i in range(2):
ln = fp.readline()
m = cookie_re.search(ln)
if m is not None:
return m.group(1).decode('ascii')
return default_encoding
def _run():
global __file__
import os, site
sys.frozen = 'macosx_app'
argv0 = os.path.basename(os.environ['ARGVZERO'])
script = SCRIPT_MAP.get(argv0, DEFAULT_SCRIPT)
sys.argv[0] = __file__ = script
if sys.version_info[0] == 2:
with open(script, 'rU') as fp:
source = fp.read() + "\n"
else:
with open(script, 'rb') as fp:
encoding = guess_encoding(fp)
with open(script, 'r', encoding=encoding) as fp:
source = fp.read() + '\n'
BOM=b'\xef\xbb\xbf'.decode('utf-8')
if source.startswith(BOM):
source = source[1:]
exec(compile(source, script, 'exec'), globals(), globals())

View File

@ -1,45 +0,0 @@
import re, sys
cookie_re = re.compile(b"coding[:=]\s*([-\w.]+)")
if sys.version_info[0] == 2:
default_encoding = 'ascii'
else:
default_encoding = 'utf-8'
def guess_encoding(fp):
for i in range(2):
ln = fp.readline()
m = cookie_re.search(ln)
if m is not None:
return m.group(1).decode('ascii')
return default_encoding
def _run():
global __file__
import os, site
sys.frozen = 'macosx_plugin'
base = os.environ['RESOURCEPATH']
if 'ARGVZERO' in os.environ:
argv0 = os.path.basename(os.environ['ARGVZERO'])
else:
argv0 = None
script = SCRIPT_MAP.get(argv0, DEFAULT_SCRIPT)
sys.argv[0] = __file__ = path = os.path.join(base, script)
if sys.version_info[0] == 2:
with open(path, 'rU') as fp:
source = fp.read() + "\n"
else:
with open(path, 'rb') as fp:
encoding = guess_encoding(fp)
with open(path, 'r', encoding=encoding) as fp:
source = fp.read() + '\n'
BOM=b'\xef\xbb\xbf'.decode('utf-8')
if source.startswith(BOM):
source = source[1:]
exec(compile(source, script, 'exec'), globals(), globals())

View File

@ -1,42 +0,0 @@
import re, sys
cookie_re = re.compile(b"coding[:=]\s*([-\w.]+)")
if sys.version_info[0] == 2:
default_encoding = 'ascii'
else:
default_encoding = 'utf-8'
def guess_encoding(fp):
for i in range(2):
ln = fp.readline()
m = cookie_re.search(ln)
if m is not None:
return m.group(1).decode('ascii')
return default_encoding
def _run():
global __file__
import os, site
sys.frozen = 'macosx_app'
base = os.environ['RESOURCEPATH']
argv0 = os.path.basename(os.environ['ARGVZERO'])
script = SCRIPT_MAP.get(argv0, DEFAULT_SCRIPT)
path = os.path.join(base, script)
sys.argv[0] = __file__ = path
if sys.version_info[0] == 2:
with open(path, 'rU') as fp:
source = fp.read() + "\n"
else:
with open(path, 'rb') as fp:
encoding = guess_encoding(fp)
with open(path, 'r', encoding=encoding) as fp:
source = fp.read() + '\n'
BOM=b'\xef\xbb\xbf'.decode('utf-8')
if source.startswith(BOM):
source = source[1:]
exec(compile(source, path, 'exec'), globals(), globals())

View File

@ -1,45 +0,0 @@
import re, sys
cookie_re = re.compile(b"coding[:=]\s*([-\w.]+)")
if sys.version_info[0] == 2:
default_encoding = 'ascii'
else:
default_encoding = 'utf-8'
def guess_encoding(fp):
for i in range(2):
ln = fp.readline()
m = cookie_re.search(ln)
if m is not None:
return m.group(1).decode('ascii')
return default_encoding
def _run():
global __file__
import os, site
sys.frozen = 'macosx_plugin'
base = os.environ['RESOURCEPATH']
if 'ARGVZERO' in os.environ:
argv0 = os.path.basename(os.environ['ARGVZERO'])
else:
argv0 = None
script = SCRIPT_MAP.get(argv0, DEFAULT_SCRIPT)
__file__ = path = os.path.join(base, script)
if sys.version_info[0] == 2:
with open(path, 'rU') as fp:
source = fp.read() + "\n"
else:
with open(path, 'rb') as fp:
encoding = guess_encoding(fp)
with open(path, 'r', encoding=encoding) as fp:
source = fp.read() + '\n'
BOM=b'\xef\xbb\xbf'.decode('utf-8')
if source.startswith(BOM):
source = source[1:]
exec(compile(source, path, 'exec'), globals(), globals())

View File

@ -1,4 +0,0 @@
def _chdir_resource():
import os
os.chdir(os.environ['RESOURCEPATH'])
_chdir_resource()

View File

@ -1,8 +0,0 @@
def _setup_ctypes():
from ctypes.macholib import dyld
import os
frameworks = os.path.join(os.environ['RESOURCEPATH'], '..', 'Frameworks')
dyld.DEFAULT_FRAMEWORK_FALLBACK.insert(0, frameworks)
dyld.DEFAULT_LIBRARY_FALLBACK.insert(0, frameworks)
_setup_ctypes()

View File

@ -1,7 +0,0 @@
def _disable_linecache():
import linecache
def fake_getline(*args, **kwargs):
return ''
linecache.orig_getline = linecache.getline
linecache.getline = fake_getline
_disable_linecache()

View File

@ -1,79 +0,0 @@
def _emulate_shell_environ():
import os
import sys
import time
import subprocess
if sys.version_info[0] > 2:
env = os.environb
else:
env = os.environ
split_char = b'='
# Start 'login -qf $LOGIN' in a pseudo-tty. The pseudo-tty
# is required to get the right behavior from the shell, without
# a tty the shell won't properly initialize the environment.
#
# NOTE: The code is very carefull w.r.t. getting the login
# name, the application shouldn't crash when the shell information
# cannot be retrieved
master, slave = os.openpty()
pid = os.fork()
try:
login = os.getlogin()
except AttributeError:
try:
login = os.environ['LOGNAME']
except KeyError:
login = None
if login is not None:
if pid == 0:
# Child
os.close(master)
os.setsid()
os.dup2(slave, 0)
os.dup2(slave, 1)
os.dup2(slave, 2)
os.execv('/usr/bin/login', ['login', '-qf', login])
os._exit(42)
else:
# Parent
os.close(slave)
# Echo markers around the actual output of env, that makes it
# easier to find the real data between other data printed
# by the shell.
os.write(master, b'echo "---------";env;echo "-----------"\r\n')
os.write(master, b'exit\r\n')
time.sleep(1)
data = []
b = os.read(master, 2048)
while b:
data.append(b)
b = os.read(master, 2048)
data = b''.join(data)
os.waitpid(pid, 0)
in_data = False
for ln in data.splitlines():
if not in_data:
if ln.strip().startswith(b'--------'):
in_data = True
continue
if ln.startswith(b'--------'):
break
try:
key, value = ln.rstrip().split(split_char, 1)
except:
pass
else:
env[key] = value
_emulate_shell_environ()

View File

@ -1,23 +0,0 @@
def _import_encodings():
import os
import imp
import encodings
import pkgutil
import sys
del sys.path[:2]
import encodings.aliases
encodings.__path__ = pkgutil.extend_path(
encodings.__path__,
encodings.__name__)
#imp.reload(encodings)
import encodings.mac_roman
encodings.aliases.__file__ = os.path.join(
os.path.dirname(encodings.mac_roman.__file__),
'aliases.py' + encodings.mac_roman.__file__[:-1])
imp.reload(encodings.aliases)
imp.reload(encodings)
_import_encodings()

View File

@ -1,3 +0,0 @@
def _path_inject(paths):
import sys
sys.path[:0] = paths

View File

@ -1,7 +0,0 @@
def _reset_sys_path():
# Clear generic sys.path[0]
import sys, os
resources = os.environ['RESOURCEPATH']
while sys.path[0] == resources:
del sys.path[0]
_reset_sys_path()

View File

@ -1,11 +0,0 @@
def _update_path():
import os, sys
resources = os.environ['RESOURCEPATH']
sys.path.append(os.path.join(
resources, 'lib', 'python%d.%d'%(sys.version_info[:2]), 'lib-dynload'))
sys.path.append(os.path.join(
resources, 'lib', 'python%d.%d'%(sys.version_info[:2])))
sys.path.append(os.path.join(
resources, 'lib', 'python%d.%d'%(sys.version_info[:2]), 'site-packages.zip'))
_update_path()

View File

@ -1,20 +0,0 @@
def _included_subpackages(packages):
for pkg in packages:
pass
class Finder (object):
def find_module(self, fullname, path=None):
if fullname in _path_hooks:
return Loader()
class Loader (object):
def load_module(self, fullname):
import imp, os
pkg_dir = os.path.join(os.environ['RESOURCEPATH'],
'lib', 'python%d.%d'%(sys.version_info[:2]))
return imp.load_module(
fullname, None,
os.path.join(pkg_dir, fullname), ('', '', imp.PKG_DIRECTORY))
import sys
sys.meta_path.insert(0, Finder())

View File

@ -1,13 +0,0 @@
def _setup_pkgresources():
import pkg_resources
import os, plistlib
pl = plistlib.readPlist(os.path.join(
os.path.dirname(os.getenv('RESOURCEPATH')), "Info.plist"))
appname = pl.get('CFBundleIdentifier')
if appname is None:
appname = pl['CFBundleDisplayName']
path = os.path.expanduser('~/Library/Caches/%s/python-eggs'%(appname,))
pkg_resources.set_extraction_path(path)
_setup_pkgresources()

View File

@ -1,24 +0,0 @@
def _site_packages():
import site, sys, os
paths = []
prefixes = [sys.prefix]
if sys.exec_prefix != sys.prefix:
prefixes.append(sys.exec_prefix)
for prefix in prefixes:
paths.append(os.path.join(prefix, 'lib', 'python' + sys.version[:3],
'site-packages'))
if os.path.join('.framework', '') in os.path.join(sys.prefix, ''):
home = os.environ.get('HOME')
if home:
paths.append(os.path.join(home, 'Library', 'Python',
sys.version[:3], 'site-packages'))
# Work around for a misfeature in setuptools: easy_install.pth places
# site-packages way to early on sys.path and that breaks py2app bundles.
# NOTE: this is hacks into an undocumented feature of setuptools and
# might stop to work without warning.
sys.__egginsert = len(sys.path)
for path in paths:
site.addsitedir(path)
_site_packages()

View File

@ -1,9 +0,0 @@
""" Add Apple's additional packages to sys.path """
def add_system_python_extras():
import site, sys
ver = '%s.%s'%(sys.version_info[:2])
site.addsitedir('/System/Library/Frameworks/Python.framework/Versions/%s/Extras/lib/python'%(ver,))
add_system_python_extras()

View File

@ -1,33 +0,0 @@
def _fixup_virtualenv(real_prefix):
import sys, os
sys.real_prefix = real_prefix
# NOTE: The adjustment code is based from logic in the site.py
# installed by virtualenv 1.8.2 (but simplified by removing support
# for platforms that aren't supported by py2app)
paths = [os.path.join(sys.real_prefix, 'lib', 'python'+sys.version[:3])]
hardcoded_relative_dirs = paths[:]
plat_path = os.path.join(sys.real_prefix, 'lib', 'python'+sys.version[:3],
'plat-%s' % sys.platform)
if os.path.exists(plat_path):
paths.append(plat_path)
# This is hardcoded in the Python executable, but
# relative to sys.prefix, so we have to fix up:
for path in list(paths):
tk_dir = os.path.join(path, 'lib-tk')
if os.path.exists(tk_dir):
paths.append(tk_dir)
# These are hardcoded in the Apple's Python executable,
# but relative to sys.prefix, so we have to fix them up:
hardcoded_paths = [os.path.join(relative_dir, module)
for relative_dir in hardcoded_relative_dirs
for module in ('plat-darwin', 'plat-mac', 'plat-mac/lib-scriptpackages')]
for path in hardcoded_paths:
if os.path.exists(path):
paths.append(path)
sys.path.extend(paths)

View File

@ -1,32 +0,0 @@
def _site_packages(prefix, real_prefix, global_site_packages):
import site, sys, os
paths = []
prefixes = [sys.prefix]
paths.append(os.path.join(prefix, 'lib', 'python' + sys.version[:3],
'site-packages'))
if os.path.join('.framework', '') in os.path.join(prefix, ''):
home = os.environ.get('HOME')
if home:
paths.append(os.path.join(home, 'Library', 'Python',
sys.version[:3], 'site-packages'))
# Work around for a misfeature in setuptools: easy_install.pth places
# site-packages way to early on sys.path and that breaks py2app bundles.
# NOTE: this is hacks into an undocumented feature of setuptools and
# might stop to work without warning.
sys.__egginsert = len(sys.path)
for path in paths:
site.addsitedir(path)
# Ensure that the global site packages get placed on sys.path after
# the site packages from the virtual environment (this functionality
# is also in virtualenv)
sys.__egginsert = len(sys.path)
if global_site_packages:
site.addsitedir(os.path.join(real_prefix, 'lib', 'python' + sys.version[:3],
'site-packages'))

File diff suppressed because it is too large Load Diff

View File

@ -1,2 +0,0 @@
from . import setup
from . import plist_template

View File

@ -1,12 +0,0 @@
#!/bin/sh
#
# This is the default bundletemplate error script
# Note that this DOES NOT present a GUI dialog, because
# it has no output on stdout, and has a return value of 0.
#
if ( test -n "$2" ) ; then
echo "[$1] Unexpected Exception:" 1>&2
echo "$2: $3" 1>&2
else
echo "[$1] Could not find a suitable Python runtime" 1>&2
fi

View File

@ -1,132 +0,0 @@
"""
Append module search paths for third-party packages to sys.path.
This is stripped down and customized for use in py2app applications
"""
import sys
# os is actually in the zip, so we need to do this here.
# we can't call it python24.zip because zlib is not a built-in module (!)
_libdir = '/lib/python' + sys.version[:3]
_parent = '/'.join(__file__.split('/')[:-1])
if not _parent.endswith(_libdir):
_parent += _libdir
sys.path.append(_parent + '/site-packages.zip')
# Stuffit decompresses recursively by default, that can mess up py2app bundles,
# add the uncompressed site-packages to the path to compensate for that.
sys.path.append(_parent + '/site-packages')
USER_SITE=None
import os
try:
basestring
except NameError:
basestring = str
def makepath(*paths):
dir = os.path.abspath(os.path.join(*paths))
return dir, os.path.normcase(dir)
for m in sys.modules.values():
f = getattr(m, '__file__', None)
if isinstance(f, basestring) and os.path.exists(f):
m.__file__ = os.path.abspath(m.__file__)
del m
# This ensures that the initial path provided by the interpreter contains
# only absolute pathnames, even if we're running from the build directory.
L = []
_dirs_in_sys_path = {}
dir = dircase = None # sys.path may be empty at this point
for dir in sys.path:
# Filter out duplicate paths (on case-insensitive file systems also
# if they only differ in case); turn relative paths into absolute
# paths.
dir, dircase = makepath(dir)
if not dircase in _dirs_in_sys_path:
L.append(dir)
_dirs_in_sys_path[dircase] = 1
sys.path[:] = L
del dir, dircase, L
_dirs_in_sys_path = None
def _init_pathinfo():
global _dirs_in_sys_path
_dirs_in_sys_path = d = {}
for dir in sys.path:
if dir and not os.path.isdir(dir):
continue
dir, dircase = makepath(dir)
d[dircase] = 1
def addsitedir(sitedir):
global _dirs_in_sys_path
if _dirs_in_sys_path is None:
_init_pathinfo()
reset = 1
else:
reset = 0
sitedir, sitedircase = makepath(sitedir)
if not sitedircase in _dirs_in_sys_path:
sys.path.append(sitedir) # Add path component
try:
names = os.listdir(sitedir)
except os.error:
return
names.sort()
for name in names:
if name[-4:] == os.extsep + "pth":
addpackage(sitedir, name)
if reset:
_dirs_in_sys_path = None
def addpackage(sitedir, name):
global _dirs_in_sys_path
if _dirs_in_sys_path is None:
_init_pathinfo()
reset = 1
else:
reset = 0
fullname = os.path.join(sitedir, name)
try:
with open(fullname) as f:
while 1:
dir = f.readline()
if not dir:
break
if dir[0] == '#':
continue
if dir.startswith("import"):
exec(dir)
continue
if dir[-1] == '\n':
dir = dir[:-1]
dir, dircase = makepath(sitedir, dir)
if not dircase in _dirs_in_sys_path and os.path.exists(dir):
sys.path.append(dir)
_dirs_in_sys_path[dircase] = 1
except IOError:
return
if reset:
_dirs_in_sys_path = None
#sys.setdefaultencoding('utf-8')
#
# Run custom site specific code, if available.
#
try:
import sitecustomize
except ImportError:
pass
#
# Remove sys.setdefaultencoding() so that users cannot change the
# encoding after initialization. The test for presence is needed when
# this module is run as a script, because this code is executed twice.
#
if hasattr(sys, "setdefaultencoding"):
del sys.setdefaultencoding

View File

@ -1,51 +0,0 @@
import sys
import py2app
__all__ = ['infoPlistDict']
def infoPlistDict(CFBundleExecutable, plist={}):
CFBundleExecutable = CFBundleExecutable
NSPrincipalClass = ''.join(CFBundleExecutable.split())
version = sys.version[:3]
pdict = dict(
CFBundleDevelopmentRegion='English',
CFBundleDisplayName=plist.get('CFBundleName', CFBundleExecutable),
CFBundleExecutable=CFBundleExecutable,
CFBundleIconFile=CFBundleExecutable,
CFBundleIdentifier='org.pythonmac.unspecified.%s' % (NSPrincipalClass,),
CFBundleInfoDictionaryVersion='6.0',
CFBundleName=CFBundleExecutable,
CFBundlePackageType='BNDL',
CFBundleShortVersionString=plist.get('CFBundleVersion', '0.0'),
CFBundleSignature='????',
CFBundleVersion='0.0',
LSHasLocalizedDisplayName=False,
NSAppleScriptEnabled=False,
NSHumanReadableCopyright='Copyright not specified',
NSMainNibFile='MainMen',
NSPrincipalClass=NSPrincipalClass,
PyMainFileNames=['__boot__'],
PyResourcePackages=[ (s % version) for s in [
'lib/python%s',
'lib/python%s/lib-dynload',
'lib/python%s/site-packages.zip',
]] + [ 'lib/python%s.zip' % version.replace('.', '') ],
PyRuntimeLocations=[(s % version) for s in [
'@executable_path/../Frameworks/Python.framework/Versions/%s/Python',
'~/Library/Frameworks/Python.framework/Versions/%s/Python',
'/Library/Frameworks/Python.framework/Versions/%s/Python',
'/Network/Library/Frameworks/Python.framework/Versions/%s/Python',
'/System/Library/Frameworks/Python.framework/Versions/%s/Python',
]],
)
pdict.update(plist)
pythonInfo = pdict.setdefault('PythonInfoDict', {})
pythonInfo.update(dict(
PythonLongVersion=sys.version,
PythonShortVersion=sys.version[:3],
PythonExecutable=sys.executable,
))
py2appInfo = pythonInfo.setdefault('py2app', {}).update(dict(
version=py2app.__version__,
template='bundle',
))
return pdict

View File

@ -1,122 +0,0 @@
import os
import re
import sys
import distutils.sysconfig
import distutils.util
gPreBuildVariants = [
{
'name': 'main-universal',
'target': '10.5',
'cflags': '-isysroot @@XCODE_ROOT@@/SDKs/MacOSX10.5.sdk -arch i386 -arch ppc -arch ppc64 -arch x86_64',
'cc': 'gcc-4.2',
},
{
'name': 'main-ppc64',
'target': '10.5',
'cflags': '-isysroot @@XCODE_ROOT@@/SDKs/MacOSX10.5.sdk -arch ppc64',
'cc': 'gcc-4.2',
},
{
'name': 'main-x86_64',
'target': '10.5',
'cflags': '-isysroot / -arch x86_64',
'cc': 'clang',
},
{
'name': 'main-fat3',
'target': '10.5',
'cflags': '-isysroot / -arch i386 -arch ppc -arch x86_64',
'cc': 'gcc-4.2',
},
{
'name': 'main-intel',
'target': '10.5',
'cflags': '-isysroot / -arch i386 -arch x86_64',
'cc': 'clang',
},
{
'name': 'main-i386',
'target': '10.3',
#'cflags': '-isysroot @@XCODE_ROOT@@/SDKs/MacOSX10.4u.sdk -arch i386',
'cflags': '-arch i386 -isysroot /',
'cc': 'clang',
},
{
'name': 'main-ppc',
'target': '10.3',
'cflags': '-isysroot @@XCODE_ROOT@@/SDKs/MacOSX10.4u.sdk -arch ppc',
'cc': 'gcc-4.0',
},
{
'name': 'main-fat',
'target': '10.3',
'cflags': '-isysroot @@XCODE_ROOT@@/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc',
'cc': 'gcc-4.0',
},
]
def main(all=False, arch=None):
basepath = os.path.dirname(__file__)
builddir = os.path.join(basepath, 'prebuilt')
if not os.path.exists(builddir):
os.makedirs(builddir)
src = os.path.join(basepath, 'src', 'main.m')
cfg = distutils.sysconfig.get_config_vars()
BASE_CFLAGS = cfg['CFLAGS']
BASE_CFLAGS = BASE_CFLAGS.replace('-dynamic', '')
BASE_CFLAGS += ' -bundle -framework Foundation -framework AppKit'
while True:
x = re.sub('-arch\s+\S+', '', BASE_CFLAGS)
if x == BASE_CFLAGS:
break
BASE_CFLAGS=x
while True:
x = re.sub('-isysroot\s+\S+', '', BASE_CFLAGS)
if x == BASE_CFLAGS:
break
BASE_CFLAGS=x
if arch is None:
arch = distutils.util.get_platform().split('-')[-1]
if sys.prefix.startswith('/System') and \
sys.version_info[:2] == (2,5):
arch = "fat"
name = 'main-' + arch
root = None
if all:
for entry in gPreBuildVariants:
if (not all) and entry['name'] != name: continue
dest = os.path.join(builddir, entry['name'])
if not os.path.exists(dest) or (
os.stat(dest).st_mtime < os.stat(src).st_mtime):
if root is None:
fp = os.popen('xcode-select -print-path', 'r')
root = fp.read().strip()
fp.close()
print ("rebuilding %s"%(entry['name']))
#CC=os.path.join(root, 'usr', 'bin', entry['cc'])
CC=entry['cc']
CFLAGS = BASE_CFLAGS + ' ' + entry['cflags'].replace('@@XCODE_ROOT@@', root)
os.environ['MACOSX_DEPLOYMENT_TARGET'] = entry['target']
os.system('"%(CC)s" -o "%(dest)s" "%(src)s" %(CFLAGS)s' % locals())
dest = os.path.join(
builddir,
'main-' + arch
)
return dest
if __name__ == '__main__':
main(all=True)

View File

@ -1,692 +0,0 @@
//
// main.m
// apptemplate
//
// Created by Bob Ippolito on Mon September 20 2004.
// Copyright (c) 2004 Bob Ippolito. All rights reserved.
//
#import <Foundation/Foundation.h>
#include <mach-o/dyld.h>
#include <mach-o/loader.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/syslimits.h>
#include <crt_externs.h>
#include <wchar.h>
#include <locale.h>
#include <langinfo.h>
#include <objc/objc-class.h>
//
// Constants
//
NSString *ERR_CANNOT_SAVE_LOCALE = @"Cannot save locale information";
NSString *ERR_REALLYBADTITLE = @"The bundle could not be launched.";
NSString *ERR_TITLEFORMAT = @"%@ has encountered a fatal error, and will now terminate.";
NSString *ERR_PYRUNTIMELOCATIONS = @"The Info.plist file must have a PyRuntimeLocations array containing string values for preferred Python runtime locations. These strings should be \"otool -L\" style mach ids; \"@executable_stub\" and \"~\" prefixes will be translated accordingly.";
NSString *ERR_NOPYTHONRUNTIME = @"A Python runtime could be located. You may need to install a framework build of Python, or edit the PyRuntimeLocations array in this bundle's Info.plist file.\rThese runtime locations were attempted:\r\r";
NSString *ERR_NOPYTHONSCRIPT = @"A main script could not be located in the Resources folder.\rThese files were tried:\r\r";
NSString *ERR_LINKERRFMT = @"An internal error occurred while attempting to link with:\r\r%s\r\rSee the Console for a detailed dyld error message";
NSString *ERR_PYTHONEXCEPTION = @"An uncaught exception was raised during execution of the main script:\r\r%@: %@\r\rThis may mean that an unexpected error has occurred, or that you do not have all of the dependencies for this bundle.";
NSString *ERR_COLONPATH = @"Python bundles can not currently run from paths containing a '/' (or ':' from the Terminal).";
#define PYMACAPP_NSIMAGEFLAGS (NSADDIMAGE_OPTION_RETURN_ON_ERROR | NSADDIMAGE_OPTION_WITH_SEARCHING)
#define PYMACAPP_NSLOOKUPSYMBOLINIMAGEFLAGS (NSLOOKUPSYMBOLINIMAGE_OPTION_BIND | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR)
//
// Typedefs
//
#define Py_file_input 257
typedef int PyObject;
typedef int PyThreadState;
typedef enum {PyGILState_LOCKED, PyGILState_UNLOCKED} PyGILState_STATE;
typedef PyGILState_STATE (*PyGILState_EnsurePtr)(void);
typedef void (*PyGILState_ReleasePtr)(PyGILState_STATE);
typedef PyThreadState *(*PyThreadState_SwapPtr)(PyThreadState *);
typedef void (*PyEval_ReleaseLockPtr)(void);
typedef void (*PyErr_ClearPtr)(void);
typedef void (*PyErr_PrintPtr)(void);
typedef int (*PyErr_OccurredPtr)(void);
typedef PyObject *(*PyBytes_FromStringPtr)(const char *);
typedef int (*PyList_InsertPtr)(PyObject *, int, PyObject *);
typedef void (*Py_DecRefPtr)(PyObject *);
typedef void (*Py_SetProgramNamePtr)(const wchar_t *);
typedef int (*Py_IsInitializedPtr)(void);
typedef void (*Py_InitializePtr)(void);
typedef void (*PyEval_InitThreadsPtr)(void);
typedef PyObject *(*PyRun_FilePtr)(FILE *, const char *, int, PyObject *, PyObject *);
typedef PyObject *(*PySys_GetObjectPtr)(const char *);
typedef int *(*PySys_SetArgvPtr)(int argc, char **argv);
typedef PyObject *(*PyObject_StrPtr)(PyObject *);
typedef const char *(*PyBytes_AsStringPtr)(PyObject *);
typedef PyObject *(*PyObject_GetAttrStringPtr)(PyObject *, const char *);
typedef PyObject *(*PyObject_CallMethodPtr)(PyObject *, const char *, const char *, ...);
typedef PyObject *(*PyImport_ImportModulePtr)(char *);
typedef PyObject *(*PyImport_AddModulePtr)(char *);
typedef PyObject *(*PyModule_AddStringConstantPtr)(PyObject *, char *, char *);
typedef PyObject *(*PyModule_AddObjectPtr)(PyObject *, char *, PyObject *);
typedef PyObject *(*PyModule_GetDictPtr)(PyObject *);
typedef void (*PyObject_SetItemPtr)(PyObject *, PyObject *, PyObject *);
typedef wchar_t* (*_Py_DecodeUTF8_surrogateescapePtr)(const char *s, ssize_t size);
//
// Signatures
//
static void DefaultDecRef(PyObject *op);
static int report_error(NSString *err);
static int report_linkEdit_error(const char* name);
static int report_script_error(NSString *err, NSString *errClassName, NSString *errName);
static NSString *pyStandardizePath(NSString *pyLocation);
static BOOL doesPathExist(NSString *path);
static NSString *getBundleName(void);
static NSString *getErrorTitle(NSString *bundleName);
static const char *bundlePath(void);
static NSBundle *bundleBundle(void);
static int pyobjc_main(int argc, char * const *argv, char * const *envp);
//
// Mach-O Constructor
//
static void __attribute__ ((constructor)) _py2app_bundle_load(void);
//
// Implementation
//
static
const char *bundlePath(void) {
int i;
const struct mach_header *myHeader = _dyld_get_image_header_containing_address(&bundlePath);
int count = _dyld_image_count();
for (i = 0; i < count; i++) {
if (_dyld_get_image_header(i) == myHeader) {
return _dyld_get_image_name(i);
}
}
abort();
return NULL;
}
static
NSBundle *bundleBundle(void) {
static NSBundle *myBundle = NULL;
if (!myBundle) {
int i;
NSString *path = [NSString stringWithUTF8String:bundlePath()];
// strip Contents/MacOS/App
for (i = 0; i < 3; i++) {
path = [path stringByDeletingLastPathComponent];
}
myBundle = [[NSBundle alloc] initWithPath:path];
}
return myBundle;
}
//
// THIS WILL NOT WORK WITH Py_TRACE_REFS / Py_DEBUG ON UNLESS USING 2.4 OR LATER!
//
static
void DefaultDecRef(PyObject *op) {
if (op != NULL) {
--(*op);
}
}
static
int report_script_error(NSString *err, NSString *errClassName, NSString *errName) {
return report_error(err);
}
static
int report_error(NSString *err) {
NSLog(@"%@", getErrorTitle(getBundleName()));
NSLog(@"%@", err);
return -1;
}
static
int report_linkEdit_error(const char* name) {
NSLinkEditErrors errorClass;
int errorNumber;
const char *fileName;
const char *errorString;
NSLinkEditError(&errorClass, &errorNumber, &fileName, &errorString);
NSLog(@"%s: %s", name, errorString);
printf("<<<py2app>>>> %s: %s\n", name, errorString);
return report_error([NSString stringWithFormat:ERR_LINKERRFMT, fileName]);
}
static
NSString *pyStandardizePath(NSString *pyLocation) {
if ([pyLocation hasPrefix:@"@executable_path/"]) {
NSMutableArray *newComponents = [[pyLocation pathComponents] mutableCopy];
[newComponents replaceObjectAtIndex:0 withObject:[bundleBundle() privateFrameworksPath]];
pyLocation = [NSString pathWithComponents: newComponents];
}
return [pyLocation stringByStandardizingPath];
};
static
BOOL doesPathExist(NSString *path) {
struct stat sb;
return (stat([path fileSystemRepresentation], &sb) == -1) ? NO : YES;
}
static
NSString *getBundleName(void) {
NSDictionary *infoDictionary = [bundleBundle() infoDictionary];
NSString *bundleName = [infoDictionary objectForKey:@"CFBundleName"];
if (!bundleName) {
bundleName = [infoDictionary objectForKey:@"CFBundleExecutable"];
}
return bundleName;
}
static
NSString *getErrorTitle(NSString *bundleName) {
if (!bundleName) {
return ERR_REALLYBADTITLE;
}
return [NSString stringWithFormat:ERR_TITLEFORMAT,bundleName];
}
static
NSString *getPythonLocation(NSArray *pyLocations) {
// get the runtime locations from the Info.plist
// *does not* inspect DYLD environment variables for overrides, fallbacks, suffixes, etc.
// I don't really consider that a very bad thing, as it makes this search extremely deterministic.
// Note that I use the env variables when the image is actually linked, so what you find here
// may not be what gets linked. If this is the case, you deserve it :)
// find a Python runtime
NSString *pyLocation;
NSEnumerator *pyLocationsEnumerator = [pyLocations objectEnumerator];
while ((pyLocation = [pyLocationsEnumerator nextObject])) {
pyLocation = pyStandardizePath(pyLocation);
if (doesPathExist(pyLocation)) {
return pyLocation;
}
}
return nil;
}
static NSString* getPythonInterpreter(NSString* pyLocation) {
NSBundle* bndl;
NSString* auxName;
bndl = bundleBundle();
auxName = [[bndl infoDictionary] objectForKey:@"PyExecutableName"];
if (!auxName) {
auxName = @"python";
}
return [bndl pathForAuxiliaryExecutable:auxName];
}
static
NSArray *getPythonPathArray(NSDictionary *infoDictionary, NSString *resourcePath) {
NSMutableArray *pythonPathArray = [NSMutableArray arrayWithObject: resourcePath];
NSArray *pyResourcePackages = [infoDictionary objectForKey:@"PyResourcePackages"];
if (pyResourcePackages != nil) {
NSString *pkg;
NSEnumerator *pyResourcePackageEnumerator = [pyResourcePackages objectEnumerator];
while ((pkg = [pyResourcePackageEnumerator nextObject])) {
pkg = [pkg stringByExpandingTildeInPath];
if (![@"/" isEqualToString: [pkg substringToIndex:1]]) {
pkg = [resourcePath stringByAppendingPathComponent:pkg];
}
[pythonPathArray addObject:pkg];
}
}
return pythonPathArray;
}
static
NSString *getMainPyPath(NSDictionary *infoDictionary) {
NSArray *possibleMains = [infoDictionary objectForKey:@"PyMainFileNames"];
if ( !possibleMains )
possibleMains = [NSArray array];
// find main python file. __main__.py seems to be a standard, so we'll go ahead and add defaults.
possibleMains = [possibleMains arrayByAddingObjectsFromArray:[NSArray arrayWithObjects:
@"__main__",
@"__realmain__",
@"Main",
nil]];
NSEnumerator *possibleMainsEnumerator = [possibleMains objectEnumerator];
NSString *mainPyPath = nil;
NSString *nextFileName = nil;
NSString *nextExtension = nil;
NSArray *extensions = [NSArray arrayWithObjects:@".py", @".pyc", @".pyo", @"", nil];
NSMutableArray *runtimeAttempts = [NSMutableArray array];
while ((nextFileName = [possibleMainsEnumerator nextObject])) {
NSEnumerator *nextExtensionEnumerator = [extensions objectEnumerator];
while ((nextExtension = [nextExtensionEnumerator nextObject])) {
[runtimeAttempts addObject:[nextFileName stringByAppendingString:nextExtension]];
}
}
possibleMainsEnumerator = [runtimeAttempts objectEnumerator];
while ((nextFileName = [possibleMainsEnumerator nextObject]) && !mainPyPath) {
mainPyPath = [bundleBundle() pathForResource:nextFileName ofType:nil];
}
if (!mainPyPath) {
NSString *components = [runtimeAttempts componentsJoinedByString:@"\r"];
report_error([ERR_NOPYTHONSCRIPT stringByAppendingString:components]);
}
return mainPyPath;
}
int pyobjc_main(int argc, char * const *argv, char * const *envp) {
char* curenv;
char* curlocale;
NSDictionary *infoDictionary = [bundleBundle() infoDictionary];
if (getenv("PYTHONOPTIMIZE") != NULL) {
unsetenv("PYTHONOPTIMIZE");
}
if (getenv("PYTHONDEBUG") != NULL) {
unsetenv("PYTHONDEBUG");
}
if (getenv("PYTHONDONTWRITEBYTECODE") != NULL) {
unsetenv("PYTHONDONTWRITEBYTECODE");
}
if (getenv("PYTHONIOENCODING") != NULL) {
unsetenv("PYTHONIOENCODING");
}
if (getenv("PYTHONDUMPREFS") != NULL) {
unsetenv("PYTHONDUMPREFS");
}
if (getenv("PYTHONMALLOCSTATS") != NULL) {
unsetenv("PYTHONMALLOCSTATS");
}
/* Disable writing of bytecode files */
setenv("PYTHONDONTWRITEBYTECODE", "1", 1);
NSString *pyLocation = nil;
while (NSIsSymbolNameDefined("_Py_Initialize")) {
// Python is already in-process
NSSymbol sym = NSLookupAndBindSymbol("_Py_Initialize");
if (!sym) {
break;
}
NSModule mod = NSModuleForSymbol(sym);
if (!mod) {
break;
}
const char *python_dylib_path = NSLibraryNameForModule(mod);
if (python_dylib_path) {
pyLocation = [NSString stringWithUTF8String:python_dylib_path];
}
break;
}
NSArray *pyLocations = [infoDictionary objectForKey:@"PyRuntimeLocations"];
if (!pyLocation) {
// Python is not in-process
if (!pyLocations) {
return report_error(ERR_PYRUNTIMELOCATIONS);
}
pyLocation = getPythonLocation(pyLocations);
}
if (!pyLocation) {
NSString *components = [pyLocations componentsJoinedByString:@"\r\r"];
return report_script_error([ERR_NOPYTHONRUNTIME stringByAppendingString:components], nil, nil);
}
// Find our resource path and possible PYTHONPATH
NSString *resourcePath = [bundleBundle() resourcePath];
NSArray *pythonPathArray = getPythonPathArray(infoDictionary, resourcePath);
// find the main script
NSString *mainPyPath = getMainPyPath(infoDictionary);
if (!mainPyPath) {
// error already reported
return -1;
}
// Load the Python dylib (may have already been loaded, that is OK)
const struct mach_header *py_dylib = NSAddImage([pyLocation fileSystemRepresentation], PYMACAPP_NSIMAGEFLAGS);
if (!py_dylib) {
return report_linkEdit_error([pyLocation fileSystemRepresentation]);
}
// Load the symbols we need from Python. We avoid lookups of unicode methods because their
// names are mangled by Python (because of UCS2/UCS4 stuff) and looking them up reliably is
// problematic.
NSSymbol tmpSymbol;
#define LOOKUP_SYMBOL(NAME) \
tmpSymbol = NSLookupSymbolInImage(py_dylib, "_" #NAME, PYMACAPP_NSLOOKUPSYMBOLINIMAGEFLAGS)
#define LOOKUP_DEFINEADDRESS(NAME, ADDRESS) \
NAME ## Ptr NAME = (NAME ## Ptr)ADDRESS
#define LOOKUP_DEFINE(NAME) \
LOOKUP_DEFINEADDRESS(NAME, NSAddressOfSymbol(tmpSymbol))
#define LOOKUP(NAME) \
LOOKUP_SYMBOL(NAME); \
if ( !tmpSymbol ) \
return report_linkEdit_error(#NAME); \
LOOKUP_DEFINE(NAME)
#define OPT_LOOKUP(NAME) \
LOOKUP_SYMBOL(NAME); \
NAME ## Ptr NAME = NULL; \
if (tmpSymbol) { \
NAME = (NAME ## Ptr)NSAddressOfSymbol(tmpSymbol); \
}
LOOKUP_SYMBOL(Py_DecRef);
LOOKUP_DEFINEADDRESS(Py_DecRef, (tmpSymbol ? NSAddressOfSymbol(tmpSymbol) : &DefaultDecRef));
LOOKUP(Py_SetProgramName);
LOOKUP(Py_IsInitialized);
LOOKUP(Py_Initialize);
LOOKUP(PyErr_Clear);
LOOKUP(PyErr_Print);
LOOKUP(PyErr_Occurred);
LOOKUP(PyEval_ReleaseLock);
LOOKUP(PyGILState_Ensure);
LOOKUP(PyGILState_Release);
LOOKUP(PyEval_InitThreads);
LOOKUP(PyRun_File);
LOOKUP(PySys_GetObject);
LOOKUP(PySys_SetArgv);
LOOKUP(PyObject_Str);
LOOKUP(PyList_Insert);
LOOKUP(PyObject_GetAttrString);
LOOKUP(PyObject_CallMethod);
LOOKUP(PyImport_ImportModule);
LOOKUP(PyImport_AddModule);
LOOKUP(PyObject_SetItem);
LOOKUP(PyModule_AddStringConstant);
LOOKUP(PyModule_AddObject);
LOOKUP(PyModule_GetDict);
LOOKUP(PyThreadState_Swap);
OPT_LOOKUP(_Py_DecodeUTF8_surrogateescape);
/* PyBytes / PyString lookups depend of if we're on py3k or not */
PyBytes_AsStringPtr PyBytes_AsString = NULL;
PyBytes_FromStringPtr PyBytes_FromString = NULL;
LOOKUP_SYMBOL(PyBytes_AsString);
int isPy3k = tmpSymbol != NULL;
if (isPy3k) {
PyBytes_AsString = (PyBytes_AsStringPtr)NSAddressOfSymbol(tmpSymbol);
LOOKUP_SYMBOL(PyBytes_FromString);
PyBytes_FromString = (PyBytes_FromStringPtr)NSAddressOfSymbol(tmpSymbol);
}
else {
LOOKUP_SYMBOL(PyString_AsString);
PyBytes_AsString = (PyBytes_AsStringPtr)NSAddressOfSymbol(tmpSymbol);
LOOKUP_SYMBOL(PyString_FromString);
PyBytes_FromString = (PyBytes_FromStringPtr)NSAddressOfSymbol(tmpSymbol);
}
#undef LOOKUP
#undef LOOKUP_DEFINE
#undef LOOKUP_DEFINEADDRESS
#undef LOOKUP_SYMBOL
int was_initialized = Py_IsInitialized();
/*
* When apps are started from the Finder (or anywhere
* except from the terminal), the LANG and LC_* variables
* aren't set in the environment. This confuses Py_Initialize
* when it tries to import the codec for UTF-8,
* therefore explicitly set the locale.
*
* Also set the LC_CTYPE environment variable because Py_Initialize
* reset the locale information using the environment :-(
*/
if (isPy3k) {
curlocale = setlocale(LC_ALL, NULL);
if (curlocale != NULL) {
curlocale = strdup(curlocale);
if (curlocale == NULL) {
(void)report_error(ERR_CANNOT_SAVE_LOCALE);
return -1;
}
}
setlocale(LC_ALL, "en_US.UTF-8");
curenv = getenv("LC_CTYPE");
if (!curenv) {
setenv("LC_CTYPE", "en_US.UTF-8", 1);
}
}
// Set up the environment variables to be transferred
NSMutableDictionary *newEnviron = [NSMutableDictionary dictionary];
[newEnviron setObject:[NSString stringWithFormat:@"%p", bundleBundle()] forKey:@"PYOBJC_BUNDLE_ADDRESS"];
[newEnviron setObject:[NSString stringWithFormat:@"%p", bundleBundle()] forKey:[NSString
stringWithFormat:@"PYOBJC_BUNDLE_ADDRESS%ld", (long)getpid()]];
[newEnviron setObject:resourcePath forKey:@"RESOURCEPATH"];
NSMutableDictionary *oldEnviron = [NSMutableDictionary dictionary];
// bootstrap Python with information about how to find what it needs
// if it is not already initialized
if (!was_initialized) {
// $PREFIX/Python -> $PREFIX
NSString *pythonProgramName = [pyLocation stringByDeletingLastPathComponent];
NSString* interpreter = getPythonInterpreter(pyLocation);
struct stat sb;
if (lstat([interpreter fileSystemRepresentation], &sb) == 0) {
if(!((sb.st_mode & S_IFLNK) == S_IFLNK)) {
setenv("PYTHONHOME", [resourcePath fileSystemRepresentation], 1);
}
} else {
setenv("PYTHONHOME", [resourcePath fileSystemRepresentation], 1);
}
NSString *pyExecutableName = [infoDictionary objectForKey:@"PyExecutableName"];
if ( !pyExecutableName ) {
pyExecutableName = @"python";
}
pythonProgramName = [[pythonProgramName stringByAppendingPathComponent:@"bin"] stringByAppendingPathComponent:pyExecutableName];
wchar_t wPythonName[PATH_MAX+1];
if (isPy3k) {
mbstowcs(wPythonName, [pythonProgramName fileSystemRepresentation], PATH_MAX+1);
}
else {
const char *cPythonName = [pythonProgramName fileSystemRepresentation];
memcpy(wPythonName, cPythonName, strlen(cPythonName));
}
Py_SetProgramName(wPythonName);
}
// Set new environment variables and save older ones (for nested plugin loading)
NSEnumerator *envEnumerator = [newEnviron keyEnumerator];
NSString *envKey;
while ((envKey = [envEnumerator nextObject])) {
char *keyString = (char *)[envKey UTF8String];
char *oldValue = getenv(keyString);
if (oldValue) {
[oldEnviron setObject:[NSString stringWithUTF8String:oldValue] forKey:envKey];
}
setenv(keyString, (char *)[[newEnviron objectForKey:envKey] UTF8String], 1);
}
int rval = 0;
FILE *mainPyFile = NULL;
Py_Initialize();
PyEval_InitThreads();
if (isPy3k) {
/*
* Reset the environment and locale information
*/
setlocale(LC_CTYPE, curlocale);
free(curlocale);
if (!curenv) {
unsetenv("LC_CTYPE");
}
}
PyGILState_STATE gilState = PyGILState_Ensure();
if (was_initialized) {
// transfer path into existing Python process
PyObject *path = PySys_GetObject("path");
NSEnumerator *pathEnumerator = [pythonPathArray reverseObjectEnumerator];
NSString *curPath;
while ((curPath = [pathEnumerator nextObject])) {
PyObject *b = PyBytes_FromString([curPath UTF8String]);
PyObject *s = PyObject_CallMethod(b, "decode", "s", "utf-8");
PyList_Insert(path, 0, s);
Py_DecRef(b);Py_DecRef(s);
}
// transfer environment variables into existing Python process
PyObject *osModule = PyImport_ImportModule("os");
PyObject *pyenv = PyObject_GetAttrString(osModule, "environ");
Py_DecRef(osModule);
envEnumerator = [newEnviron keyEnumerator];
while ((envKey = [envEnumerator nextObject])) {
char *keyString = (char *)[envKey UTF8String];
PyObject *b_key = PyBytes_FromString(keyString);
PyObject *b_value = PyBytes_FromString(getenv(keyString));
PyObject *key = PyObject_CallMethod(b_key, "decode", "s", "utf-8");
PyObject *value = PyObject_CallMethod(b_value, "decode", "s", "utf-8");
PyObject_SetItem(pyenv, key, value);
Py_DecRef(b_key);Py_DecRef(key);
Py_DecRef(b_value);Py_DecRef(value);
}
Py_DecRef(pyenv);
}
char *c_mainPyPath = (char *)[mainPyPath fileSystemRepresentation];
mainPyFile = fopen(c_mainPyPath, "r");
if (!mainPyFile) {
rval = report_error([NSString stringWithFormat:@"Could not open main script %@",mainPyPath]);
goto cleanup;
}
if (!was_initialized) {
int i;
NSMutableData *data_argv = [NSMutableData dataWithCapacity:(sizeof(char *) * argc)];
char **argv_new = [data_argv mutableBytes];
if (isPy3k) {
argv_new[0] = (char*)_Py_DecodeUTF8_surrogateescape(c_mainPyPath, strlen(c_mainPyPath));
} else {
argv_new[0] = c_mainPyPath;
}
for (i = 1; i < argc; i++) {
if (isPy3k) {
argv_new[i] = (char*)_Py_DecodeUTF8_surrogateescape(argv[i], strlen(argv[i]));
} else {
argv_new[i] = argv[i];
}
}
argv_new[argc] = NULL;
PySys_SetArgv(argc, argv_new);
}
// create a unique moduleName by CFBundleIdentifier replacing . with _ and prepending __main__
NSString *moduleName = [NSString stringWithFormat:@"__main__%@", [[[infoDictionary objectForKey:@"CFBundleIdentifier"] componentsSeparatedByString:@"."] componentsJoinedByString:@"_"]];
PyObject *module = PyImport_AddModule((char *)[moduleName UTF8String]);
if (!module) {
rval = report_error([NSString stringWithFormat:@"Could not create module '%@'",moduleName]);
goto cleanup;
}
PyModule_AddStringConstant(module, "__file__", c_mainPyPath);
char * builtinsName = isPy3k ? "builtins" : "__builtin__";
PyObject *builtins = PyImport_ImportModule(builtinsName);
PyModule_AddObject(module, "__builtins__", builtins);
PyObject *module_dict = PyModule_GetDict(module);
if (PyErr_Occurred()) {
goto cleanup;
}
PyObject *res = PyRun_File(mainPyFile, c_mainPyPath, Py_file_input, module_dict, module_dict);
if (res) {
Py_DecRef(res);
}
cleanup:
// un-transfer the environment variables
envEnumerator = [newEnviron keyEnumerator];
while ((envKey = [envEnumerator nextObject])) {
char *keyString = (char *)[envKey UTF8String];
NSString *newValue = [oldEnviron objectForKey:envKey];
if (newValue) {
setenv(keyString, [newValue UTF8String], 1);
} else {
unsetenv(keyString);
}
}
if (mainPyFile) {
fclose(mainPyFile);
}
if (PyErr_Occurred()) {
rval = -1;
PyErr_Print();
}
while ( rval ) {
PyObject *exc = PySys_GetObject("last_type");
if ( !exc ) {
rval = report_error([NSString stringWithFormat:ERR_PYTHONEXCEPTION,"<<PyMacAppException>>","The exception went away?"]);
break;
}
PyObject *exceptionClassName = PyObject_GetAttrString(exc, "__name__");
if ( !exceptionClassName ) {
rval = report_error([NSString stringWithFormat:ERR_PYTHONEXCEPTION,"<<PyMacAppException>>","Could not get exception class name?"]);
break;
}
PyObject *v = PySys_GetObject("last_value");
PyObject *exceptionName = NULL;
if ( v )
exceptionName = PyObject_Str(v);
PyObject *b = PyObject_CallMethod(exceptionClassName, "encode", "s", "utf-8");
NSString *nsExceptionClassName = [NSString stringWithCString:PyBytes_AsString(b) encoding:NSUTF8StringEncoding];
Py_DecRef(exceptionClassName);Py_DecRef(b);
NSString *nsExceptionName;
if ( exceptionName ) {
PyObject *b = PyObject_CallMethod(exceptionName, "encode", "s", "utf-8");
nsExceptionName = [NSString stringWithCString:PyBytes_AsString(b) encoding:NSUTF8StringEncoding];
Py_DecRef(exceptionName);Py_DecRef(b);
} else {
nsExceptionName = @"";
}
rval = report_script_error([NSString stringWithFormat:ERR_PYTHONEXCEPTION, nsExceptionClassName, nsExceptionName], nsExceptionClassName, nsExceptionName);
break;
}
PyErr_Clear();
PyGILState_Release(gilState);
if (gilState == PyGILState_LOCKED) {
PyThreadState_Swap(NULL);
PyEval_ReleaseLock();
}
return rval;
}
static
void _py2app_bundle_load(void)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
int argc = 1;
char * const argv[] = { (char *)bundlePath(), NULL };
char * const *envp = *_NSGetEnviron();
(void)pyobjc_main(argc, argv, envp);
[pool release];
}

View File

@ -1,3 +0,0 @@
"""
Resource data converters
"""

View File

@ -1,24 +0,0 @@
"""
Automatic compilation of CoreData model files
"""
import subprocess, os
from py2app.decorators import converts
from py2app.util import momc, mapc
@converts(suffix=".xcdatamodel")
def convert_datamodel(source, destination, dry_run=0):
destination = os.path.splitext(destination)[0] + ".mom"
if dry_run:
return
momc(source, destination)
@converts(suffix=".xcmappingmodel")
def convert_mappingmodel(source, destination, dry_run=0):
destination = destination[:-4] + ".cdm"
if dry_run:
return
mapc(source, destination)

View File

@ -1,72 +0,0 @@
"""
Automatic compilation of XIB files
"""
from __future__ import print_function
import subprocess, os
from py2app.decorators import converts
from py2app.util import check_output
import time
# XXX: _run_nibtool is an experiment while researching an odd
# failure of py2app: when _run_nibtool is None py2app will often
# (but for from everytime) fail when there are NIB files in the
# project. The failure is very odd: writing to sys.stderr fails
# with EGAIN as the errno, and subsequently the interpreter basicly
# crashes.
#
# This workaround seems to fix that issue for now.
#
def _run_nibtool(source, destination):
pid = os.fork()
if pid == 0:
os.setsid()
xit = subprocess.call([_get_ibtool(), '--compile', destination, source])
os._exit(xit)
else:
pid, status = os.waitpid(pid, 0)
if os.WEXITSTATUS(status) != 0:
raise RuntimeError("ibtool failed (%r -> %r)"%(source, destination))
#_run_nibtool = None
gTool = None
def _get_ibtool():
global gTool
if gTool is None:
if os.path.exists('/usr/bin/xcrun'):
try:
gTool = check_output(['/usr/bin/xcrun', '-find', 'ibtool'])[:-1]
except subprocess.CalledProcessError:
raise IOError("Tool 'ibtool' not found")
else:
gTool = 'ibtool'
return gTool
@converts(suffix=".xib")
def convert_xib(source, destination, dry_run=0):
destination = destination[:-4] + ".nib"
print("compile %s -> %s"%(source, destination))
if dry_run:
return
if _run_nibtool is None:
subprocess.check_call([_get_ibtool(), '--compile', destination, source])
else:
_run_nibtool(source, destination)
#time.sleep(1)
@converts(suffix=".nib")
def convert_nib(source, destination, dry_run=0):
destination = destination[:-4] + ".nib"
print("compile %s -> %s"%(source, destination))
if dry_run:
return
if _run_nibtool is None:
subprocess.check_call([_get_ibtool, '--compile', destination, source])
else:
_run_nibtool(source, destination)
#time.sleep(1)

View File

@ -1,55 +0,0 @@
import os
import plistlib
import shutil
import sys
from pkg_resources import resource_filename
import py2app.apptemplate
from py2app.util import makedirs, mergecopy, mergetree, skipscm, make_exec
def create_appbundle(destdir, name, extension='.app', module=py2app.apptemplate,
platform='MacOS', copy=mergecopy, mergetree=mergetree,
condition=skipscm, plist={}, arch=None, redirect_stdout=False):
kw = module.plist_template.infoPlistDict(
plist.get('CFBundleExecutable', name), plist)
app = os.path.join(destdir, kw['CFBundleName'] + extension)
if os.path.exists(app):
# Remove any existing build artifacts to ensure that
# we're getting a clean build
shutil.rmtree(app)
contents = os.path.join(app, 'Contents')
resources = os.path.join(contents, 'Resources')
platdir = os.path.join(contents, platform)
dirs = [contents, resources, platdir]
plist = plistlib.Plist()
plist.update(kw)
plistPath = os.path.join(contents, 'Info.plist')
if os.path.exists(plistPath):
if plist != plistlib.Plist.fromFile(plistPath):
for d in dirs:
shutil.rmtree(d, ignore_errors=True)
for d in dirs:
makedirs(d)
plist.write(plistPath)
srcmain = module.setup.main(arch=arch, secondary=not redirect_stdout)
if sys.version_info[0] == 2 and isinstance(kw['CFBundleExecutable'], unicode):
destmain = os.path.join(platdir, kw['CFBundleExecutable'].encode('utf-8'))
else:
destmain = os.path.join(platdir, kw['CFBundleExecutable'])
with open(os.path.join(contents, 'PkgInfo'), 'w') as fp:
fp.write(
kw['CFBundlePackageType'] + kw['CFBundleSignature']
)
copy(srcmain, destmain)
make_exec(destmain)
mergetree(
resource_filename(module.__name__, 'lib'),
resources,
condition=condition,
copyfn=copy,
)
return app, plist
if __name__ == '__main__':
import sys
create_appbundle('build', sys.argv[1])

View File

@ -1,55 +0,0 @@
import os
import plistlib
import shutil
import sys
from pkg_resources import resource_filename
import py2app.bundletemplate
from py2app.util import makedirs, mergecopy, mergetree, skipscm, make_exec
def create_pluginbundle(destdir, name, extension='.plugin', module=py2app.bundletemplate,
platform='MacOS', copy=mergecopy, mergetree=mergetree,
condition=skipscm, plist={}, arch=None):
kw = module.plist_template.infoPlistDict(
plist.get('CFBundleExecutable', name), plist)
plugin = os.path.join(destdir, kw['CFBundleName'] + extension)
if os.path.exists(plugin):
# Remove any existing build artifacts to ensure
# we're getting a clean build
shutil.rmtree(plugin)
contents = os.path.join(plugin, 'Contents')
resources = os.path.join(contents, 'Resources')
platdir = os.path.join(contents, platform)
dirs = [contents, resources, platdir]
plist = plistlib.Plist()
plist.update(kw)
plistPath = os.path.join(contents, 'Info.plist')
if os.path.exists(plistPath):
if plist != plistlib.Plist.fromFile(plistPath):
for d in dirs:
shutil.rmtree(d, ignore_errors=True)
for d in dirs:
makedirs(d)
plist.write(plistPath)
srcmain = module.setup.main(arch=arch)
if sys.version_info[0] == 2 and isinstance(kw['CFBundleExecutable'], unicode):
destmain = os.path.join(platdir, kw['CFBundleExecutable'].encode('utf-8'))
else:
destmain = os.path.join(platdir, kw['CFBundleExecutable'])
with open(os.path.join(contents, 'PkgInfo'), 'w') as fp:
fp.write(
kw['CFBundlePackageType'] + kw['CFBundleSignature']
)
copy(srcmain, destmain)
make_exec(destmain)
mergetree(
resource_filename(module.__name__, 'lib'),
resources,
condition=condition,
copyfn=copy,
)
return plugin, plist
if __name__ == '__main__':
import sys
create_pluginbundle('build', sys.argv[1])

View File

@ -1,14 +0,0 @@
def converts(suffix):
"""
Use the following convention when writing a file converter::
from py2app.decorators import converts
@converts(suffix=".png")
def convert_png(source_file, destination_file):
pass
"""
def wrapper(func):
func.py2app_suffix=suffix
return func
return wrapper

View File

@ -1,61 +0,0 @@
import os
import sys
from modulegraph import modulegraph
from macholib.util import in_system_path
def has_filename_filter(module):
if isinstance(module, modulegraph.MissingModule):
return True
return getattr(module, 'filename', None) is not None
def not_stdlib_filter(module, prefix=None):
"""
Return False if the module is located in the standard library
"""
if prefix is None:
prefix = sys.prefix
if module.filename is None:
return True
prefix = os.path.join(os.path.realpath(prefix), '')
rp = os.path.realpath(module.filename)
if rp.startswith(prefix):
rest = rp[len(prefix):]
if '/site-python/' in rest:
return True
elif '/site-packages/' in rest:
return True
else:
return False
if os.path.exists(os.path.join(prefix, ".Python")):
# Virtualenv
fn = os.path.join(prefix, "lib", "python%d.%d"%(sys.version_info[:2]), "orig-prefix.txt")
if os.path.exists(fn):
with open(fn, 'rU') as fp:
prefix = fp.read().strip()
if rp.startswith(prefix):
rest = rp[len(prefix):]
if '/site-python/' in rest:
return True
elif '/site-packages/' in rest:
return True
else:
return False
return True
def not_system_filter(module):
"""
Return False if the module is located in a system directory
"""
return not in_system_path(module.filename)
def bundle_or_dylib_filter(module):
"""
Return False if the module does not have a filetype attribute
corresponding to a Mach-O bundle or dylib
"""
return getattr(module, 'filetype', None) in ('bundle', 'dylib')

View File

@ -1,87 +0,0 @@
from py2app.util import imp_find_module
import os, sys, glob
try:
from cStringIO import StringIO
except ImportError:
from io import StringIO
try:
set
except NameError:
from sets import Set as set
try:
basestring
except NameError:
basestring = str
def check(cmd, mf):
m = mf.findNode('Image') or mf.findNode('PIL.Image')
if m is None or m.filename is None:
return None
if mf.findNode('PIL.Image'):
have_PIL = True
else:
have_PIL = False
plugins = set()
visited = set()
for folder in sys.path:
if not isinstance(folder, basestring):
continue
for extra in ('', 'PIL'):
folder = os.path.realpath(os.path.join(folder, extra))
if (not os.path.isdir(folder)) or (folder in visited):
continue
for fn in os.listdir(folder):
if not fn.endswith('ImagePlugin.py'):
continue
mod, ext = os.path.splitext(fn)
try:
sys.path.insert(0, folder)
imp_find_module(mod)
del sys.path[0]
except ImportError:
pass
else:
plugins.add(mod)
visited.add(folder)
s = StringIO('_recipes_pil_prescript(%r)\n' % list(plugins))
for plugin in plugins:
if have_PIL:
mf.implyNodeReference(m, 'PIL.' + plugin)
else:
mf.implyNodeReference(m, plugin)
mf.removeReference(m, 'FixTk')
# Since Imaging-1.1.5, SpiderImagePlugin imports ImageTk conditionally.
# This is not ever used unless the user is explicitly using Tk elsewhere.
sip = mf.findNode('SpiderImagePlugin')
if sip is not None:
mf.removeReference(sip, 'ImageTk')
# The ImageQt plugin should only be usefull when using PyQt, which
# would then be explicitly imported.
# Note: this code doesn't have the right side-effect at the moment
# due to the way the PyQt5 recipe is structured.
sip = mf.findNode('PIL.ImageQt')
if sip is not None:
mf.removeReference(sip, 'PyQt5')
mf.removeReference(sip, 'PyQt5.QtGui')
mf.removeReference(sip, 'PyQt5.QtCore')
mf.removeReference(sip, 'PyQt4')
mf.removeReference(sip, 'PyQt4.QtGui')
mf.removeReference(sip, 'PyQt4.QtCore')
pass
return dict(
prescripts = ['py2app.recipes.PIL.prescript', s],
include = "PIL.JpegPresets", # Dodgy import from PIL.JpegPlugin in Pillow 2.0
flatpackages = [os.path.dirname(m.filename)],
)

View File

@ -1,43 +0,0 @@
def _recipes_pil_prescript(plugins):
try:
import Image
have_PIL = False
except ImportError:
from PIL import Image
have_PIL = True
import sys
def init():
if Image._initialized >= 2:
return
if have_PIL:
try:
import PIL.JpegPresets
sys.modules['JpegPresets'] = PIL.JpegPresets
except ImportError:
pass
for plugin in plugins:
try:
if have_PIL:
try:
# First try absolute import through PIL (for Pillow support)
# only then try relative imports
m = __import__('PIL.' + plugin, globals(), locals(), [])
m = getattr(m, plugin)
sys.modules[plugin] = m
continue
except ImportError:
pass
__import__(plugin, globals(), locals(), [])
except ImportError:
if Image.DEBUG:
print('Image: failed to import')
if Image.OPEN or Image.SAVE:
Image._initialized = 2
return 1
Image.init = init

View File

@ -1,26 +0,0 @@
from . import PIL
from . import ctypes
from . import docutils
from . import ftplib
from . import importlib
from . import lxml
from . import matplotlib
from . import mimetypes
from . import numpy
from . import os_module
from . import pydoc
from . import pyenchant
from . import pygame
from . import pyopengl
from . import pyside
from . import pyzmq
from . import qt5
from . import re
from . import scipy
from . import sip
from . import subprocess
from . import virtualenv
from . import wx
from . import xml
from . import setuptools
from . import uuid

View File

@ -1,7 +0,0 @@
def check(cmd, mf):
name = 'cjkcodecs'
m = mf.findNode(name)
if m is None or m.filename is None:
return None
mf.import_hook(name, m, ['*'])
return dict()

View File

@ -1,9 +0,0 @@
import os
def check(cmd, mf):
m = mf.findNode('ctypes')
if m is None or m.filename is None:
return None
return dict(
prescripts=['py2app.bootstrap.ctypes_setup'],
)

View File

@ -1,9 +0,0 @@
def check(cmd, mf):
m = mf.findNode('docutils')
if m is None or m.filename is None:
return None
for pkg in [
'languages', 'parsers', 'readers', 'writers',
'parsers.rst.directives', 'parsers.rst.languages']:
mf.import_hook('docutils.' + pkg, m, ['*'])
return dict()

View File

@ -1,14 +0,0 @@
import sys
from modulegraph.modulegraph import MissingModule
def check(cmd, mf):
if sys.version_info[0] != 2: return {}
# ftplib has an optional dependency on an external (and likely
# non-existing) SOCKS module.
f = mf.findNode('ftplib')
m = mf.findNode('SOCKS')
if m is not None and f is not None and isinstance(m, MissingModule):
mf.removeReference(f, m)
return {}

View File

@ -1,7 +0,0 @@
def check(cmd, mf):
m = mf.findNode('importlib')
if m:
return dict(expected_missing_imports=set(
['_frozen_importlib_external']))
return None

View File

@ -1,38 +0,0 @@
#
# LXML uses imports from C code (or actually Cython code)
# and those cannot be detected by modulegraph.
# The check function adds the hidden imports to the graph
#
# The dependency list was extracted from lxml 3.0.2
import sys
def check(cmd, mf):
m = mf.findNode('lxml.etree')
if m is not None and m.filename is not None:
mf.import_hook('lxml._elementpath', m)
mf.import_hook('os.path', m)
mf.import_hook('re', m)
mf.import_hook('gzip', m)
if sys.version_info[0] == 2:
mf.import_hook('StringIO', m)
else:
mf.import_hook('io', m)
m = mf.findNode('lxml.objectify')
if m is not None and m.filename is not None:
if sys.version_info[0] == 2:
mf.import_hook('copy_reg', m)
else:
mf.import_hook('copyreg', m)
m = mf.findNode('lxml.isoschematron')
if m is not None and m.filename is not None:
# Not zip-safe (see issue 118)
return dict(packages=['lxml'])
if mf.findNode('lxml') is None:
return None
return {}

View File

@ -1,27 +0,0 @@
import os
def check(cmd, mf):
m = mf.findNode('matplotlib')
if m is None or m.filename is None:
return None
if cmd.matplotlib_backends:
backends = {}
for backend in cmd.matplotlib_backends:
if backend == '-':
pass
elif backend == '*':
mf.import_hook('matplotlib.backends', m, ['*'])
else:
mf.import_hook('matplotlib.backends.backend_%s'%(backend,), m)
else:
backends = {'packages': ['matplotlib']}
return dict(
prescripts=['py2app.recipes.matplotlib_prescript'],
resources=[os.path.join(os.path.dirname(m.filename), 'mpl-data')],
**backends
)

View File

@ -1,2 +0,0 @@
import os
os.environ['MATPLOTLIBDATA'] = os.path.join(os.environ['RESOURCEPATH'], 'mpl-data')

View File

@ -1,4 +0,0 @@
def check(cmd, mf):
m = mf.findNode('mimetypes')
if m:
return dict(expected_missing_imports=set(['winreg']))

View File

@ -1,7 +0,0 @@
def check(cmd, mf):
m = mf.findNode('numpy')
if m is None or m.filename is None:
return None
return dict(
packages = ['numpy']
)

View File

@ -1,4 +0,0 @@
def check(cmd, mf):
m = mf.findNode('os')
if m:
return dict(expected_missing_imports=set(['nt']))

View File

@ -1,12 +0,0 @@
import sys
def check(cmd, mf):
m = mf.findNode('pydoc')
if m is None or m.filename is None:
return None
refs = [
'Tkinter', 'tty', 'BaseHTTPServer', 'mimetools', 'select',
'threading', 'ic', 'getopt', 'tkinter', 'win32',
]
for ref in refs:
mf.removeReference(m, ref)
return dict()

View File

@ -1,28 +0,0 @@
"""
Recipe for pyEnchant <http://pypi.python.org/pypi/pyenchant>
PyEnchant is a python library that wraps a C library
using ctypes, hence the usual way to find the library
won't work.
"""
import os
def check(cmd, mf):
m = mf.findNode('enchant')
if m is None or m.filename is None:
return None
if 'PYENCHANT_LIBRARY_PATH' in os.environ:
libpath = os.environ['PYENCHANT_LIBRARY_PATH']
print("WARNING: using pyEnchant without embedding")
print("WARNING: this is not supported at the moment")
else:
path = os.path.dirname(m.filename)
if not os.path.exists(os.path.join(path, "lib", "libenchant.1.dylib")):
print("WARNING: using pyEnchant without embedding")
print("WARNING: this is not supported at the moment")
# Include the entire package outside of site-packages.zip,
# mostly to avoid trying to extract the C code from the package
return dict(packages=['enchant'])

View File

@ -1,14 +0,0 @@
import os
def check(cmd, mf):
m = mf.findNode('pygame')
if m is None or m.filename is None:
return None
def addpath(f):
return os.path.join(os.path.dirname(m.filename), f)
RESOURCES = ['freesansbold.ttf', 'pygame_icon.tiff', 'pygame_icon.icns']
result = dict(
loader_files = [
('pygame', map(addpath, RESOURCES)),
],
)
return result

View File

@ -1,16 +0,0 @@
from __future__ import absolute_import
import os
def check(cmd, mf):
m = mf.findNode('OpenGL')
if m is None or m.filename is None:
return None
p = os.path.splitext(m.filename)[0] + '.py'
# check to see if it's a patched version that doesn't suck
if os.path.exists(p):
for line in open(p, 'rU'):
if line.startswith('__version__ = '):
return dict()
# otherwise include the whole damned thing
return dict(
packages = ['OpenGL'],
)

View File

@ -1,48 +0,0 @@
# since pkg_resources.py lives next to this file, we need to disambiguate the import
from __future__ import absolute_import
import glob
import os
import pkg_resources
def check(cmd, mf):
name = 'PySide'
m = mf.findNode(name)
if m is None or m.filename is None:
return None
try:
from PySide import QtCore
except ImportError:
print("WARNING: macholib found PySide, but cannot import")
return {}
plugin_dir = QtCore.QLibraryInfo.location(QtCore.QLibraryInfo.PluginsPath)
resources = [pkg_resources.resource_filename('py2app', 'recipes/qt.conf')]
for item in cmd.qt_plugins:
if '/' not in item:
item = item + '/*'
if '*' in item:
for path in glob.glob(os.path.join(plugin_dir, item)):
resources.append((os.path.dirname('qt_plugins' + path[len(plugin_dir):]), [path]))
else:
resources.append((os.path.dirname(os.path.join('qt_plugins', item)), [os.path.join(plugin_dir, item)]))
# PySide dumps some of its shared files
# into /usr/lib, which is a system location
# and those files are therefore not included
# into the app bundle by default.
from macholib.util import NOT_SYSTEM_FILES
import sys
for fn in os.listdir('/usr/lib'):
add=False
if fn.startswith('libpyside-python'):
add=True
elif fn.startswith('libshiboken-python'):
add=True
if add:
NOT_SYSTEM_FILES.append(os.path.join('/usr/lib', fn))
return dict(resources=resources)

View File

@ -1,15 +0,0 @@
def check(cmd, mf):
m = mf.findNode('zmq')
if m is None or m.filename is None:
return None
# PyZMQ is a package that contains
# a shared library. This recipe
# is mostly a workaround for a bug
# in py2app: it copies the dylib into
# the site-packages zipfile and builds
# a non-functionaly application.
return dict(
packages=['zmq']
)

View File

@ -1,3 +0,0 @@
; Qt Configuration file
[Paths]
Plugins = Resources/qt_plugins

View File

@ -1,28 +0,0 @@
import sys
from modulegraph.modulegraph import MissingModule
def check(cmd, mf):
m = mf.findNode('PyQt5')
if m and not isinstance(m, MissingModule):
try:
# PyQt5 with sipconfig module, handled
# by sip recipe
import sipconfig
return None
except ImportError:
pass
# All imports are done from C code, hence not visible
# for modulegraph
# 1. Use of 'sip'
# 2. Use of other modules, datafiles and C libraries
# in the PyQt5 package.
mf.import_hook('sip', m)
if sys.version[0] != 2:
return dict(packages=['PyQt5'],
expected_missing_imports=set(['copy_reg', 'cStringIO', 'StringIO']))
else:
return dict(packages=['PyQt5'])
return None

View File

@ -1,4 +0,0 @@
def check(cmd, mf):
m = mf.findNode('re')
if m:
return dict(expected_missing_imports=set(['sys.getwindowsversion']))

Some files were not shown because too many files have changed in this diff Show More