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

Issue:
pysnmp error with PyInstaller
When building a simple app using `pysnmp` I get this error:

```
from pysnmp.hlapi import *

errorIndication, errorStatus, errorIndex, varBinds = next(
    getCmd(SnmpEngine(),
           CommunityData('public', mpModel=0),
           UdpTransportTarget(('demo.snmplabs.com', 161)),
           ContextData(),
           ObjectType(ObjectIdentity('SNMPv2-MIB', 'sysDescr', 0)))
)

if errorIndication:
    print(errorIndication)
elif errorStatus:
    print('%s at %s' % (errorStatus.prettyPrint(),
                        errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))
else:
    for varBind in varBinds:
        print(' = '.join([x.prettyPrint() for x in varBind]))
```

```
Traceback (most recent call last):
  File "test.py", line 4, in <module>
    getCmd(SnmpEngine(),
  File "site-packages/pysnmp/entity/engine.py", line 91, in __init__
  File "site-packages/pysnmp/smi/builder.py", line 426, in importSymbols
pysnmp.smi.error.MibNotFoundError: No module __SNMP-FRAMEWORK-MIB loaded at <pysnmp.smi.builder.MibBuilder object at 0x7f0530052f90>
```

After some digging, it looks like there are some files that we need to collect when building.
Will create a PR for that.


Discussion:

Resolving patch:
diff --git a/PyInstaller/hooks/hook-pysnmp.py b/PyInstaller/hooks/hook-pysnmp.py
new file mode 100644
--- /dev/null
+++ b/PyInstaller/hooks/hook-pysnmp.py
@@ -0,0 +1,13 @@
+#-----------------------------------------------------------------------------
+# Copyright (c) 2005-2019, PyInstaller Development Team.
+#
+# Distributed under the terms of the GNU General Public License with exception
+# for distributing bootloader.
+#
+# The full license is in the file COPYING.txt, distributed with this software.
+#-----------------------------------------------------------------------------
+
+from PyInstaller.utils.hooks import collect_submodules, collect_data_files
+
+hiddenimports = collect_submodules('pysnmp.smi.mibs')
+datas = collect_data_files('pysnmp.smi.mibs', include_py_files=True)


Test patch:
Repository: pyinstaller/pyinstaller

Issue:
soundfile hook has osx/windows specific behaviour
hook-soundfile.py was added in 3.5 but it blows up on linux as follows

    9727 INFO: Loading module hook "hook-soundfile.py"...
    Unable to find "/home/matt/.virtualenvs/beqdesigner-entpycF3/lib/python3.7/site-packages/_soundfile_data" when adding binary and data files.

on OSX, it also fails but with a different error

    ValueError: Unknown Mach-O header: 0x20202020 in <_io.BufferedReader 
    name='/Users/travis/build/3ll3d00d/beqdesigner/.venv/lib/python3.7/site-packages/_soundfile_data/COPYING'>

It completes successfully on Windows

