internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: pypa/virtualenv

Issue:
site.getsitepackages() doesn't respect --system-site-packages on python2
**Issue**

site.getsitepackages() doesn't respect --system-site-packages being set on python2. System site-package paths are never included. 
I came across this while working on #2105. In contrast to #2105 this is not specific to debian, which is why I am creating a separate issue for it.

```
python -m virtualenv --system-site-packages -ppython2 testenv
. testenv/bin/activate
python -c "import site; print(site.getsitepackages())"
['/home/adrian/Documents/dev/uni/bachelor/mypy/testenv/lib/python2.7/site-packages', '/home/adrian/Documents/dev/uni/bachelor/mypy/testenv/lib/site-python']
```

**Environment**

Provide at least:
- OS: Tested on both Ubuntu 18.04.3 LTS and Arch Linux
- ``pip list`` of the host python where ``virtualenv`` is installed:

Same as #2105 

**Output of the virtual environment creation**

Make sure to run the creation with `-vvv --with-traceback`:
Same as #2105 



Discussion:

Resolving patch:
diff --git a/src/virtualenv/create/via_global_ref/builtin/python2/site.py b/src/virtualenv/create/via_global_ref/builtin/python2/site.py
--- a/src/virtualenv/create/via_global_ref/builtin/python2/site.py
+++ b/src/virtualenv/create/via_global_ref/builtin/python2/site.py
@@ -158,7 +158,7 @@ def add_global_site_package():
         site.PREFIXES = [sys.base_prefix, sys.base_exec_prefix]
         site.main()
     finally:
-        site.PREFIXES = orig_prefixes
+        site.PREFIXES = orig_prefixes + site.PREFIXES
 
 
 main()


Test patch:
diff --git a/tests/unit/create/test_creator.py b/tests/unit/create/test_creator.py
--- a/tests/unit/create/test_creator.py
+++ b/tests/unit/create/test_creator.py
@@ -1,5 +1,6 @@
 from __future__ import absolute_import, unicode_literals
 
+import ast
 import difflib
 import gc
 import json
@@ -621,3 +622,34 @@ def test_pth_in_site_vs_PYTHONPATH(tmp_path):
         env=env,
     )
     assert out == "ok\n"
+
+
+def test_getsitepackages_system_site(tmp_path):
+    import site
+
+    old_prefixes = site.PREFIXES
+    site.PREFIXES = [sys.base_prefix, sys.base_exec_prefix]
+    system_site_packages = site.getsitepackages()
+    site.PREFIXES = old_prefixes
+
+    # Test without --system-site-packages
+    session = cli_run([ensure_text(str(tmp_path))])
+    out = subprocess.check_output(
+        [str(session.creator.exe), "-c", r"import site; print(site.getsitepackages())"],
+        universal_newlines=True,
+    )
+    site_packages = ast.literal_eval(out)
+
+    for system_site_package in system_site_packages:
+        assert system_site_package not in site_packages
+
+    # Test with --system-site-packages
+    session = cli_run([ensure_text(str(tmp_path)), "--system-site-packages"])
+    out = subprocess.check_output(
+        [str(session.creator.exe), "-c", r"import site; print(site.getsitepackages())"],
+        universal_newlines=True,
+    )
+    site_packages = ast.literal_eval(out)
+
+    for system_site_package in system_site_packages:
+        assert system_site_package in site_packages
Repository: pypa/virtualenv

Issue:
Virtualenv 20.14.0 bundles broken setuptools
**Issue**

Virtualenv 20.14.0 has broken version of setuptools 61.0.0 bundled in. This causes broken installations of packages, especially missing package data files.

**Environment**

Various


Discussion:

Resolving patch:
diff --git a/src/virtualenv/seed/wheels/embed/__init__.py b/src/virtualenv/seed/wheels/embed/__init__.py
--- a/src/virtualenv/seed/wheels/embed/__init__.py
+++ b/src/virtualenv/seed/wheels/embed/__init__.py
@@ -7,27 +7,27 @@
 BUNDLE_SUPPORT = {
     "3.11": {
         "pip": "pip-22.0.4-py3-none-any.whl",
-        "setuptools": "setuptools-61.0.0-py3-none-any.whl",
+        "setuptools": "setuptools-62.1.0-py3-none-any.whl",
         "wheel": "wheel-0.37.1-py2.py3-none-any.whl",
     },
     "3.10": {
         "pip": "pip-22.0.4-py3-none-any.whl",
-        "setuptools": "setuptools-61.0.0-py3-none-any.whl",
+        "setuptools": "setuptools-62.1.0-py3-none-any.whl",
         "wheel": "wheel-0.37.1-py2.py3-none-any.whl",
     },
     "3.9": {
         "pip": "pip-22.0.4-py3-none-any.whl",
-        "setuptools": "setuptools-61.0.0-py3-none-any.whl",
+        "setuptools": "setuptools-62.1.0-py3-none-any.whl",
         "wheel": "wheel-0.37.1-py2.py3-none-any.whl",
     },
     "3.8": {
         "pip": "pip-22.0.4-py3-none-any.whl",
-        "setuptools": "setuptools-61.0.0-py3-none-any.whl",
+        "setuptools": "setuptools-62.1.0-py3-none-any.whl",
         "wheel": "wheel-0.37.1-py2.py3-none-any.whl",
     },
     "3.7": {
         "pip": "pip-22.0.4-py3-none-any.whl",
-        "setuptools": "setuptools-61.0.0-py3-none-any.whl",
+        "setuptools": "setuptools-62.1.0-py3-none-any.whl",
         "wheel": "wheel-0.37.1-py2.py3-none-any.whl",
     },
     "3.6": {


Test patch:
Repository: psychopy/psychopy

Issue:
docs: builder documentation for new timing methods
Explain how the new system works (as a single separate document, linked to each of the other Component documents?)

Explain the advantage of using frames, rather than time, for better precision

Use some examples like:
    Use 'time (s)' and simply set it to a numeric value
    Use 'time (s)' and set it to a variable name with $. Then also set the 'expected time' to see a rough approximation (this won't affect the script)
    Set to 'frameN' and use either a numeric value or a variable, as above
    Set to condition with value myMovie.status==FINISHED



Discussion:

Resolving patch:
diff --git a/psychopy/app/builder/builder.py b/psychopy/app/builder/builder.py
--- a/psychopy/app/builder/builder.py
+++ b/psychopy/app/builder/builder.py
@@ -651,7 +651,7 @@ def drawLoop(self,dc,loop,id, startX,endX,
         dc.SetPen(wx.Pen(wx.Color(r, g, b, 200)))
         vertOffset=0 # 1 is interesting too
         area = wx.Rect(startX, base+vertOffset, endX-startX, max(yy)-min(yy))
-        dc.SetBrush(wx.Brush(wx.Color(0,0,0,0))) # transparent
+        dc.SetBrush(wx.Brush(wx.Color(0,0,0,0), wx.TRANSPARENT)) # transparent
         dc.DrawRoundedRectangleRect(area, curve) # draws outline
         dc.SetIdBounds(tmpId, area)
 


Test patch:
Repository: psychopy/psychopy

Issue:
pyo is not handling mono files correctly
Gary Lupyan reports: pyo is still not handling mono files correctly.  It plays them only from one speaker. 



Discussion:

Resolving patch:
diff --git a/psychopy/sound.py b/psychopy/sound.py
--- a/psychopy/sound.py
+++ b/psychopy/sound.py
@@ -420,6 +420,7 @@ def __init__(self, value="C", secs=0.5, octave=4, stereo=True, volume=1.0,
         self.sampleRate=pyoSndServer.getSamplingRate()
         self.format = bits
         self.isStereo = stereo
+        self.channels = 1 + int(stereo)
         self.secs=secs
         self.autoLog=autoLog
         self.name=name
@@ -523,20 +524,17 @@ def _fromFile(self, fileName):
                 self.fileName=path.join(filePath,fileName+'.wav')
         if self.fileName is None:
             return False
-        #load the file
-        self._sndTable = pyo.SndTable(self.fileName)
+        # want mono sound file played to both speakers, not just left / 0
+        self._sndTable = pyo.SndTable(initchnls=self.channels)
+        self._sndTable.setSound(self.fileName)  # mono file loaded to all chnls
         self._updateSnd()
         self.duration = self._sndTable.getDur()
         return True
 
     def _fromArray(self, thisArray):
-        if self.isStereo:
-            channels=2
-        else:
-            channels=1
         self._sndTable = pyo.DataTable(size=len(thisArray),
                                        init=thisArray.T.tolist(),
-                                       chnls=channels)
+                                       chnls=self.channels)
         self._updateSnd()
         # a DataTable has no .getDur() method, so just store the duration:
         self.duration = float(len(thisArray)) / self.sampleRate


Test patch:
Repository: psychopy/psychopy

Issue:
set order of routines within the routine panel
I have an exp with 7 blocks, each with an instruction screen, so 14 routines (plus start and end). Currently they all seem jumbled around all over the place, so I have to hunt around to find Block_4 (for example). It would be nice if I could have the tabs show up in a sensible order: Flow order would be nice but won't always work, because the same routine can be in multiple places. Alphabetical order might be good too, and hopefully always be appropriate (?)



Discussion:
I know you can click on the routine in the flow to bring it to the foreground in the routine panel (very cool), but having a predictable and stable order would be helpful too.


Resolving patch:
diff --git a/psychopy/app/builder/builder.py b/psychopy/app/builder/builder.py
--- a/psychopy/app/builder/builder.py
+++ b/psychopy/app/builder/builder.py
@@ -1421,7 +1421,8 @@ def redrawRoutines(self):
         """
         currPage = self.GetSelection()
         self.removePages()
-        for routineName in self.frame.exp.routines:
+        displayOrder = sorted(self.frame.exp.routines.keys())  # alphabetical
+        for routineName in displayOrder:
             self.addRoutinePage(routineName, self.frame.exp.routines[routineName])
         if currPage>-1:
             self.SetSelection(currPage)


Test patch:
Repository: psychopy/psychopy

Issue:
WX version
I think line 13 in _psychopyApp.py (https://github.com/psychopy/psychopy/blob/master/psychopy/app/_psychopyApp.py): `wxversion.ensureMinimal('2.8')` needs to be changed to `wxversion.select('2.8')` since PsychoPy is not compatible with wx 2.9 and above.



Discussion:

Resolving patch:
diff --git a/psychopy/app/_psychopyApp.py b/psychopy/app/_psychopyApp.py
--- a/psychopy/app/_psychopyApp.py
+++ b/psychopy/app/_psychopyApp.py
@@ -10,7 +10,7 @@
 # Ensure 2.8 version of wx
 if not hasattr(sys, 'frozen'):
     import wxversion
-    wxversion.ensureMinimal('2.8')
+    wxversion.select(['2.8.10', '2.8.11', '2.8.12'])
 import wx
 try:
     from agw import advancedsplash as AS


Test patch:
Repository: psychopy/psychopy

Issue:
Python version
Most of the scripts start with `#!/usr/bin/env python` but face.py and plaid.py do not. I think these should be changed. Further, PEP 394 (http://www.python.org/dev/peps/pep-0394/) recommends that "python should be used in the shebang line only for scripts that are source compatible with both Python 2 and 3" since PsychoPy is not compatible with Python 3, the shebang line should use python2. The current shebang lines cause issues with Arch Linux where python refers to python3.



Discussion:
The part of this that is related to demos could / should go in a comment for issue #248.

The other place this might come up is in lastrun.py scripts generated by the Builder.


Resolving patch:
diff --git a/psychopy/app/builder/experiment.py b/psychopy/app/builder/experiment.py
--- a/psychopy/app/builder/experiment.py
+++ b/psychopy/app/builder/experiment.py
@@ -130,7 +130,7 @@ def writeScript(self, expPath=None):
         else:
             localDateTime = data.getDateStr(format="%B %d, %Y, at %H:%M")
 
-        script.write('#!/usr/bin/env python\n' +
+        script.write('#!/usr/bin/env python2\n' +
                     '# -*- coding: utf-8 -*-\n' +
                     '"""\nThis experiment was created using PsychoPy2 Experiment Builder (v%s), %s\n' % (
                         self.psychopyVersion, localDateTime ) +


Test patch:
Repository: psychopy/psychopy

Issue:
disable auto-updates pref
John Allen writes: "I was looking for something on the psychopy updates dialog." That seems like a nice place for it, not much work to implement probably.

Even less work to just move the pref from the connections panel to the general or app panel (within the preferences dialog). This would increase its visibility.



Discussion:
Easy to add a note in the updates dialog (saying that there's a pref to disable auto-updating)

Sure, that sounds the easiest thing to do actually


Resolving patch:
diff --git a/psychopy/app/connections.py b/psychopy/app/connections.py
--- a/psychopy/app/connections.py
+++ b/psychopy/app/connections.py
@@ -145,7 +145,7 @@ def __init__(self,latest,runningVersion):
 
         #info about current version
         msg1 = wx.StaticText(self,-1,style=wx.ALIGN_CENTRE,
-            label="PsychoPy v%s is available (you are running %s)." %(latest['version'],runningVersion))
+            label="PsychoPy v%s is available (you are running %s).\n\n(To disable this check, see Preferences > connections > checkForUpdates)" %(latest['version'],runningVersion))
         if latest['lastCompatible']>runningVersion:
             msg2 = wx.StaticText(self,-1,style=wx.ALIGN_CENTRE,
             label="This version MAY require you to modify your\nscripts/exps slightly. Read the changelog carefully.")
@@ -496,4 +496,3 @@ def sendUsageStats():
     except:
         logging.warning("Couldn't connect to psychopy.org\n"+\
             "Check internet settings (and proxy setting in PsychoPy Preferences.")
-


Test patch:
Repository: psychopy/psychopy

Issue:
bug: only one condition fails in csv conditions import
I think Pablo Garaizar spotted this, and I get an error too.
File contents two lines:
  Duration
  1

Traceback (most recent call last):
  File "/Users/jgray/code/psychopy/psychopy/app/builder/builder.py", line 2927, in onBrowseTrialsFile
    returnFieldNames=True)
  File "/Users/jgray/code/psychopy/psychopy/data.py", line 1273, in importConditions
    for trialN, trialType in enumerate(trialsArr):
TypeError: iteration over a 0-d array



Discussion:

Resolving patch:
diff --git a/psychopy/data.py b/psychopy/data.py
--- a/psychopy/data.py
+++ b/psychopy/data.py
@@ -1265,6 +1265,8 @@ def _assertValidVarNames(fieldNames, fileName):
         #use csv import library to fetch the fieldNames
         f = open(fileName, 'rU')#the U converts line endings to os.linesep (not unicode!)
         trialsArr = numpy.recfromcsv(f, case_sensitive=True)
+        if trialsArr.shape == ():  # convert 0-D to 1-D with one element:
+            trialsArr = trialsArr[numpy.newaxis]
         fieldNames = trialsArr.dtype.names
         _assertValidVarNames(fieldNames, fileName)
         f.close()


Test patch:
Repository: psychopy/psychopy

Issue:
feature request: develop a pylint rule-set
pylint is a code analysis tool, and will err of the side of being super duper ultra nitpicky (which is great). You just then turn some things off to see the signal in the noise. For example, I've been bitten by mutable default values to a method / function, and it will catch this. It flags bare excepts -- lots of useful stuff.

If anyone has experience with pylint, it would be great to have advice on what works well, and what is likely to work well for PsychoPy given its history and current conventions. If its counterproductive to start using pylint with a codebase this large, that would be helpful to know.

I'm thinking that even if its never run as part of the build process, it might be nice to have a project-wide pylintrc file that makes explicit what style conventions are expected (long lines ok, variable name conventions, etc). This seems like a powerful way to communicate the conventions. 

PsychoPy currently has lots of bare excepts, bad indentations, unused variables, redefined builtins, unused imports, and so on -- seemingly all good targets for clean-up work.



Discussion:
It's good to write new code following pylint principles but i'm not keen on it being applying too strongly to existing code because it obscures where meaningful code changes have occurred.


Resolving patch:
diff --git a/psychopy/misc.py b/psychopy/misc.py
--- a/psychopy/misc.py
+++ b/psychopy/misc.py
@@ -6,6 +6,9 @@
 
 '''Wrapper for all miscellaneous functions and classes from psychopy.tools'''
 
+# pylint: disable=W0611
+# W0611 = Unused import %s
+
 from psychopy.tools.arraytools import (createXYs, extendArr, makeRadialMatrix,
                                        ratioRange, shuffleArray, val2array)
 
diff --git a/psychopy/tools/unittools.py b/psychopy/tools/unittools.py
--- a/psychopy/tools/unittools.py
+++ b/psychopy/tools/unittools.py
@@ -9,4 +9,7 @@
 # This module is not used by psychopy; retained for backwards compatibility
 # for user-scripts.
 
+# pylint: disable=W0611
+# W0611 = Unused import %s
+
 from numpy import radians, degrees


Test patch:
Repository: psychopy/psychopy

Issue:
RatingScale: Error when marker specified AND visual analog scale checked
In recent versions of Psychopy, when a rating scale component "marker" option is specified and the "Visual analog scale" checkbox is selected, the component is created with two "marker" options and a "SyntaxError: keyword argument repeated" error occurs. 

We just need to check whether a marker option has been specified, or pass **args in correctly. 



Discussion:

Resolving patch:
diff --git a/psychopy/app/builder/components/ratingscale.py b/psychopy/app/builder/components/ratingscale.py
--- a/psychopy/app/builder/components/ratingscale.py
+++ b/psychopy/app/builder/components/ratingscale.py
@@ -158,7 +158,9 @@ def writeInitCode(self, buff):
             # type of scale:
             choices = unicode(self.params['categoryChoices'].val)
             if self.params['visualAnalogScale'].val:
-                init_str += ", low=0, high=1, precision=100, marker='glow', showValue=False, markerExpansion=0"
+                init_str += ", low=0, high=1, precision=100, showValue=False, markerExpansion=0"
+                if not self.params['marker'].val:
+                    init_str += ", marker='glow'"
             elif len(choices):
                 if ',' in choices:
                     ch_list = choices.split(',')
diff --git a/psychopy/demos/coder/basic/hello_world.py b/psychopy/demos/coder/basic/hello_world.py
new file mode 100644
--- /dev/null
+++ b/psychopy/demos/coder/basic/hello_world.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python2
+# -*- coding: utf-8 -*-
+
+"""Demo: show a very basic program: hello world
+"""
+
+# Import key parts of the PsychoPy library:
+from psychopy import visual, core
+
+# Create a visual window:
+win = visual.Window()
+
+# Create (but not yet display) some text:
+msg1 = visual.TextStim(win, text=u"Hello world!")  # default position = centered
+msg2 = visual.TextStim(win, text=u"\u00A1Hola mundo!", pos=(0, -0.3))
+
+# Draw the text to the hidden visual buffer:
+msg1.draw()
+msg2.draw()
+
+# Show the hidden buffer--everything that has been drawn since the last win.flip():
+win.flip()
+
+# Wait 3 seconds so people can see the message, then exit gracefully:
+core.wait(3)
+win.close()


Test patch:
diff --git a/psychopy/tests/test_misc/test_microphone.py b/psychopy/tests/test_misc/test_microphone.py
--- a/psychopy/tests/test_misc/test_microphone.py
+++ b/psychopy/tests/test_misc/test_microphone.py
@@ -162,6 +162,8 @@ def test_wav_flac(self):
         wav2flac(self.tmp, keep=True)
 
     def test_Speech2Text(self):
+        pytest.skip()  # google speech API gives Error 400: Bad request
+
         try:
             web.requireInternetAccess()
         except web.NoInternetAccessError:
Repository: psychopy/psychopy

Issue:
builder fileClose issues, esp for history
fileHistory gets appended to without bound, so appData.cfg can become large

fileClose gets called multiple times (in fileOpen and fileNew, for example), resulting in the same file being appended to the history multiple times



Discussion:

Resolving patch:
diff --git a/psychopy/app/builder/builder.py b/psychopy/app/builder/builder.py
--- a/psychopy/app/builder/builder.py
+++ b/psychopy/app/builder/builder.py
@@ -4049,7 +4049,8 @@ def makeMenus(self):
         menuBar.Append(self.fileMenu, _('&File'))
 
         #create a file history submenu
-        self.fileHistory = wx.FileHistory(maxFiles=10)
+        self.fileHistoryMaxFiles = 10
+        self.fileHistory = wx.FileHistory(maxFiles=self.fileHistoryMaxFiles)
         self.recentFilesMenu = wx.Menu()
         self.fileHistory.UseMenu(self.recentFilesMenu)
         for filename in self.appData['fileHistory']:
@@ -4401,11 +4402,27 @@ def fileClose(self, event=None, checkSave=True, updateViews=True):
         frameData['auiPerspective'] = self._mgr.SavePerspective()
         frameData['winW'], frameData['winH']=self.GetSize()
         frameData['winX'], frameData['winY']=self.GetPosition()
+
+        # truncate history to the recent-most last N unique files, where
+        # N = self.fileHistoryMaxFiles, as defined in makeMenus()
         for ii in range(self.fileHistory.GetCount()):
             self.appData['fileHistory'].append(self.fileHistory.GetHistoryFile(ii))
+        # fileClose gets calls multiple times, so remove redundancy while preserving order,
+        # end of the list is recent-most:
+        tmp = []
+        for f in self.appData['fileHistory'][-3 * self.fileHistoryMaxFiles:]:
+            if not f in tmp:
+                tmp.append(f)
+        self.appData['fileHistory'] = copy.copy(tmp[-self.fileHistoryMaxFiles:])
 
         #assign the data to this filename
         self.appData['frames'][self.filename] = frameData
+        # save the display data only for those frames in the history:
+        tmp2 = {}
+        for f in self.appData['frames'].keys():
+            if f in self.appData['fileHistory']:
+                tmp2[f] = self.appData['frames'][f]
+        self.appData['frames'] = copy.copy(tmp2)
 
         #close self
         self.routinePanel.removePages()


Test patch:
Repository: psychopy/psychopy

Issue:
detection of available RAM is off on mac 10.9
in info.py getRAM()



Discussion:

Resolving patch:
diff --git a/psychopy/app/localization/__init__.py b/psychopy/app/localization/__init__.py
--- a/psychopy/app/localization/__init__.py
+++ b/psychopy/app/localization/__init__.py
@@ -18,8 +18,15 @@
 import os, sys, glob, codecs
 from psychopy import logging, prefs
 
-# Get a dict of locale aliases from wx.Locale() -- same cross-platform (Win 7, Mac 10.9)
 import wx
+
+# need a wx App for wx.Locale:
+try:
+    wx.Dialog(None, -1)
+except wx._core.PyNoAppError:
+    tmpApp = wx.PySimpleApp()
+
+# Get a dict of locale aliases from wx.Locale() -- same cross-platform (Win 7, Mac 10.9)
 locale = wx.Locale()
 aliases = {}
 wxIdFromCode = {}  # int: 0, 2-229
diff --git a/psychopy/info.py b/psychopy/info.py
--- a/psychopy/info.py
+++ b/psychopy/info.py
@@ -182,7 +182,7 @@ def _setSystemInfo(self):
         """system info"""
         # system encoding
         osEncoding=sys.getfilesystemencoding()
-        
+
         # machine name
         self['systemHostName'] = platform.node()
 
@@ -646,16 +646,17 @@ def getRAM():
     totalRAM = 'unknown'
 
     if sys.platform == 'darwin':
-        so = core.shellCall('vm_stat')
-        lines = so.splitlines()
+        lines = core.shellCall('vm_stat').splitlines()
         pageIndex = lines[0].find('page size of ')
         if  pageIndex > -1:
             pagesize = int(lines[0][pageIndex + len('page size of '):].split()[0])
-            free = float(lines[1].split()[-1])
-            freeRAM = int(free * pagesize / 1048576.)  # M
-            pieces = [lines[i].split()[-1] for i in range(1, 6)]
-            total = sum([float(x) for x in pieces])
-            totalRAM = int(total * pagesize / 1048576.)  # M
+            lineFree = [ln for ln in lines if ln.startswith('Pages free')][0]
+            lineSpec = [ln for ln in lines if ln.startswith('Pages speculative')][0]
+            free = float(lineFree.split()[-1])
+            spec = float(lineSpec.split()[-1])
+            freeRAM = int((free + spec) * pagesize / 1048576.)  # M
+            total = core.shellCall(['sysctl', 'hw.memsize']).split(':')
+            totalRAM = int(int(total[-1]) / 1048576.)  # M
     elif sys.platform == 'win32':
         if not haveCtypes:
             return 'unknown', 'unknown'


Test patch: