mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-25 07:31:07 +00:00
68c2d54c0b
This patch adds support for a mac native build. At the moment it's a fairly simple .app - i.e. so simple as to be unacceptable for a shipping product, but ok for testing and experiment at this point. notably once launched, the app's ui does not respond at all, although its dock icon does allow it to be force-quit. this produces a single .app bundle, which when run will look for a node basedir in ~/.tahoe. If one is not found, one will be created in ~/Library/Application Support/Allmydata Tahoe, and that will be symlinked to ~/.tahoe if the basedir is lacking basic config (introducer.furl and root_dir.cap) then the wx config wizard will be launched to log into an account and to set up those files. if a webport file is not found, the default value of 8123 will be written into it. once the node has started running, a webbrowser will be opened to the webish interface at the users root_dir note that, once configured, the node runs as the main thread of the .app, no daemonisation is done, twistd is not involved. the binary itself, from within the .app bundle, i.e. "Allmydata Tahoe.app/Contents/MacOS/Allmydata Tahoe" can be used from the command line and functions as the 'tahoe' executable would in a unix environment, with one exception - when launched with no args it triggers the default behaviour of running a node, and if necessary config wizard, as if the user had launched the .app one other gotcha to be aware of is that symlinking to this binary from some other place in ones $PATH will most likely not work. when I tried this, something - wx I believe - exploded, since it seems to use argv[0] to figure out where necessary libraries reside and fails if argv[0] isn't in the .app bundle. it's pretty easy to set up a script a la #!/bin/bash /Blah/blah/blah/Allmydata\ Tahoe.app/Contents/MacOS/Allmydata\ Tahoe "${@}"
47 lines
1.8 KiB
Python
47 lines
1.8 KiB
Python
|
|
def install():
|
|
"""
|
|
This installs a hook into setuptools' pkg_resources infrastructure, so that resource
|
|
files can be found in files relative to the runnin executable, in addition to the
|
|
usual egg and source lookup mechanisms. This overrides the ZipProvider, since that
|
|
is the lookup mechanism triggered within pkg_resources when running code out of a
|
|
py2exe or py2app build's library.zip.
|
|
"""
|
|
import os, sys
|
|
import pkg_resources, zipimport
|
|
|
|
platform_libdirs = {
|
|
'darwin': '../Resources/pkg_resources',
|
|
}
|
|
exedir = os.path.dirname(sys.executable)
|
|
libdir = platform_libdirs.get(sys.platform, 'pkg_resources')
|
|
|
|
class Provider(pkg_resources.ZipProvider):
|
|
|
|
def __init__(self, module):
|
|
self._module_name = module.__name__
|
|
pkg_resources.ZipProvider.__init__(self, module)
|
|
|
|
def get_resource_filename(self, manager, resource_name):
|
|
#print 'get_resource_filename(%s, %s)' % (manager, resource_name)
|
|
path = [exedir, libdir] + self._module_name.split('.') + [resource_name]
|
|
localfile = os.path.join(*path)
|
|
#print ' checking(%s)' % (localfile,)
|
|
if os.path.exists(localfile):
|
|
#print 'found locally'
|
|
return localfile
|
|
else:
|
|
try:
|
|
ret = pkg_resources.ZipProvider.get_resource_filename(self, manager, resource_name)
|
|
#print 'returning %s' % (ret,)
|
|
return ret
|
|
except NotImplementedError:
|
|
print 'get_resource_filename(%s,%s): not found' % (self._module_name, resource_name)
|
|
import traceback
|
|
traceback.print_exc()
|
|
return ''
|
|
|
|
pkg_resources.register_loader_type(zipimport.zipimporter, Provider)
|
|
|
|
|