The problem is that pysoundfile packages libsndfile on Windows and OSX (as per https://pysoundfile.readthedocs.io/en/0.9.0/#installation) but relies on a system package on Linux so the mentioned directory (`_soundfile_data`) will not exist on Linux. On OSX only a certain file is required (`_soundfile_data/libsndfile.dylib`)

Minimal test case can be found at https://github.com/3ll3d00d/pyinstaller-pysoundfile-bug



Discussion:

Resolving patch:
diff --git a/PyInstaller/hooks/hook-soundfile.py b/PyInstaller/hooks/hook-soundfile.py
--- a/PyInstaller/hooks/hook-soundfile.py
+++ b/PyInstaller/hooks/hook-soundfile.py
@@ -13,11 +13,20 @@
 """
 
 import os
+
+from PyInstaller.compat import is_win, is_darwin
 from PyInstaller.utils.hooks import get_package_paths
 
 # get path of soundfile
 sfp = get_package_paths('soundfile')
 
-# add the binaries
-bins = os.path.join(sfp[0], "_soundfile_data")
-binaries = [(bins, "_soundfile_data")]
+# add binaries packaged by soundfile on OSX and Windows
+# an external dependency (libsndfile) is used on GNU/Linux
+path = None
+if is_win:
+    path = os.path.join(sfp[0], '_soundfile_data')
+elif is_darwin:
+    path = os.path.join(sfp[0], '_soundfile_data', 'libsndfile.dylib')
+
+if path is not None and os.path.exists(path):
+    binaries = [(path, "_soundfile_data")]


Test patch:
Repository: pyinstaller/pyinstaller

Issue:
VSVersionInfo argument to EXE instead of a path
In previous versions (3.4) it was possible to pass a VSVersionInfo object as the version argument to EXE. In 3.5 this raises an exception. It seems to be the following code in api.py on line 426 which expects the argument to be a path.

```Python
if self.versrsrc:
	if not os.path.isabs(self.versrsrc):
		# relative version-info path is relative to spec file
		self.versrsrc = os.path.join(
			CONF['specpath'], self.versrsrc)
```

I'm not sure if it was ever intended that passing a VSVersionInfo would work.


Discussion:
> I'm not sure if it was ever intended that passing a VSVersionInfo would work.

Please use `git blame` (or `blame` on github) to learn about this. Anyway, you are welcome to provide a pull-requests changing thsi behavior to what you need.
The ability to pass a VSVersionInfo was a feature forgotten in the attempt to make paths relative.
In the responsible function in `utils/win32/versioninfo.py` this is explicitly implemented as an option:
```py3
def SetVersion(exenm, versionfile):
    if isinstance(versionfile, VSVersionInfo): #      <- explicit test
        vs = versionfile
    else:
        with codecs.open(versionfile, text_read_mode, 'utf-8') as fp:
            txt = fp.read()
        vs = eval(txt)
```

Resolving patch:
diff --git a/PyInstaller/building/api.py b/PyInstaller/building/api.py
--- a/PyInstaller/building/api.py
+++ b/PyInstaller/building/api.py
@@ -424,7 +424,8 @@ def __init__(self, *args, **kwargs):
                                  "", "OPTION"))
 
             if self.versrsrc:
-                if not os.path.isabs(self.versrsrc):
+                if (not isinstance(self.versrsrc, versioninfo.VSVersionInfo)
+                    and not os.path.isabs(self.versrsrc)):
                     # relative version-info path is relative to spec file
                     self.versrsrc = os.path.join(
                         CONF['specpath'], self.versrsrc)


Test patch:
Repository: pyinstaller/pyinstaller

Issue:
Import hook for argon2 (password hashing library)

**Is your feature request related to a problem? Please describe.**
I could not use password authentication easily.

**Describe the solution you'd like**
Make it easier to use a good password hashing library.

**Describe alternatives you've considered**
I tried to use `passlib` but the pull-request I found did not work for me and it was easier to fix this library directly.

**Additional context**
This seems to be a good password hashing algorithm, would be great to support it by default.



Discussion:

Resolving patch:
diff --git a/PyInstaller/hooks/hook-argon2.py b/PyInstaller/hooks/hook-argon2.py
new file mode 100644
--- /dev/null
+++ b/PyInstaller/hooks/hook-argon2.py
@@ -0,0 +1,12 @@
+#-----------------------------------------------------------------------------
+# Copyright (c) 2018-2020, PyInstaller Development Team.
+#
+# Distributed under the terms of the GNU General Public License (version 2
+# or later) with exception for distributing the bootloader.
+#
+# The full license is in the file COPYING.txt, distributed with this software.
+#
+# SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)
+#-----------------------------------------------------------------------------
+
+hiddenimports = ["_cffi_backend"]


Test patch:
diff --git a/tests/functional/test_libraries.py b/tests/functional/test_libraries.py
--- a/tests/functional/test_libraries.py
+++ b/tests/functional/test_libraries.py
@@ -883,3 +883,14 @@ def test_pendulum(pyi_builder):
 
         print(pendulum.now().isoformat())
         """)
