We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Working directory issues with 2020.1.1 (most likely related to the new run window)
See https://discourse.psychopy.org/t/working-directory-change-with-2020-1-and-later/11143 and https://discourse.psychopy.org/t/both-the-stim3d-py-and-trialhandler-py-programs-with-psychopy-2020-1-1-do-not-run-properly/11201

At least on Mac (have not tested on Windows), since upgrading to 2020.1.1, if you run a script, the working directory is set to /Applications/PsychoPy3.app/Contents/Resources, rather than the directory that contains the script. This completely breaks any script that uses relative paths for relevant files expecting the working directory to be the script's directory. This includes some of the demos (see second link above) and my PyHab project.

In the short run you can just add the following to the top of every file where it matters:

```
import os
os.chdir(os.path.dirname(os.path.realpath(__file__)))
```

but this is basically a kludge and bad for backwards-compatibility. Does it need to be this way or can we get the new running window to use the script's directory as the working directory by default?

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `psychopy/__init__.py`
Content:
```
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 # Part of the PsychoPy library
5 # Copyright (C) 2002-2018 Jonathan Peirce (C) 2019 Open Science Tools Ltd.
6 # Distributed under the terms of the GNU General Public License (GPL).
7 
8 # --------------------------------------------------------------------------
9 # This file is automatically generated during build (do not edit directly).
10 # --------------------------------------------------------------------------
11 
12 import os
13 import sys
14 
15 __version__ = '2020.1.2'
16 __license__ = 'GNU GPLv3 (or more recent equivalent)'
17 __author__ = 'Jonathan Peirce'
18 __author_email__ = 'jon.peirce@gmail.com'
19 __maintainer_email__ = 'jon.peirce@gmail.com'
20 __url__ = 'http://www.psychopy.org/'
21 __download_url__ = 'https://github.com/psychopy/psychopy/releases/'
22 __git_sha__ = 'n/a'
23 __build_platform__ = 'n/a'
24 
25 __all__ = ["gui", "misc", "visual", "core",
26            "event", "data", "sound", "microphone"]
27 
28 # for developers the following allows access to the current git sha from
29 # their repository
30 if __git_sha__ == 'n/a':
31     from subprocess import check_output, PIPE
32     # see if we're in a git repo and fetch from there
33     try:
34         thisFileLoc = os.path.split(__file__)[0]
35         output = check_output(['git', 'rev-parse', '--short', 'HEAD'],
36                               cwd=thisFileLoc, stderr=PIPE)
37     except Exception:
38         output = False
39     if output:
40         __git_sha__ = output.strip()  # remove final linefeed
41 
42 # update preferences and the user paths
43 if 'installing' not in locals():
44     from psychopy.preferences import prefs
45     for pathName in prefs.general['paths']:
46         sys.path.append(pathName)
47 
48     from psychopy.tools.versionchooser import useVersion, ensureMinimal
49 
50 # import readline here to get around an issue with sounddevice
51 # issues GH-2230 GH-2344 GH-2662
52 try:
53     import readline
54 except ImportError:
55     pass  # all that will happen is the stderr/stdout might get redirected
56 
57
```

Path: `setupApp.py`
Content:
```
1 #!/usr/bin/env python
2 ################
3 # see notes at bottom for requirements
4 from __future__ import absolute_import, print_function
5 import glob
6 import os
7 import sys
8 from sys import platform
9 from distutils.core import setup
10 from pkg_resources import parse_version
11 # import versioneer
12 import psychopy
13 version = psychopy.__version__
14 
15 # regenerate __init__.py only if we're in the source repos (not in a zip file)
16 try:
17     import createInitFile  # won't exist in a sdist.zip
18     writeNewInit=True
19 except:
20     writeNewInit=False
21 if writeNewInit:
22     vStr = createInitFile.createInitFile(dist='bdist')
23 
24 #define the extensions to compile if necess
25 packageData = []
26 requires = []
27 
28 if platform != 'darwin':
29     raise RuntimeError("setupApp.py is only for building Mac Standalone bundle")
30 
31 import bdist_mpkg
32 import py2app
33 resources = glob.glob('psychopy/app/Resources/*')
34 resources.append('/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyconfig.h')
35 frameworks = ["libavbin.dylib", "/usr/lib/libxml2.2.dylib", #"libyaml.dylib",
36               "libevent.dylib", "libffi.dylib",
37               "libmp3lame.0.dylib",
38               "/usr/local/Cellar/glfw/3.2.1/lib/libglfw.3.2.dylib",
39               ]
40 opencvLibs = glob.glob(os.path.join(sys.exec_prefix, 'lib', 'libopencv*.2.4.dylib'))
41 frameworks.extend(opencvLibs)
42 
43 import macholib
44 #print("~"*60 + "macholib version: "+macholib.__version__)
45 
46 if parse_version(macholib.__version__) <= parse_version('1.7'):
47     print("Applying macholib patch...")
48     import macholib.dyld
49     import macholib.MachOGraph
50     dyld_find_1_7 = macholib.dyld.dyld_find
51     def dyld_find(name, loader=None, **kwargs):
52         #print("~"*60 + "calling alternate dyld_find")
53         if loader is not None:
54             kwargs['loader_path'] = loader
55         return dyld_find_1_7(name, **kwargs)
56     macholib.MachOGraph.dyld_find = dyld_find
57 
58 includes = ['Tkinter', 'tkFileDialog',
59             'imp', 'subprocess', 'shlex',
60             'shelve',  # for scipy.io
61             '_elementtree', 'pyexpat',  # for openpyxl
62             'hid',
63             'pyo', 'greenlet', 'zmq', 'tornado',
64             'psutil',  # for iohub
65             'tobii_research',  # need tobii_research file and tobiiresearch pkg
66             'pysoundcard', 'soundfile', 'sounddevice', 'readline',
67             'hid',
68             'xlwt',  # writes excel files for pandas
69             'vlc',  # install with pip install python-vlc
70             'msgpack_numpy',
71             'configparser',
72             ]
73 packages = ['wx', 'psychopy',
74             'pyglet', 'pygame',  'pytz', 'OpenGL', 'glfw',
75             'scipy', 'matplotlib', 'lxml', 'xml', 'openpyxl',
76             'moviepy', 'imageio', 'imageio_ffmpeg',
77             '_sounddevice_data', '_soundfile_data',
78             'cffi','pycparser',
79             'PIL',  # 'Image',
80             'objc', 'Quartz', 'AppKit', 'QTKit', 'Cocoa',
81             'Foundation', 'CoreFoundation',
82             'pkg_resources',  # needed for objc
83             'pyolib',
84             'requests', 'certifi', 'cryptography',
85             'pyosf',
86             # for unit testing
87             'coverage',
88             # handy external science libs
89             'serial',
90             'egi', 'pylink', 'tobiiresearch',
91             'pyxid', 'pyxid2', 'ftd2xx',  # ftd2xx is used by cedrus
92             'pandas', 'tables',  # 'cython',
93             'msgpack', 'yaml', 'gevent',  # for ioHub
94             # these aren't needed, but liked
95             'psychopy_ext', 'pyfilesec',
96             'bidi', 'arabic_reshaper',  # for right-left language conversions
97             # for Py3 compatibility
98             'future', 'past', 'lib2to3',
99             'json_tricks',  # allows saving arrays/dates in json
100             'git', 'gitlab',
101             'astunparse', 'esprima',  # for translating/adapting py/JS
102             'pylsl', 'pygaze', 'smite',
103             'cv2',
104             'badapted', 'darc_toolbox',  # adaptive methods from Ben Vincent
105             'questplus',
106             'metapensiero.pj', 'dukpy', 'macropy',
107             ]
108 
109 if sys.version_info.major >= 3:
110     packages.extend(['PyQt5'])
111 else:
112     # not available or not working under Python3:
113     includes.extend(['UserString', 'ioLabs', 'FileDialog'])
114     packages.extend(['PyQt4', 'labjack', 'rusocsci'])
115     # is available but py2app can't seem to find it:
116     packages.extend(['OpenGL'])
117 
118 setup(
119     app=['psychopy/app/psychopyApp.py'],
120     options=dict(py2app=dict(
121             includes=includes,
122             packages=packages,
123             excludes=['bsddb', 'jinja2', 'IPython','ipython_genutils','nbconvert',
124                       'libsz.2.dylib',
125                       # 'stringprep',
126                       'functools32',
127                       ],  # anything we need to forcibly exclude?
128             resources=resources,
129             argv_emulation=True,
130             site_packages=True,
131             frameworks=frameworks,
132             iconfile='psychopy/app/Resources/psychopy.icns',
133             plist=dict(
134                   CFBundleIconFile='psychopy.icns',
135                   CFBundleName               = "PsychoPy3",
136                   CFBundleShortVersionString = version,  # must be in X.X.X format
137                   CFBundleGetInfoString      = "PsychoPy3 "+version,
138                   CFBundleExecutable         = "PsychoPy3",
139                   CFBundleIdentifier         = "org.psychopy.PsychoPy3",
140                   CFBundleLicense            = "GNU GPLv3+",
141                   CFBundleDocumentTypes=[dict(CFBundleTypeExtensions=['*'],
142                                               CFBundleTypeRole='Editor')],
143                   LSEnvironment=dict(PATH="/usr/local/git/bin:/usr/local/bin:"
144                                           "/usr/local:/usr/bin:/usr/sbin"),
145             ),
146     ))  # end of the options dict
147 )
148 
149 
150 # ugly hack for opencv2:
151 # As of opencv 2.4.5 the cv2.so binary used rpath to a fixed
152 # location to find libs and even more annoyingly it then appended
153 # 'lib' to the rpath as well. These were fine for the packaged
154 # framework python but the libs in an app bundle are different.
155 # So, create symlinks so they appear in the same place as in framework python
156 rpath = "dist/PsychoPy3.app/Contents/Resources/"
157 for libPath in opencvLibs:
158     libname = os.path.split(libPath)[-1]
159     realPath = "../../Frameworks/"+libname  # relative path (w.r.t. the fake)
160     fakePath = os.path.join(rpath, "lib", libname)
161     os.symlink(realPath, fakePath)
162 # they even did this for Python lib itself, which is in diff location
163 realPath = "../Frameworks/Python.framework/Python"  # relative to the fake path
164 fakePath = os.path.join(rpath, "Python")
165 os.symlink(realPath, fakePath)
166 
167 if writeNewInit:
168     # remove unwanted info about this system post-build
169     createInitFile.createInitFile(dist=None)
170 
171 # running testApp from within the app raises wx errors
172 # shutil.rmtree("dist/PsychoPy3.app/Contents/Resources/lib/python2.6/psychopy/tests/testTheApp")
173
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/psychopy/__init__.py b/psychopy/__init__.py
--- a/psychopy/__init__.py
+++ b/psychopy/__init__.py
@@ -12,7 +12,7 @@
 import os
 import sys
 
-__version__ = '2020.1.2'
+__version__ = '2020.1.3'
 __license__ = 'GNU GPLv3 (or more recent equivalent)'
 __author__ = 'Jonathan Peirce'
 __author_email__ = 'jon.peirce@gmail.com'
diff --git a/setupApp.py b/setupApp.py
--- a/setupApp.py
+++ b/setupApp.py
@@ -134,10 +134,11 @@
                   CFBundleIconFile='psychopy.icns',
                   CFBundleName               = "PsychoPy3",
                   CFBundleShortVersionString = version,  # must be in X.X.X format
-                  CFBundleGetInfoString      = "PsychoPy3 "+version,
+                  CFBundleVersion            = version,
                   CFBundleExecutable         = "PsychoPy3",
                   CFBundleIdentifier         = "org.psychopy.PsychoPy3",
                   CFBundleLicense            = "GNU GPLv3+",
+                  NSHumanReadableCopyright   = "Open Science Tools Ltd.",
                   CFBundleDocumentTypes=[dict(CFBundleTypeExtensions=['*'],
                                               CFBundleTypeRole='Editor')],
                   LSEnvironment=dict(PATH="/usr/local/git/bin:/usr/local/bin:"

{"golden_diff": "diff --git a/psychopy/__init__.py b/psychopy/__init__.py\n--- a/psychopy/__init__.py\n+++ b/psychopy/__init__.py\n@@ -12,7 +12,7 @@\n import os\n import sys\n \n-__version__ = '2020.1.2'\n+__version__ = '2020.1.3'\n __license__ = 'GNU GPLv3 (or more recent equivalent)'\n __author__ = 'Jonathan Peirce'\n __author_email__ = 'jon.peirce@gmail.com'\ndiff --git a/setupApp.py b/setupApp.py\n--- a/setupApp.py\n+++ b/setupApp.py\n@@ -134,10 +134,11 @@\n                   CFBundleIconFile='psychopy.icns',\n                   CFBundleName               = \"PsychoPy3\",\n                   CFBundleShortVersionString = version,  # must be in X.X.X format\n-                  CFBundleGetInfoString      = \"PsychoPy3 \"+version,\n+                  CFBundleVersion            = version,\n                   CFBundleExecutable         = \"PsychoPy3\",\n                   CFBundleIdentifier         = \"org.psychopy.PsychoPy3\",\n                   CFBundleLicense            = \"GNU GPLv3+\",\n+                  NSHumanReadableCopyright   = \"Open Science Tools Ltd.\",\n                   CFBundleDocumentTypes=[dict(CFBundleTypeExtensions=['*'],\n                                               CFBundleTypeRole='Editor')],\n                   LSEnvironment=dict(PATH=\"/usr/local/git/bin:/usr/local/bin:\"\n", "issue": "Working directory issues with 2020.1.1 (most likely related to the new run window)\nSee https://discourse.psychopy.org/t/working-directory-change-with-2020-1-and-later/11143 and https://discourse.psychopy.org/t/both-the-stim3d-py-and-trialhandler-py-programs-with-psychopy-2020-1-1-do-not-run-properly/11201\r\n\r\nAt least on Mac (have not tested on Windows), since upgrading to 2020.1.1, if you run a script, the working directory is set to /Applications/PsychoPy3.app/Contents/Resources, rather than the directory that contains the script. This completely breaks any script that uses relative paths for relevant files expecting the working directory to be the script's directory. This includes some of the demos (see second link above) and my PyHab project.\r\n\r\nIn the short run you can just add the following to the top of every file where it matters:\r\n\r\n```\r\nimport os\r\nos.chdir(os.path.dirname(os.path.realpath(__file__)))\r\n```\r\n\r\nbut this is basically a kludge and bad for backwards-compatibility. Does it need to be this way or can we get the new running window to use the script's directory as the working directory by default?\n", "before_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n# Part of the PsychoPy library\n# Copyright (C) 2002-2018 Jonathan Peirce (C) 2019 Open Science Tools Ltd.\n# Distributed under the terms of the GNU General Public License (GPL).\n\n# --------------------------------------------------------------------------\n# This file is automatically generated during build (do not edit directly).\n# --------------------------------------------------------------------------\n\nimport os\nimport sys\n\n__version__ = '2020.1.2'\n__license__ = 'GNU GPLv3 (or more recent equivalent)'\n__author__ = 'Jonathan Peirce'\n__author_email__ = 'jon.peirce@gmail.com'\n__maintainer_email__ = 'jon.peirce@gmail.com'\n__url__ = 'http://www.psychopy.org/'\n__download_url__ = 'https://github.com/psychopy/psychopy/releases/'\n__git_sha__ = 'n/a'\n__build_platform__ = 'n/a'\n\n__all__ = [\"gui\", \"misc\", \"visual\", \"core\",\n           \"event\", \"data\", \"sound\", \"microphone\"]\n\n# for developers the following allows access to the current git sha from\n# their repository\nif __git_sha__ == 'n/a':\n    from subprocess import check_output, PIPE\n    # see if we're in a git repo and fetch from there\n    try:\n        thisFileLoc = os.path.split(__file__)[0]\n        output = check_output(['git', 'rev-parse', '--short', 'HEAD'],\n                              cwd=thisFileLoc, stderr=PIPE)\n    except Exception:\n        output = False\n    if output:\n        __git_sha__ = output.strip()  # remove final linefeed\n\n# update preferences and the user paths\nif 'installing' not in locals():\n    from psychopy.preferences import prefs\n    for pathName in prefs.general['paths']:\n        sys.path.append(pathName)\n\n    from psychopy.tools.versionchooser import useVersion, ensureMinimal\n\n# import readline here to get around an issue with sounddevice\n# issues GH-2230 GH-2344 GH-2662\ntry:\n    import readline\nexcept ImportError:\n    pass  # all that will happen is the stderr/stdout might get redirected\n\n", "path": "psychopy/__init__.py"}, {"content": "#!/usr/bin/env python\n################\n# see notes at bottom for requirements\nfrom __future__ import absolute_import, print_function\nimport glob\nimport os\nimport sys\nfrom sys import platform\nfrom distutils.core import setup\nfrom pkg_resources import parse_version\n# import versioneer\nimport psychopy\nversion = psychopy.__version__\n\n# regenerate __init__.py only if we're in the source repos (not in a zip file)\ntry:\n    import createInitFile  # won't exist in a sdist.zip\n    writeNewInit=True\nexcept:\n    writeNewInit=False\nif writeNewInit:\n    vStr = createInitFile.createInitFile(dist='bdist')\n\n#define the extensions to compile if necess\npackageData = []\nrequires = []\n\nif platform != 'darwin':\n    raise RuntimeError(\"setupApp.py is only for building Mac Standalone bundle\")\n\nimport bdist_mpkg\nimport py2app\nresources = glob.glob('psychopy/app/Resources/*')\nresources.append('/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyconfig.h')\nframeworks = [\"libavbin.dylib\", \"/usr/lib/libxml2.2.dylib\", #\"libyaml.dylib\",\n              \"libevent.dylib\", \"libffi.dylib\",\n              \"libmp3lame.0.dylib\",\n              \"/usr/local/Cellar/glfw/3.2.1/lib/libglfw.3.2.dylib\",\n              ]\nopencvLibs = glob.glob(os.path.join(sys.exec_prefix, 'lib', 'libopencv*.2.4.dylib'))\nframeworks.extend(opencvLibs)\n\nimport macholib\n#print(\"~\"*60 + \"macholib version: \"+macholib.__version__)\n\nif parse_version(macholib.__version__) <= parse_version('1.7'):\n    print(\"Applying macholib patch...\")\n    import macholib.dyld\n    import macholib.MachOGraph\n    dyld_find_1_7 = macholib.dyld.dyld_find\n    def dyld_find(name, loader=None, **kwargs):\n        #print(\"~\"*60 + \"calling alternate dyld_find\")\n        if loader is not None:\n            kwargs['loader_path'] = loader\n        return dyld_find_1_7(name, **kwargs)\n    macholib.MachOGraph.dyld_find = dyld_find\n\nincludes = ['Tkinter', 'tkFileDialog',\n            'imp', 'subprocess', 'shlex',\n            'shelve',  # for scipy.io\n            '_elementtree', 'pyexpat',  # for openpyxl\n            'hid',\n            'pyo', 'greenlet', 'zmq', 'tornado',\n            'psutil',  # for iohub\n            'tobii_research',  # need tobii_research file and tobiiresearch pkg\n            'pysoundcard', 'soundfile', 'sounddevice', 'readline',\n            'hid',\n            'xlwt',  # writes excel files for pandas\n            'vlc',  # install with pip install python-vlc\n            'msgpack_numpy',\n            'configparser',\n            ]\npackages = ['wx', 'psychopy',\n            'pyglet', 'pygame',  'pytz', 'OpenGL', 'glfw',\n            'scipy', 'matplotlib', 'lxml', 'xml', 'openpyxl',\n            'moviepy', 'imageio', 'imageio_ffmpeg',\n            '_sounddevice_data', '_soundfile_data',\n            'cffi','pycparser',\n            'PIL',  # 'Image',\n            'objc', 'Quartz', 'AppKit', 'QTKit', 'Cocoa',\n            'Foundation', 'CoreFoundation',\n            'pkg_resources',  # needed for objc\n            'pyolib',\n            'requests', 'certifi', 'cryptography',\n            'pyosf',\n            # for unit testing\n            'coverage',\n            # handy external science libs\n            'serial',\n            'egi', 'pylink', 'tobiiresearch',\n            'pyxid', 'pyxid2', 'ftd2xx',  # ftd2xx is used by cedrus\n            'pandas', 'tables',  # 'cython',\n            'msgpack', 'yaml', 'gevent',  # for ioHub\n            # these aren't needed, but liked\n            'psychopy_ext', 'pyfilesec',\n            'bidi', 'arabic_reshaper',  # for right-left language conversions\n            # for Py3 compatibility\n            'future', 'past', 'lib2to3',\n            'json_tricks',  # allows saving arrays/dates in json\n            'git', 'gitlab',\n            'astunparse', 'esprima',  # for translating/adapting py/JS\n            'pylsl', 'pygaze', 'smite',\n            'cv2',\n            'badapted', 'darc_toolbox',  # adaptive methods from Ben Vincent\n            'questplus',\n            'metapensiero.pj', 'dukpy', 'macropy',\n            ]\n\nif sys.version_info.major >= 3:\n    packages.extend(['PyQt5'])\nelse:\n    # not available or not working under Python3:\n    includes.extend(['UserString', 'ioLabs', 'FileDialog'])\n    packages.extend(['PyQt4', 'labjack', 'rusocsci'])\n    # is available but py2app can't seem to find it:\n    packages.extend(['OpenGL'])\n\nsetup(\n    app=['psychopy/app/psychopyApp.py'],\n    options=dict(py2app=dict(\n            includes=includes,\n            packages=packages,\n            excludes=['bsddb', 'jinja2', 'IPython','ipython_genutils','nbconvert',\n                      'libsz.2.dylib',\n                      # 'stringprep',\n                      'functools32',\n                      ],  # anything we need to forcibly exclude?\n            resources=resources,\n            argv_emulation=True,\n            site_packages=True,\n            frameworks=frameworks,\n            iconfile='psychopy/app/Resources/psychopy.icns',\n            plist=dict(\n                  CFBundleIconFile='psychopy.icns',\n                  CFBundleName               = \"PsychoPy3\",\n                  CFBundleShortVersionString = version,  # must be in X.X.X format\n                  CFBundleGetInfoString      = \"PsychoPy3 \"+version,\n                  CFBundleExecutable         = \"PsychoPy3\",\n                  CFBundleIdentifier         = \"org.psychopy.PsychoPy3\",\n                  CFBundleLicense            = \"GNU GPLv3+\",\n                  CFBundleDocumentTypes=[dict(CFBundleTypeExtensions=['*'],\n                                              CFBundleTypeRole='Editor')],\n                  LSEnvironment=dict(PATH=\"/usr/local/git/bin:/usr/local/bin:\"\n                                          \"/usr/local:/usr/bin:/usr/sbin\"),\n            ),\n    ))  # end of the options dict\n)\n\n\n# ugly hack for opencv2:\n# As of opencv 2.4.5 the cv2.so binary used rpath to a fixed\n# location to find libs and even more annoyingly it then appended\n# 'lib' to the rpath as well. These were fine for the packaged\n# framework python but the libs in an app bundle are different.\n# So, create symlinks so they appear in the same place as in framework python\nrpath = \"dist/PsychoPy3.app/Contents/Resources/\"\nfor libPath in opencvLibs:\n    libname = os.path.split(libPath)[-1]\n    realPath = \"../../Frameworks/\"+libname  # relative path (w.r.t. the fake)\n    fakePath = os.path.join(rpath, \"lib\", libname)\n    os.symlink(realPath, fakePath)\n# they even did this for Python lib itself, which is in diff location\nrealPath = \"../Frameworks/Python.framework/Python\"  # relative to the fake path\nfakePath = os.path.join(rpath, \"Python\")\nos.symlink(realPath, fakePath)\n\nif writeNewInit:\n    # remove unwanted info about this system post-build\n    createInitFile.createInitFile(dist=None)\n\n# running testApp from within the app raises wx errors\n# shutil.rmtree(\"dist/PsychoPy3.app/Contents/Resources/lib/python2.6/psychopy/tests/testTheApp\")\n", "path": "setupApp.py"}], "after_files": [{"content": "#!/usr/bin/env python\n# -*- coding: utf-8 -*-\n\n# Part of the PsychoPy library\n# Copyright (C) 2002-2018 Jonathan Peirce (C) 2019 Open Science Tools Ltd.\n# Distributed under the terms of the GNU General Public License (GPL).\n\n# --------------------------------------------------------------------------\n# This file is automatically generated during build (do not edit directly).\n# --------------------------------------------------------------------------\n\nimport os\nimport sys\n\n__version__ = '2020.1.3'\n__license__ = 'GNU GPLv3 (or more recent equivalent)'\n__author__ = 'Jonathan Peirce'\n__author_email__ = 'jon.peirce@gmail.com'\n__maintainer_email__ = 'jon.peirce@gmail.com'\n__url__ = 'http://www.psychopy.org/'\n__download_url__ = 'https://github.com/psychopy/psychopy/releases/'\n__git_sha__ = 'n/a'\n__build_platform__ = 'n/a'\n\n__all__ = [\"gui\", \"misc\", \"visual\", \"core\",\n           \"event\", \"data\", \"sound\", \"microphone\"]\n\n# for developers the following allows access to the current git sha from\n# their repository\nif __git_sha__ == 'n/a':\n    from subprocess import check_output, PIPE\n    # see if we're in a git repo and fetch from there\n    try:\n        thisFileLoc = os.path.split(__file__)[0]\n        output = check_output(['git', 'rev-parse', '--short', 'HEAD'],\n                              cwd=thisFileLoc, stderr=PIPE)\n    except Exception:\n        output = False\n    if output:\n        __git_sha__ = output.strip()  # remove final linefeed\n\n# update preferences and the user paths\nif 'installing' not in locals():\n    from psychopy.preferences import prefs\n    for pathName in prefs.general['paths']:\n        sys.path.append(pathName)\n\n    from psychopy.tools.versionchooser import useVersion, ensureMinimal\n\n# import readline here to get around an issue with sounddevice\n# issues GH-2230 GH-2344 GH-2662\ntry:\n    import readline\nexcept ImportError:\n    pass  # all that will happen is the stderr/stdout might get redirected\n\n", "path": "psychopy/__init__.py"}, {"content": "#!/usr/bin/env python\n################\n# see notes at bottom for requirements\nfrom __future__ import absolute_import, print_function\nimport glob\nimport os\nimport sys\nfrom sys import platform\nfrom distutils.core import setup\nfrom pkg_resources import parse_version\n# import versioneer\nimport psychopy\nversion = psychopy.__version__\n\n# regenerate __init__.py only if we're in the source repos (not in a zip file)\ntry:\n    import createInitFile  # won't exist in a sdist.zip\n    writeNewInit=True\nexcept:\n    writeNewInit=False\nif writeNewInit:\n    vStr = createInitFile.createInitFile(dist='bdist')\n\n#define the extensions to compile if necess\npackageData = []\nrequires = []\n\nif platform != 'darwin':\n    raise RuntimeError(\"setupApp.py is only for building Mac Standalone bundle\")\n\nimport bdist_mpkg\nimport py2app\nresources = glob.glob('psychopy/app/Resources/*')\nresources.append('/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7/pyconfig.h')\nframeworks = [\"libavbin.dylib\", \"/usr/lib/libxml2.2.dylib\", #\"libyaml.dylib\",\n              \"libevent.dylib\", \"libffi.dylib\",\n              \"libmp3lame.0.dylib\",\n              \"/usr/local/Cellar/glfw/3.2.1/lib/libglfw.3.2.dylib\",\n              ]\nopencvLibs = glob.glob(os.path.join(sys.exec_prefix, 'lib', 'libopencv*.2.4.dylib'))\nframeworks.extend(opencvLibs)\n\nimport macholib\n#print(\"~\"*60 + \"macholib version: \"+macholib.__version__)\n\nif parse_version(macholib.__version__) <= parse_version('1.7'):\n    print(\"Applying macholib patch...\")\n    import macholib.dyld\n    import macholib.MachOGraph\n    dyld_find_1_7 = macholib.dyld.dyld_find\n    def dyld_find(name, loader=None, **kwargs):\n        #print(\"~\"*60 + \"calling alternate dyld_find\")\n        if loader is not None:\n            kwargs['loader_path'] = loader\n        return dyld_find_1_7(name, **kwargs)\n    macholib.MachOGraph.dyld_find = dyld_find\n\nincludes = ['Tkinter', 'tkFileDialog',\n            'imp', 'subprocess', 'shlex',\n            'shelve',  # for scipy.io\n            '_elementtree', 'pyexpat',  # for openpyxl\n            'hid',\n            'pyo', 'greenlet', 'zmq', 'tornado',\n            'psutil',  # for iohub\n            'tobii_research',  # need tobii_research file and tobiiresearch pkg\n            'pysoundcard', 'soundfile', 'sounddevice', 'readline',\n            'hid',\n            'xlwt',  # writes excel files for pandas\n            'vlc',  # install with pip install python-vlc\n            'msgpack_numpy',\n            'configparser',\n            ]\npackages = ['wx', 'psychopy',\n            'pyglet', 'pygame',  'pytz', 'OpenGL', 'glfw',\n            'scipy', 'matplotlib', 'lxml', 'xml', 'openpyxl',\n            'moviepy', 'imageio', 'imageio_ffmpeg',\n            '_sounddevice_data', '_soundfile_data',\n            'cffi','pycparser',\n            'PIL',  # 'Image',\n            'objc', 'Quartz', 'AppKit', 'QTKit', 'Cocoa',\n            'Foundation', 'CoreFoundation',\n            'pkg_resources',  # needed for objc\n            'pyolib',\n            'requests', 'certifi', 'cryptography',\n            'pyosf',\n            # for unit testing\n            'coverage',\n            # handy external science libs\n            'serial',\n            'egi', 'pylink', 'tobiiresearch',\n            'pyxid', 'pyxid2', 'ftd2xx',  # ftd2xx is used by cedrus\n            'pandas', 'tables',  # 'cython',\n            'msgpack', 'yaml', 'gevent',  # for ioHub\n            # these aren't needed, but liked\n            'psychopy_ext', 'pyfilesec',\n            'bidi', 'arabic_reshaper',  # for right-left language conversions\n            # for Py3 compatibility\n            'future', 'past', 'lib2to3',\n            'json_tricks',  # allows saving arrays/dates in json\n            'git', 'gitlab',\n            'astunparse', 'esprima',  # for translating/adapting py/JS\n            'pylsl', 'pygaze', 'smite',\n            'cv2',\n            'badapted', 'darc_toolbox',  # adaptive methods from Ben Vincent\n            'questplus',\n            'metapensiero.pj', 'dukpy', 'macropy',\n            ]\n\nif sys.version_info.major >= 3:\n    packages.extend(['PyQt5'])\nelse:\n    # not available or not working under Python3:\n    includes.extend(['UserString', 'ioLabs', 'FileDialog'])\n    packages.extend(['PyQt4', 'labjack', 'rusocsci'])\n    # is available but py2app can't seem to find it:\n    packages.extend(['OpenGL'])\n\nsetup(\n    app=['psychopy/app/psychopyApp.py'],\n    options=dict(py2app=dict(\n            includes=includes,\n            packages=packages,\n            excludes=['bsddb', 'jinja2', 'IPython','ipython_genutils','nbconvert',\n                      'libsz.2.dylib',\n                      # 'stringprep',\n                      'functools32',\n                      ],  # anything we need to forcibly exclude?\n            resources=resources,\n            argv_emulation=True,\n            site_packages=True,\n            frameworks=frameworks,\n            iconfile='psychopy/app/Resources/psychopy.icns',\n            plist=dict(\n                  CFBundleIconFile='psychopy.icns',\n                  CFBundleName               = \"PsychoPy3\",\n                  CFBundleShortVersionString = version,  # must be in X.X.X format\n                  CFBundleVersion            = version,\n                  CFBundleExecutable         = \"PsychoPy3\",\n                  CFBundleIdentifier         = \"org.psychopy.PsychoPy3\",\n                  CFBundleLicense            = \"GNU GPLv3+\",\n                  NSHumanReadableCopyright   = \"Open Science Tools Ltd.\",\n                  CFBundleDocumentTypes=[dict(CFBundleTypeExtensions=['*'],\n                                              CFBundleTypeRole='Editor')],\n                  LSEnvironment=dict(PATH=\"/usr/local/git/bin:/usr/local/bin:\"\n                                          \"/usr/local:/usr/bin:/usr/sbin\"),\n            ),\n    ))  # end of the options dict\n)\n\n\n# ugly hack for opencv2:\n# As of opencv 2.4.5 the cv2.so binary used rpath to a fixed\n# location to find libs and even more annoyingly it then appended\n# 'lib' to the rpath as well. These were fine for the packaged\n# framework python but the libs in an app bundle are different.\n# So, create symlinks so they appear in the same place as in framework python\nrpath = \"dist/PsychoPy3.app/Contents/Resources/\"\nfor libPath in opencvLibs:\n    libname = os.path.split(libPath)[-1]\n    realPath = \"../../Frameworks/\"+libname  # relative path (w.r.t. the fake)\n    fakePath = os.path.join(rpath, \"lib\", libname)\n    os.symlink(realPath, fakePath)\n# they even did this for Python lib itself, which is in diff location\nrealPath = \"../Frameworks/Python.framework/Python\"  # relative to the fake path\nfakePath = os.path.join(rpath, \"Python\")\nos.symlink(realPath, fakePath)\n\nif writeNewInit:\n    # remove unwanted info about this system post-build\n    createInitFile.createInitFile(dist=None)\n\n# running testApp from within the app raises wx errors\n# shutil.rmtree(\"dist/PsychoPy3.app/Contents/Resources/lib/python2.6/psychopy/tests/testTheApp\")\n", "path": "setupApp.py"}]}