We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
uninstall: cannot change path
Hello,
the current uninst.exe is fixed to the path C:\Program Files\PsychoPy3,
which makes it impossible to uninstall an old version in another fold or disk.
Best
PJ

--- 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-2021 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__ = '2022.1.0rc5'
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__ = 'https://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 if sys.version_info.major < 3:
51     raise ImportError("psychopy does not support Python2 installations. "
52                       "The last version to support Python2.7 was PsychoPy "
53                       "2021.2.x")
54 
55 # import readline here to get around an issue with sounddevice
56 # issues GH-2230 GH-2344 GH-2662
57 try:
58     import readline
59 except ImportError:
60     pass  # all that will happen is the stderr/stdout might get redirected
61 
62
```

Path: `setupApp.py`
Content:
```
1 #!/usr/bin/env python
2 ################
3 # see notes at bottom for requirements
4 
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     from building 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 frameworks = [ # these installed using homebrew
35               "/usr/local/opt/libevent/lib/libevent.dylib", 
36               "/usr/local/opt/lame/lib/libmp3lame.0.dylib",
37               "/usr/local/opt/libffi/lib/libffi.dylib",
38               "/usr/local/opt/libglfw/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', 'pytz', 'OpenGL', 'glfw',
75             'scipy', 'matplotlib', 'openpyxl',
76             'xml', 'xmlschema', 'elementpath',
77             'moviepy', 'imageio', 'imageio_ffmpeg',
78             '_sounddevice_data', '_soundfile_data',
79             'cffi', 'pycparser',
80             'PIL',  # 'Image',
81             'objc', 'Quartz', 'AppKit', 'QTKit', 'Cocoa',
82             'Foundation', 'CoreFoundation',
83             'pkg_resources',  # needed for objc
84             'pyo',
85             'requests', 'certifi', 'cryptography',
86             # for unit testing
87             'coverage',
88             # handy external science libs
89             'serial',
90             'egi', 'pylink', 'tobiiresearch',
91             '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             'bidi', 'arabic_reshaper',  # for right-left language conversions
96             # for Py3 compatibility
97             'ujson',  # faster than built-in json
98             'json_tricks',  # allows saving arrays/dates in json
99             'git', 'gitlab',
100             'astunparse', 'esprima',  # for translating/adapting py/JS
101             'pylsl', 'pygaze',
102             'smite',  # https://github.com/marcus-nystrom/SMITE (not pypi!)
103             'cv2',
104             'badapted', 'darc_toolbox',  # adaptive methods from Ben Vincent
105             'questplus',
106             'metapensiero.pj', 'dukpy', 'macropy',
107             'jedi', 'parso',
108             'psychtoolbox',
109             'freetype', 'h5py',
110             'markdown_it',
111             'speech_recognition', 'googleapiclient', 'pocketsphinx',
112             'six',  # needed by configobj
113             'PyQt5',
114             ]
115 
116 setup(
117     app=['psychopy/app/psychopyApp.py'],
118     options=dict(py2app=dict(
119             includes=includes,
120             packages=packages,
121             excludes=['bsddb', 'jinja2', 'IPython','ipython_genutils','nbconvert',
122                       'libsz.2.dylib', 'pygame',
123                       # 'stringprep',
124                       'functools32',
125                       ],  # anything we need to forcibly exclude?
126             resources=resources,
127             argv_emulation=False,  # must be False or app bundle pauses (py2app 0.21 and 0.24 tested)
128             site_packages=True,
129             frameworks=frameworks,
130             iconfile='psychopy/app/Resources/psychopy.icns',
131             plist=dict(
132                   CFBundleIconFile='psychopy.icns',
133                   CFBundleName               = "PsychoPy",
134                   CFBundleShortVersionString = version,  # must be in X.X.X format
135                   CFBundleVersion            = version,
136                   CFBundleExecutable         = "PsychoPy",
137                   CFBundleIdentifier         = "org.opensciencetools.psychopy",
138                   CFBundleLicense            = "GNU GPLv3+",
139                   NSHumanReadableCopyright   = "Open Science Tools Limited",
140                   CFBundleDocumentTypes=[dict(CFBundleTypeExtensions=['*'],
141                                               CFBundleTypeRole='Editor')],
142                   LSEnvironment=dict(PATH="/usr/local/git/bin:/usr/local/bin:"
143                                           "/usr/local:/usr/bin:/usr/sbin"),
144             ),
145     ))  # end of the options dict
146 )
147 
148 
149 # ugly hack for opencv2:
150 # As of opencv 2.4.5 the cv2.so binary used rpath to a fixed
151 # location to find libs and even more annoyingly it then appended
152 # 'lib' to the rpath as well. These were fine for the packaged
153 # framework python but the libs in an app bundle are different.
154 # So, create symlinks so they appear in the same place as in framework python
155 rpath = "dist/PsychoPy.app/Contents/Resources/"
156 for libPath in opencvLibs:
157     libname = os.path.split(libPath)[-1]
158     realPath = "../../Frameworks/"+libname  # relative path (w.r.t. the fake)
159     fakePath = os.path.join(rpath, "lib", libname)
160     os.symlink(realPath, fakePath)
161 # they even did this for Python lib itself, which is in diff location
162 realPath = "../Frameworks/Python.framework/Python"  # relative to the fake path
163 fakePath = os.path.join(rpath, "Python")
164 os.symlink(realPath, fakePath)
165 
166 if writeNewInit:
167     # remove unwanted info about this system post-build
168     createInitFile.createInitFile(dist=None)
169
```
--- 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__ = '2022.1.0rc5'
+__version__ = '2022.1.0rc7'
 __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
@@ -6,9 +6,12 @@
 import os
 import sys
 from sys import platform
+import setuptools  # noqa: setuptools complains if it isn't implicitly imported before distutils
 from distutils.core import setup
 from pkg_resources import parse_version
-# import versioneer
+import bdist_mpkg  # noqa: needed to build bdist, even though not explicitly used here
+import py2app  # noqa: needed to build app bundle, even though not explicitly used here
+
 import psychopy
 version = psychopy.__version__
 
@@ -28,8 +31,6 @@
 if platform != 'darwin':
     raise RuntimeError("setupApp.py is only for building Mac Standalone bundle")
 
-import bdist_mpkg
-import py2app
 resources = glob.glob('psychopy/app/Resources/*')
 frameworks = [ # these installed using homebrew
               "/usr/local/opt/libevent/lib/libevent.dylib",

{"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__ = '2022.1.0rc5'\n+__version__ = '2022.1.0rc7'\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@@ -6,9 +6,12 @@\n import os\n import sys\n from sys import platform\n+import setuptools  # noqa: setuptools complains if it isn't implicitly imported before distutils\n from distutils.core import setup\n from pkg_resources import parse_version\n-# import versioneer\n+import bdist_mpkg  # noqa: needed to build bdist, even though not explicitly used here\n+import py2app  # noqa: needed to build app bundle, even though not explicitly used here\n+\n import psychopy\n version = psychopy.__version__\n \n@@ -28,8 +31,6 @@\n if platform != 'darwin':\n     raise RuntimeError(\"setupApp.py is only for building Mac Standalone bundle\")\n \n-import bdist_mpkg\n-import py2app\n resources = glob.glob('psychopy/app/Resources/*')\n frameworks = [ # these installed using homebrew\n               \"/usr/local/opt/libevent/lib/libevent.dylib\",\n", "issue": "uninstall: cannot change path\nHello,\r\nthe current uninst.exe is fixed to the path C:\\Program Files\\PsychoPy3,\r\nwhich makes it impossible to uninstall an old version in another fold or disk.\r\nBest\r\nPJ\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-2021 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__ = '2022.1.0rc5'\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__ = 'https://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\nif sys.version_info.major < 3:\n    raise ImportError(\"psychopy does not support Python2 installations. \"\n                      \"The last version to support Python2.7 was PsychoPy \"\n                      \"2021.2.x\")\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\n\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    from building 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/*')\nframeworks = [ # these installed using homebrew\n              \"/usr/local/opt/libevent/lib/libevent.dylib\", \n              \"/usr/local/opt/lame/lib/libmp3lame.0.dylib\",\n              \"/usr/local/opt/libffi/lib/libffi.dylib\",\n              \"/usr/local/opt/libglfw/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', 'pytz', 'OpenGL', 'glfw',\n            'scipy', 'matplotlib', 'openpyxl',\n            'xml', 'xmlschema', 'elementpath',\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            'pyo',\n            'requests', 'certifi', 'cryptography',\n            # for unit testing\n            'coverage',\n            # handy external science libs\n            'serial',\n            'egi', 'pylink', 'tobiiresearch',\n            '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            'bidi', 'arabic_reshaper',  # for right-left language conversions\n            # for Py3 compatibility\n            'ujson',  # faster than built-in json\n            'json_tricks',  # allows saving arrays/dates in json\n            'git', 'gitlab',\n            'astunparse', 'esprima',  # for translating/adapting py/JS\n            'pylsl', 'pygaze',\n            'smite',  # https://github.com/marcus-nystrom/SMITE (not pypi!)\n            'cv2',\n            'badapted', 'darc_toolbox',  # adaptive methods from Ben Vincent\n            'questplus',\n            'metapensiero.pj', 'dukpy', 'macropy',\n            'jedi', 'parso',\n            'psychtoolbox',\n            'freetype', 'h5py',\n            'markdown_it',\n            'speech_recognition', 'googleapiclient', 'pocketsphinx',\n            'six',  # needed by configobj\n            'PyQt5',\n            ]\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', 'pygame',\n                      # 'stringprep',\n                      'functools32',\n                      ],  # anything we need to forcibly exclude?\n            resources=resources,\n            argv_emulation=False,  # must be False or app bundle pauses (py2app 0.21 and 0.24 tested)\n            site_packages=True,\n            frameworks=frameworks,\n            iconfile='psychopy/app/Resources/psychopy.icns',\n            plist=dict(\n                  CFBundleIconFile='psychopy.icns',\n                  CFBundleName               = \"PsychoPy\",\n                  CFBundleShortVersionString = version,  # must be in X.X.X format\n                  CFBundleVersion            = version,\n                  CFBundleExecutable         = \"PsychoPy\",\n                  CFBundleIdentifier         = \"org.opensciencetools.psychopy\",\n                  CFBundleLicense            = \"GNU GPLv3+\",\n                  NSHumanReadableCopyright   = \"Open Science Tools Limited\",\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/PsychoPy.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", "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-2021 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__ = '2022.1.0rc7'\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__ = 'https://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\nif sys.version_info.major < 3:\n    raise ImportError(\"psychopy does not support Python2 installations. \"\n                      \"The last version to support Python2.7 was PsychoPy \"\n                      \"2021.2.x\")\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\n\nimport glob\nimport os\nimport sys\nfrom sys import platform\nimport setuptools  # noqa: setuptools complains if it isn't implicitly imported before distutils\nfrom distutils.core import setup\nfrom pkg_resources import parse_version\nimport bdist_mpkg  # noqa: needed to build bdist, even though not explicitly used here\nimport py2app  # noqa: needed to build app bundle, even though not explicitly used here\n\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    from building 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\nresources = glob.glob('psychopy/app/Resources/*')\nframeworks = [ # these installed using homebrew\n              \"/usr/local/opt/libevent/lib/libevent.dylib\", \n              \"/usr/local/opt/lame/lib/libmp3lame.0.dylib\",\n              \"/usr/local/opt/libffi/lib/libffi.dylib\",\n              \"/usr/local/opt/libglfw/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', 'pytz', 'OpenGL', 'glfw',\n            'scipy', 'matplotlib', 'openpyxl',\n            'xml', 'xmlschema', 'elementpath',\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            'pyo',\n            'requests', 'certifi', 'cryptography',\n            # for unit testing\n            'coverage',\n            # handy external science libs\n            'serial',\n            'egi', 'pylink', 'tobiiresearch',\n            '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            'bidi', 'arabic_reshaper',  # for right-left language conversions\n            # for Py3 compatibility\n            'ujson',  # faster than built-in json\n            'json_tricks',  # allows saving arrays/dates in json\n            'git', 'gitlab',\n            'astunparse', 'esprima',  # for translating/adapting py/JS\n            'pylsl', 'pygaze',\n            'smite',  # https://github.com/marcus-nystrom/SMITE (not pypi!)\n            'cv2',\n            'badapted', 'darc_toolbox',  # adaptive methods from Ben Vincent\n            'questplus',\n            'metapensiero.pj', 'dukpy', 'macropy',\n            'jedi', 'parso',\n            'psychtoolbox',\n            'freetype', 'h5py',\n            'markdown_it',\n            'speech_recognition', 'googleapiclient', 'pocketsphinx',\n            'six',  # needed by configobj\n            'PyQt5',\n            ]\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', 'pygame',\n                      # 'stringprep',\n                      'functools32',\n                      ],  # anything we need to forcibly exclude?\n            resources=resources,\n            argv_emulation=False,  # must be False or app bundle pauses (py2app 0.21 and 0.24 tested)\n            site_packages=True,\n            frameworks=frameworks,\n            iconfile='psychopy/app/Resources/psychopy.icns',\n            plist=dict(\n                  CFBundleIconFile='psychopy.icns',\n                  CFBundleName               = \"PsychoPy\",\n                  CFBundleShortVersionString = version,  # must be in X.X.X format\n                  CFBundleVersion            = version,\n                  CFBundleExecutable         = \"PsychoPy\",\n                  CFBundleIdentifier         = \"org.opensciencetools.psychopy\",\n                  CFBundleLicense            = \"GNU GPLv3+\",\n                  NSHumanReadableCopyright   = \"Open Science Tools Limited\",\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/PsychoPy.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", "path": "setupApp.py"}]}