+
+
+@importorskip('argon2')
+def test_argon2(pyi_builder):
+    pyi_builder.test_source("""
+        from argon2 import PasswordHasher
+
+        ph = PasswordHasher()
+        hash = ph.hash("s3kr3tp4ssw0rd")
+        ph.verify(hash, "s3kr3tp4ssw0rd")
+        """)
Repository: pyinstaller/pyinstaller

Issue:
bcrypt needs _cffi_backend
Please add a hook for bcrypt, identical to nnpy. It needs the hidden import _cffi_backend.



Discussion:
@vashek please submit a PR if you need this hook. (Please also refer to the development guide if you do)

Resolving patch:
diff --git a/PyInstaller/hooks/hook-bcrypt.py b/PyInstaller/hooks/hook-bcrypt.py
new file mode 100644
--- /dev/null
+++ b/PyInstaller/hooks/hook-bcrypt.py
@@ -0,0 +1,18 @@
+#-----------------------------------------------------------------------------
+# Copyright (c) 2013-2020, PyInstaller Development Team.
+#
+# Distributed under the terms of the GNU General Public License (version 2
+# or later) with exception for distributing the bootloader.
+#
+# The full license is in the file COPYING.txt, distributed with this software.
+#
+# SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)
+#-----------------------------------------------------------------------------
+
+
+"""
+Hook for https://pypi.org/project/bcrypt/
+"""
+
+
+hiddenimports = ['_cffi_backend']


Test patch:
Repository: pyinstaller/pyinstaller

Issue:
Py3.6: Unable to find .../site-packages/importlib_resources/version.txt"
Hello,

On latest version of pyinstaller, the hook for importlib_resource seems to look for a non existing version.txt file. It is not provided by the latest version 1.2.0 of the backport: https://gitlab.com/python-devs/importlib_resources


Discussion:
@gsemet thanks for reporting this. Unfortunately, we don't have the time to fix this, but if you do, then please submit a PR. All the info you need is in the docs and current hook.
@Legorooj it should really be open until it is fixed (or rejected at all), this way it is easier to understand the status. Having it open doesn't mean that maintainers are required to fix it :).
I will work on this.
What is pyinstaller policy on supporting older versions of packages - can/should I remove > 2-year-old version support?
Thanks!
@Jmennius we support anything that the developers support (in theory).

Target the PR at the hooks-contrib repo in the PyInstaller account. We're moving hooks out there. (Also, ignore the CI on that repo for now. It's not complete)

Resolving patch:
diff --git a/PyInstaller/hooks/hook-importlib_resources.py b/PyInstaller/hooks/hook-importlib_resources.py
--- a/PyInstaller/hooks/hook-importlib_resources.py
+++ b/PyInstaller/hooks/hook-importlib_resources.py
@@ -9,26 +9,25 @@
 # SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)
 #-----------------------------------------------------------------------------
 """
-`importlib_resources` is a backport of the 3.7+ module `importlib.resources`
+`importlib_resources` is a backport of the 3.9+ module `importlib.resources`
 """
 
 import os
-from PyInstaller.compat import is_py37
-from PyInstaller.utils.hooks import get_module_file_attribute
+from PyInstaller.utils.hooks import get_module_file_attribute, \
+    is_module_satisfies, copy_metadata
 
-# Include the version.txt file, used to set __version__
-res_loc = os.path.dirname(get_module_file_attribute('importlib_resources'))
-datas = [
-    (os.path.join(res_loc, 'version.txt'), 'importlib_resources'),
-]
-
-# Replicate the module's version checks to exclude unused modules.
-if is_py37:
-    # Stdlib now has the implmentation of this, so the backports
-    # aren't used at all
-    excludedmodules = [
-        'importlib_resources._py2',
-        'importlib_resources._py3',
-    ]
+if is_module_satisfies("importlib_resources >= 1.2.0"):
+    # since 1.2.0 importlib.metadata is used
+    datas = copy_metadata('importlib_resources')
 else:
-    excludedmodules = ['importlib_resources._py2']
+    # include the version.txt file, used to set __version__
+    res_loc = os.path.dirname(get_module_file_attribute('importlib_resources'))
+    datas = [
+        (os.path.join(res_loc, 'version.txt'), 'importlib_resources'),
+    ]
+
+if is_module_satisfies("importlib_resources >= 1.3.1"):
+    hiddenimports = ['importlib_resources.trees']
+
+# this is only required for python2 support
+excludedimports = ['importlib_resources._py2']


Test patch:
Repository: pyinstaller/pyinstaller

Issue:
Add check for correct names of new-fragments
While releasing the last version, I was hindered by some news-fragments having the wrong filename. While this is not much of an issue, it  costs yet another few minutes to solve. But for a possible (half-)automated release pipeline, this would make some entries vanish from the change log.

The check could be part of the linting step.

Valid names are in <https://github.com/pyinstaller/pyinstaller/blob/develop/doc/development/changelog-entries.rst>

draft pattern: `([^.]+)\.(feature|bugfix|…)\.rst` -> validate with towncrier


Discussion:

Resolving patch:
diff --git a/scripts/verify-news-fragments.py b/scripts/verify-news-fragments.py
new file mode 100644
--- /dev/null
+++ b/scripts/verify-news-fragments.py
@@ -0,0 +1,74 @@
+#!/usr/bin/env python
+#-----------------------------------------------------------------------------
+# Copyright (c) 2013-2020, PyInstaller Development Team.
+#
+# Distributed under the terms of the GNU General Public License (version 2
+# or later) with exception for distributing the bootloader.
+#
+# The full license is in the file COPYING.txt, distributed with this software.
+#
+# SPDX-License-Identifier: (GPL-2.0-or-later WITH Bootloader-exception)
+#-----------------------------------------------------------------------------
+"""
+Verify that new news entries have valid filenames. Usage:
+
+.. code-block:: bash
+
+    git diff --name-status $COMMIT_ID | python verify-news-fragments.py
+
+"""
+
+import re
+import sys
+from pathlib import Path
+
+CHANGELOG_GUIDE = (
+    "https://github.com/pyinstaller/pyinstaller/"
+    "blob/develop/doc/development/changelog-entries.rst#changelog-entries")
+
+CHANGE_TYPES = {'bootloader', 'break', 'bugfix', 'build', 'core', 'doc',
+                'feature', 'hooks', 'moduleloader', 'process', 'tests'}
+
+NEWS_PATTERN = re.compile(r"(\d+)\.(\w+)\.rst")
+
+NEWS_DIR = Path(__file__).absolute().parent.parent / "news"
+
+
+def validate_name(name):
+    """Check a filename/filepath matches the required format.
+
+    :param name: Name of news fragment file.
+    :type: str, os.Pathlike
+
+    :raises: ``SystemExit`` if above checks don't pass.
+    """
+    match = NEWS_PATTERN.fullmatch(Path(name).name)
+    if match is None:
+        sys.exit("'{}' does not match '(pr-number).(type).rst' changelog"
+                 "entries format. See:\n{}".format(name, CHANGELOG_GUIDE))
+
+    if match.group(2) not in CHANGE_TYPES:
+        sys.exit("'{}' of of invalid type '{}'. Valid types are:\n{}".format(
+            name, match.group(2), CHANGE_TYPES))
+
+    print(name, "is ok")
+
+
+def main():
+    # Parse the output of `git diff --name-status COMMIT`
+    lines = sys.stdin.readlines()
+
+    for line in lines:
+        try:
+            action, filename = line.split(maxsplit=1)
+        except ValueError:
+            continue
+        filename = Path(filename.strip())
+
+        if action == "A" and filename.parts[0] == "news":
+            if filename.suffix == ".rst":
+                validate_name(filename)
+
+
+if __name__ == "__main__":
+    main()


Test patch:
Repository: pyinstaller/pyinstaller

Issue:
Hook file for sqlalchemy misses hidden import "sqlalchemy.ext.baked"
The provided hook file for sqlalchemy doesn't seem to pick up the hidden import of "sqlalchemy.ext.baked".


Discussion:
@mastergibber Can you share your `sqlalchemy` version? I'm assuming it's just the latest?


Resolving patch:
diff --git a/PyInstaller/hooks/hook-sqlalchemy.py b/PyInstaller/hooks/hook-sqlalchemy.py
--- a/PyInstaller/hooks/hook-sqlalchemy.py
+++ b/PyInstaller/hooks/hook-sqlalchemy.py
@@ -22,7 +22,7 @@
 # include most common database bindings
 # some database bindings are detected and include some
 # are not. We should explicitly include database backends.
-hiddenimports = ['pysqlite2', 'MySQLdb', 'psycopg2']
+hiddenimports = ['pysqlite2', 'MySQLdb', 'psycopg2', 'sqlalchemy.ext.baked']
 
 # In SQLAlchemy >= 0.6, the "sqlalchemy.dialects" package provides dialects.
 if is_module_satisfies('sqlalchemy >= 0.6'):


Test patch:
Repository: pyinstaller/pyinstaller

Issue:
MacOS onefile package, GUI does not display in High Resolution mode by default. Now it's 2019, so I suggest make the 'NSHighResolutionCapable' option a default.
Hi dear developers,

I found a small issue on mac os x, after running the command 'pyinstaller --onefile --noconsole myscript.py', there are 2 generated files, one is a Unix executable, the other one is a mac os APP PACKAGE. 

My program uses Tkinter for GUI, When the program is launched from the unix executable, it displays in the high resolution mode like a normal mac os app. But when launched from the APP Package, it will display in a low resolution mode, which looks really strange on today's Mac.

After a little search, I found this topic in Stackoverflow, https://stackoverflow.com/questions/40484659/pyinstaller-tkinter-window-low-resolution-in-app-bundle-but-not-in-app-program , added some configs as this topic suggests:

app = BUNDLE(exe,
     name='myscript.app',
     icon=None,
     bundle_identifier=None
     **info_plist={
        'NSHighResolutionCapable': 'True'
        },**
     )

and my program launched from package file now just displayed fine.
So it's all about the **NSHighResolutionCapable** option is disabled or not set by default.


Though my problem is solved, the reason why I still want to open this Issue is, **now it's 2019, in the MacWorld, Retina or High Resolution is already the mainstream,** almost all the Mac products are equipped with a Retina display, and people buy mac for its crisp display. 
Even if you are using an external display, now the 4k is the mainstream, there's no reason to hook a low resolution display especially on a Mac except you already have one and want to still use it.

So I suggest, make this option a DEFAULT in Mac OS version, since the command line executable displays in a high res mode, there's no reason why the App Package not. And high resolution is always what most folks expected. 

Make high resolution a default, no more tweaks, no more searches.

Consider this!


Discussion:

Resolving patch:
diff --git a/PyInstaller/building/osx.py b/PyInstaller/building/osx.py
--- a/PyInstaller/building/osx.py
+++ b/PyInstaller/building/osx.py
@@ -151,10 +151,14 @@ def assemble(self):
 
                            }
 
-        # Setting EXE console=True implies LSBackgroundOnly=True.
-        # But it still can be overwrite by the user.
+        # Set some default values.
+        # But they still can be overwritten by the user.
         if self.console:
+            # Setting EXE console=True implies LSBackgroundOnly=True.
             info_plist_dict['LSBackgroundOnly'] = True
+        else:
+            # Let's use high resolution by default.
+            info_plist_dict['NSHighResolutionCapable'] = True
 
         # Merge info_plist settings from spec file
         if isinstance(self.info_plist, dict) and self.info_plist:


Test patch:
Repository: pyinstaller/pyinstaller

Issue:
Code signing and notarization fails on macOS .app bundles
When using the pyinstaller to create an .app bundle, the installer places a file called base_library.zip into Contents/MacOS. This file is the reason that notarization will fail. As already done with other non executable files, the base_library.zip must be placed into the Contents/Resources/ folder and a link must be made in Contents/MacOS, as described here: https://github.com/pyinstaller/pyinstaller/blob/develop/PyInstaller/building/osx.py#L193


Discussion:
Hey, I want to work on this issue. I am trying to reproduce a notorization issue so I compiled a python script with

`pyinstaller  -w --onedir  script.py`

which generated a script.app in the dist/ folder.

Now I want to perform Notorization. Do I need to create an Apple Developer account to get a developer_id from apple @scheffle or is there a way for me to reproduce this without going through this?

Platform: Macos Mojave

For notarization you need to have a paid developer account at Apple. I don't think that there's another way to reproduce it, sorry.
FTR I am using codesign + noatrization with success since the beginning. You just need to codesign every files in the "MacOS" and some of the "Resources" subfolder of the app. Here is my [working script](https://github.com/nuxeo/nuxeo-drive/blob/c87b627361d73590d810bfde68d33e2b30c2530f/tools/osx/deploy_ci_agent.sh#L108-L133), if it can help.

Think to read https://github.com/pyinstaller/pyinstaller/wiki/Recipe-OSX-Code-Signing and https://github.com/pyinstaller/pyinstaller/wiki/Recipe-OSX-Code-Signing-Qt too.

Resolving patch:
diff --git a/PyInstaller/building/osx.py b/PyInstaller/building/osx.py
--- a/PyInstaller/building/osx.py
+++ b/PyInstaller/building/osx.py
@@ -174,7 +174,7 @@ def assemble(self):
                 fnm = checkCache(fnm, strip=self.strip, upx=self.upx,
                                  upx_exclude=self.upx_exclude, dist_nm=inm)
             # Add most data files to a list for symlinking later.
-            if typ == 'DATA' and base_path not in ('base_library.zip', 'PySide2', 'PyQt5'):
+            if typ == 'DATA' and base_path not in ('PySide2', 'PyQt5'):
                 links.append((inm, fnm))
             else:
                 tofnm = os.path.join(self.name, "Contents", "MacOS", inm)


Test patch:
Repository: pyinstaller/pyinstaller

Issue:
gevent hook unnecessarily bundles ~17MB of "stuff"
## Description of the issue

The included `gevent` hook bundles about 17MB of unnecessary files.
These include:
- HTML documentation
- `__pycache__` folders
- tests
- Generated `.c` and `.h` files

## Context information (for bug reports)

* Output of `pyinstaller --version`: `3.6`
* Version of Python: `3.7.7`
* Platform: macOS 10.15.4 / Ubuntu 18.04

### A minimal example program which shows the error

`test.py`:
```
import gevent
```

Commands
```shell
$ pip install gevent pyinstaller
[...]
$ pyinstaller -D test.py
[...]
$ find dist/test/gevent -name "*.c" -or -name "*.h" -or -name "*.html" -or -path "*/__pycache__/*" -or -path "*/tests/*" | xargs du -shc
[...]
 17M	total
```



Discussion:
Hmm. Looks like the hook needs updating to remove files like that. If you'd be able to provide a PR?
Hi, Can I pick this up
@mihirsn I've tracked this issue down and I'm in the process of fixing it. Thanks for the offer though! (Maybe find another issue if you want to help)

Resolving patch:
diff --git a/PyInstaller/hooks/hook-gevent.py b/PyInstaller/hooks/hook-gevent.py
--- a/PyInstaller/hooks/hook-gevent.py
+++ b/PyInstaller/hooks/hook-gevent.py
@@ -16,4 +16,6 @@
 datas, binaries, hiddenimports = collect_all(
     'gevent',
     filter_submodules=lambda name: (
-        "gevent.testing" not in name or "gevent.tests" not in name))
+        "gevent.testing" not in name or "gevent.tests" not in name),
+    include_py_files=False,
+    exclude_datas=["**/tests"])


Test patch: