b-2-r/pybfd3

Compile issues

Bidski opened this issue · 10 comments

I have encountered a number of build issues.

The first is the same/similar to #1 and #2 . On Arch Linux with pip version 20.1.1 (python 3.8) and setuptools==49.1.0 I get the following error

$ pip install pybfd3
Collecting pybfd3
  Downloading pybfd3-0.1.3.tar.gz (47 kB)
     |████████████████████████████████| 47 kB 2.8 MB/s 
Requirement already satisfied: future in /usr/local/lib/python3.8/site-packages (from pybfd3) (0.18.2)
Building wheels for collected packages: pybfd3
  Building wheel for pybfd3 (setup.py) ... done
  WARNING: Legacy build of wheel for 'pybfd3' created no files.
  Command arguments: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-91o8i9rs/pybfd3/setup.py'"'"'; __file__='"'"'/tmp/pip-install-91o8i9rs/pybfd3/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-ejl67u98
  Command output: [use --verbose to show]
  Running setup.py clean for pybfd3
Failed to build pybfd3
Installing collected packages: pybfd3
    Running setup.py install for pybfd3 ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-91o8i9rs/pybfd3/setup.py'"'"'; __file__='"'"'/tmp/pip-install-91o8i9rs/pybfd3/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-pnddwf8o/install-record.txt --single-version-externally-managed --prefix /usr/local --compile --install-headers /usr/local/include/python3.8/pybfd3
         cwd: /tmp/pip-install-91o8i9rs/pybfd3/
    Complete output (6 lines):
    usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: setup.py --help [cmd1 cmd2 ...]
       or: setup.py --help-commands
       or: setup.py cmd --help
    
    error: option --single-version-externally-managed not recognized
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-91o8i9rs/pybfd3/setup.py'"'"'; __file__='"'"'/tmp/pip-install-91o8i9rs/pybfd3/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-pnddwf8o/install-record.txt --single-version-externally-managed --prefix /usr/local --compile --install-headers /usr/local/include/python3.8/pybfd3 Check the logs for full command output.

Trying to compile from source produces other errors.

running build
running build_py
running build_ext
[+] Using binutils headers at:
[+]   /usr/include
[+] Searching binutils libraries...
[+]   /usr/lib/libbfd.so
[+]   /usr/lib/libopcodes.so
[+] Detecting libbfd/libopcodes compiled architectures
nm: /usr/lib/libopcodes.so: file format not recognized
[+] Generating .C files...
[+]   pybfd3/gen_bfd_archs.c
cc -I/usr/include -c pybfd3/gen_bfd_archs.c -o pybfd3/gen_bfd_archs.o
cc pybfd3/gen_bfd_archs.o -L/usr/lib -L/usr/lib -lbfd -lopcodes -o pybfd3/gen_bfd_archs
[+] Generating .py files...
[+]   build/lib.linux-x86_64-3.8/pybfd3/bfd_archs.py
[-] Error : Unable to determine libopcodes' supported platforms from '/usr/lib/libopcodes.so'

Arch Linux has a static binutils with /usr/lib/libopcodes.so a linker script that nm can't parse. I added --with-static-binutils=/usr to the pip command (this doesn't seem to be documented) but this produces the following error

$ python setup.py build --with-static-binutils=/usr
running build
running build_py
running build_ext
[+] Using specific binutils static distribution
[+]   /usr
[+] Using binutils headers at:
[+]   /usr/include
[+] Searching binutils libraries...
[+]   /usr/lib/libbfd.a
[+]   /usr/lib/libopcodes.a
[+] Detecting libbfd/libopcodes compiled architectures
[-] Error : name 'libs_dir' is not defined

The following patch fixes this error

--- a/setup.py
+++ b/setup.py
@@ -194,8 +194,12 @@
         if self.with_static_binutils: # use the nm from the binutils distro
 
             nms = [
-                os.path.join( libs_dir, "..", "bin", "nm" ), # default name of nm
+                os.path.join( libs_dir, "..", "bin", "nm" ) # default name of nm
+                for libs_dir in libs_dirs
+            ]
+            nms = nms + [
                 os.path.join( libs_dir, "..", "bin", "gnm" ) # in OSX brew install binutils's nm as gnm.
+                for libs_dir in libs_dirs
             ]
             path_to_nm = None
             for nm_fullpath in nms:

With this error resolved, the following error appears

$ python setup.py build --with-static-binutils=/usr
running build
running build_py
running build_ext
[+] Using specific binutils static distribution
[+]   /usr
[+] Using binutils headers at:
[+]   /usr/include
[+] Searching binutils libraries...
[+]   /usr/lib/libbfd.a
[+]   /usr/lib/libopcodes.a
[+] Detecting libbfd/libopcodes compiled architectures
[+] Generating .C files...
[+]   pybfd3/gen_bfd_archs.c
cc -I/usr/include -c pybfd3/gen_bfd_archs.c -o pybfd3/gen_bfd_archs.o
cc pybfd3/gen_bfd_archs.o -L/usr/lib -L/usr/lib -o pybfd3/gen_bfd_archs
[+] Generating .py files...
[+]   build/lib.linux-x86_64-3.8/pybfd3/bfd_archs.py
[+] Generating .h files...
[+]   pybfd3/supported_disasm.h
building 'pybfd3._opcodes' extension
/usr/bin/gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -fno-semantic-interposition -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -march=x86-64 -mtune=generic -O3 -pipe -fno-plt -O3 -DNDEBUG -fPIC -mtune=generic -O3 -DNDEBUG -fPIC -mtune=generic -fPIC -I/usr/include -I/usr/include/python3.8 -c pybfd3/opcodes.c -o build/temp.linux-x86_64-3.8/pybfd3/opcodes.o
In file included from pybfd3/opcodes.c:14:
pybfd3/supported_disasm.h:19:21: error: ‘print_insn_i386’ undeclared here (not in a function); did you mean ‘print_insn_m32c’?
   19 |     {bfd_arch_i386, print_insn_i386, print_insn_i386},
      |                     ^~~~~~~~~~~~~~~
      |                     print_insn_m32c
pybfd3/opcodes.c: In function ‘pyopcodes_initialize_bfd’:
pybfd3/opcodes.c:979:57: error: incompatible type for argument 1 of ‘disassembler’
  979 |             pdisasm_ptr->pfn_disassemble = disassembler(abfd);
      |                                                         ^~~~
      |                                                         |
      |                                                         bfd *
In file included from pybfd3/bfd_headers.h:13,
                 from pybfd3/opcodes.c:13:
/usr/include/dis-asm.h:322:63: note: expected ‘enum bfd_architecture’ but argument is of type ‘bfd *’
  322 | extern disassembler_ftype disassembler (enum bfd_architecture arc,
      |                                         ~~~~~~~~~~~~~~~~~~~~~~^~~
pybfd3/opcodes.c:979:44: error: too few arguments to function ‘disassembler’
  979 |             pdisasm_ptr->pfn_disassemble = disassembler(abfd);
      |                                            ^~~~~~~~~~~~
In file included from pybfd3/bfd_headers.h:13,
                 from pybfd3/opcodes.c:13:
/usr/include/dis-asm.h:322:27: note: declared here
  322 | extern disassembler_ftype disassembler (enum bfd_architecture arc,
      |                           ^~~~~~~~~~~~
pybfd3/opcodes.c:979:42: warning: assignment to ‘disassembler_ftype’ {aka ‘int (*)(long unsigned int,  disassemble_info *)’} from incompatible pointer type ‘supported_disasm *’ {aka ‘struct _supported_disasm *’} [-Wincompatible-pointer-types]
  979 |             pdisasm_ptr->pfn_disassemble = disassembler(abfd);
      |                                          ^
error: command '/usr/bin/gcc' failed with exit status 1

This is, unfortunately, where I run into a wall. What is wrong here?

I have done some more digging and it appears that the compiler errors are a result of an API change in binutils v2.29. The following patch resolves all of the errors I have come across. I haven't yet tested that it is functionally correct, but python setup.py build --with-static-binutils=/usr completes without error.

diff --git a/pybfd3/bfd_headers.h b/pybfd3/bfd_headers.h
index 096e5c4..eadab5c 100644
--- a/pybfd3/bfd_headers.h
+++ b/pybfd3/bfd_headers.h
@@ -12,6 +12,11 @@
 
 #include <dis-asm.h>
 
+#ifdef PYBFD3_BFD_GE_2_29
+// In binutils 2.29 print_insn_i386 disappeared from the dis-asm.h header
+int print_insn_i386 (bfd_vma, disassemble_info *);
+#endif
+
 #define PYBFD3_SYMBOL_VALUE_FMT "k" // unsigned long
 #define PYBFD3_SYMBOL_FLAG_FMT "I" // typedef unsigned int flagword;	/* 32 bits of flags */
 
diff --git a/pybfd3/opcodes.c b/pybfd3/opcodes.c
index 6ab9034..dbd94a5 100644
--- a/pybfd3/opcodes.c
+++ b/pybfd3/opcodes.c
@@ -976,7 +976,15 @@ static PyObject * pyopcodes_initialize_bfd(PyObject *self, PyObject *args)
                 bfd_big_endian(abfd) ? BFD_ENDIAN_BIG : BFD_ENDIAN_LITTLE;
 
             // Assign the disassembler function selected by BFD itself.
+#ifdef PYBFD3_BFD_GE_2_29
+            // In binutils 2.29 the signature for disassembler changed
+            pdisasm_ptr->pfn_disassemble = disassembler(bfd_get_arch(abfd),
+                bfd_little_endian(abfd) ? FALSE : TRUE,
+                bfd_get_mach(abfd),
+                NULL);
+#else
             pdisasm_ptr->pfn_disassemble = disassembler(abfd);
+#endif
 
             if (pdisasm_ptr->pfn_disassemble) {
                 return Py_BuildValue("n", pdisasm_ptr);
diff --git a/setup.py b/setup.py
index 838a335..df9555a 100644
--- a/setup.py
+++ b/setup.py
@@ -194,8 +194,12 @@ class CustomBuildExtension( build_ext ):
         if self.with_static_binutils: # use the nm from the binutils distro
 
             nms = [
-                os.path.join( libs_dir, "..", "bin", "nm" ), # default name of nm
+                os.path.join( libs_dir, "..", "bin", "nm" ) # default name of nm
+                for libs_dir in libs_dirs
+            ]
+            nms = nms + [
                 os.path.join( libs_dir, "..", "bin", "gnm" ) # in OSX brew install binutils's nm as gnm.
+                for libs_dir in libs_dirs
             ]
             path_to_nm = None
             for nm_fullpath in nms:
@@ -221,6 +225,20 @@ class CustomBuildExtension( build_ext ):
             self.with_static_binutils == None)
 
         source_bfd_archs_c = generate_supported_architectures_source(supported_archs, supported_machines)
+        print("[+] Testing for print_insn_i386...")
+        try:
+            c_compiler = new_compiler()
+            objects = c_compiler.compile(
+                [os.path.join(PACKAGE_DIR, "test_print_insn_i386.c"), ],
+                include_dirs = [self.includes,],
+                )
+            if len(objects) > 0:
+                macros = None
+            else:
+                macros = [("PYBFD3_BFD_GE_2_29", None)]
+        except:
+            macros = [("PYBFD3_BFD_GE_2_29", None)]
+
         print("[+] Generating .C files...")
         gen_file = os.path.join(PACKAGE_DIR, "gen_bfd_archs.c")
         with io.open(gen_file, "w+") as fd:
@@ -235,7 +253,8 @@ class CustomBuildExtension( build_ext ):
         c_compiler = new_compiler()
         objects = c_compiler.compile(
             [os.path.join(PACKAGE_DIR, "gen_bfd_archs.c"), ],
-            include_dirs = [self.includes,]
+            include_dirs = [self.includes,],
+            macros=macros,
             )
         program = c_compiler.link_executable(
             objects,
@@ -280,7 +299,7 @@ class CustomBuildExtension( build_ext ):
             self.write_to_file(fd, gen_source)
         print("[+]   %s" % gen_file)
 
-        return supported_archs
+        return supported_archs, macros
 
     def _darwin_current_arch(self):
         """Add Mac OS X support."""
@@ -373,7 +392,7 @@ class CustomBuildExtension( build_ext ):
             ext_extra_objects.append(lib_liberty_fullpath)
 
         # generate .py / .h files that depends of libopcodes / libbfd currently selected
-        final_supported_archs = self.generate_source_files()
+        final_supported_archs, macros = self.generate_source_files()
 
         # final hacks for OSX
         if sys.platform == "darwin":
@@ -397,6 +416,7 @@ class CustomBuildExtension( build_ext ):
             extension.extra_objects.extend( ext_extra_objects )
             extension.libraries.extend( ext_libs )
             extension.library_dirs.extend( ext_libs_dir )
+            extension.define_macros.extend( macros )
 
         return build_ext.build_extensions(self)
 

I have made a pull request that makes this package compatible with newer binutils

b-2-r commented

Thank you for spending time and investigating the problem!
I merged your PR =)

@b-2-r did merging the PR also update pypi?

b-2-r commented

@Bidski

I published pybfd3 0.1.4 today which reflects the changes you made. The README was also updated to emphasize the fact that binutils-dev must be installed first.

I did a few test runs to verify that everything is working as expected and it looks good so far.

Let me know if anything is still not working... =)

Testing Environment

Kali Linux 2020.1

  • pip 18.1 (python 2.7), setuptools 44.0.0
  • pip 18.1 (python 3.7), setuptools 44.0.0
  • binutils-dev 2.35, libbinutils 2.35

Ubuntu 20.04

  • pip 20.2.2 (python 2.7), setuptools 44.0.0
  • pip 20.0.2 (python 3.8), setuptools 45.2.0
  • binutils-dev 2.34, libbinutils 2.34

I still get "error: option --single-version-externally-managed not recognized". The "--egg" command line options is no longer supported and my setuptools and wheel versions are up-to-date (as per the suggestion in this post). I am unable to find any other suggestions for how to resolve this issue.

This is the install command I am using

$ sudo -H pip install pybfd3 --install-option="--with-static-binutils=/usr"

Pip logs

2020-09-07T09:44:03,094 User install by explicit request
2020-09-07T09:44:03,212 Created temporary directory: /tmp/pip-ephem-wheel-cache-c33h19us
2020-09-07T09:44:03,212 Created temporary directory: /tmp/pip-req-tracker-adk6ascr
2020-09-07T09:44:03,212 Initialized build tracking at /tmp/pip-req-tracker-adk6ascr
2020-09-07T09:44:03,212 Created build tracker: /tmp/pip-req-tracker-adk6ascr
2020-09-07T09:44:03,212 Entered build tracker: /tmp/pip-req-tracker-adk6ascr
2020-09-07T09:44:03,213 Created temporary directory: /tmp/pip-install-m6th6xrx
2020-09-07T09:44:03,281 1 location(s) to search for versions of pybfd3:
2020-09-07T09:44:03,281 * https://pypi.org/simple/pybfd3/
2020-09-07T09:44:03,281 Fetching project page and analyzing links: https://pypi.org/simple/pybfd3/
2020-09-07T09:44:03,281 Getting page https://pypi.org/simple/pybfd3/
2020-09-07T09:44:03,282 Found index url https://pypi.org/simple
2020-09-07T09:44:03,282 Getting credentials from keyring for https://pypi.org/simple
2020-09-07T09:44:03,284 Getting credentials from keyring for pypi.org
2020-09-07T09:44:03,287 Looking up "https://pypi.org/simple/pybfd3/" in the cache
2020-09-07T09:44:03,287 Request header has "max_age" as 0, cache bypassed
2020-09-07T09:44:03,287 Starting new HTTPS connection (1): pypi.org:443
2020-09-07T09:44:03,333 https://pypi.org:443 "GET /simple/pybfd3/ HTTP/1.1" 304 0
2020-09-07T09:44:03,369   Found link https://files.pythonhosted.org/packages/8c/0a/496786eb8f9765f3453f698910b06ba968f18870b6afa61a6bc0ef2dd41d/pybfd3-0.1.1.tar.gz#sha256=0279a655f2c30c98a131d49bdad741aa98ba9b027d48f280dbf0c820f4af73d1 (from https://pypi.org/simple/pybfd3/), version: 0.1.1
2020-09-07T09:44:03,370   Found link https://files.pythonhosted.org/packages/5d/84/9c12bc403b3d83722db888062b34112c4d0089eecbd08ea6fb4f9e957ae2/pybfd3-0.1.2.tar.gz#sha256=f0d6b8212b84aaa70896ae04d85fb96773fb81cf304cca4565646e634fe6cfb8 (from https://pypi.org/simple/pybfd3/), version: 0.1.2
2020-09-07T09:44:03,370   Found link https://files.pythonhosted.org/packages/70/f0/85856d699783e4a725632fe7a9ae69cc9beae0df306e49113086fdefd824/pybfd3-0.1.3.tar.gz#sha256=1dd067d8c457aa2502acb8e25d4b14add0dde9ff81a37d60a25fb63413c767a1 (from https://pypi.org/simple/pybfd3/), version: 0.1.3
2020-09-07T09:44:03,370   Found link https://files.pythonhosted.org/packages/0c/b0/a3d1a689757297508336ff2bb910cb233d22e716695432d2fe4f78764f9e/pybfd3-0.1.4.tar.gz#sha256=983da41a09ff2fff770f3c84e566b6adac37c9559690653b4f740a0c75fdcdcf (from https://pypi.org/simple/pybfd3/), version: 0.1.4
2020-09-07T09:44:03,371 Given no hashes to check 4 links for project 'pybfd3': discarding no candidates
2020-09-07T09:44:03,372 Using version 0.1.4 (newest of versions: 0.1.1, 0.1.2, 0.1.3, 0.1.4)
2020-09-07T09:44:03,373 Collecting pybfd3
2020-09-07T09:44:03,373   Created temporary directory: /tmp/pip-unpack-2oq7e1vp
2020-09-07T09:44:03,374   Getting credentials from keyring for files.pythonhosted.org
2020-09-07T09:44:03,377   Looking up "https://files.pythonhosted.org/packages/0c/b0/a3d1a689757297508336ff2bb910cb233d22e716695432d2fe4f78764f9e/pybfd3-0.1.4.tar.gz" in the cache
2020-09-07T09:44:03,378   Current age based on date: 93
2020-09-07T09:44:03,378   Ignoring unknown cache-control directive: immutable
2020-09-07T09:44:03,378   Freshness lifetime from max-age: 365000000
2020-09-07T09:44:03,378   The response is "fresh", returning cached response
2020-09-07T09:44:03,378   365000000 > 93
2020-09-07T09:44:03,379   Using cached pybfd3-0.1.4.tar.gz (48 kB)
2020-09-07T09:44:03,388   Added pybfd3 from https://files.pythonhosted.org/packages/0c/b0/a3d1a689757297508336ff2bb910cb233d22e716695432d2fe4f78764f9e/pybfd3-0.1.4.tar.gz#sha256=983da41a09ff2fff770f3c84e566b6adac37c9559690653b4f740a0c75fdcdcf to build tracker '/tmp/pip-req-tracker-adk6ascr'
2020-09-07T09:44:03,388     Running setup.py (path:/tmp/pip-install-m6th6xrx/pybfd3/setup.py) egg_info for package pybfd3
2020-09-07T09:44:03,388     Created temporary directory: /tmp/pip-pip-egg-info-58cvxurd
2020-09-07T09:44:03,388     Running command python setup.py egg_info
2020-09-07T09:44:03,659     running egg_info
2020-09-07T09:44:03,659     creating /tmp/pip-pip-egg-info-58cvxurd/pybfd3.egg-info
2020-09-07T09:44:03,659     writing /tmp/pip-pip-egg-info-58cvxurd/pybfd3.egg-info/PKG-INFO
2020-09-07T09:44:03,659     writing dependency_links to /tmp/pip-pip-egg-info-58cvxurd/pybfd3.egg-info/dependency_links.txt
2020-09-07T09:44:03,659     writing requirements to /tmp/pip-pip-egg-info-58cvxurd/pybfd3.egg-info/requires.txt
2020-09-07T09:44:03,660     writing top-level names to /tmp/pip-pip-egg-info-58cvxurd/pybfd3.egg-info/top_level.txt
2020-09-07T09:44:03,660     writing manifest file '/tmp/pip-pip-egg-info-58cvxurd/pybfd3.egg-info/SOURCES.txt'
2020-09-07T09:44:03,672     reading manifest file '/tmp/pip-pip-egg-info-58cvxurd/pybfd3.egg-info/SOURCES.txt'
2020-09-07T09:44:03,672     reading manifest template 'MANIFEST.in'
2020-09-07T09:44:03,673     writing manifest file '/tmp/pip-pip-egg-info-58cvxurd/pybfd3.egg-info/SOURCES.txt'
2020-09-07T09:44:03,686   Source in /tmp/pip-install-m6th6xrx/pybfd3 has version 0.1.4, which satisfies requirement pybfd3 from https://files.pythonhosted.org/packages/0c/b0/a3d1a689757297508336ff2bb910cb233d22e716695432d2fe4f78764f9e/pybfd3-0.1.4.tar.gz#sha256=983da41a09ff2fff770f3c84e566b6adac37c9559690653b4f740a0c75fdcdcf
2020-09-07T09:44:03,687   Removed pybfd3 from https://files.pythonhosted.org/packages/0c/b0/a3d1a689757297508336ff2bb910cb233d22e716695432d2fe4f78764f9e/pybfd3-0.1.4.tar.gz#sha256=983da41a09ff2fff770f3c84e566b6adac37c9559690653b4f740a0c75fdcdcf from build tracker '/tmp/pip-req-tracker-adk6ascr'
2020-09-07T09:44:03,785 Requirement already satisfied: future in /usr/lib/python3.8/site-packages (from pybfd3) (0.18.2)
2020-09-07T09:44:03,786 Skipping wheel build for pybfd3, due to binaries being disabled for it.
2020-09-07T09:44:04,113 Installing collected packages: pybfd3
2020-09-07T09:44:04,115   Created temporary directory: /tmp/pip-record-alzfvxww
2020-09-07T09:44:04,115     Running command /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-m6th6xrx/pybfd3/setup.py'"'"'; __file__='"'"'/tmp/pip-install-m6th6xrx/pybfd3/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-alzfvxww/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/bidski/.local/include/python3.8/pybfd3 --with-static-binutils=/usr
2020-09-07T09:44:04,384     usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
2020-09-07T09:44:04,385        or: setup.py --help [cmd1 cmd2 ...]
2020-09-07T09:44:04,385        or: setup.py --help-commands
2020-09-07T09:44:04,385        or: setup.py cmd --help

2020-09-07T09:44:04,385     error: option --single-version-externally-managed not recognized
2020-09-07T09:44:04,397 ERROR: Command errored out with exit status 1: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-m6th6xrx/pybfd3/setup.py'"'"'; __file__='"'"'/tmp/pip-install-m6th6xrx/pybfd3/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-alzfvxww/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/bidski/.local/include/python3.8/pybfd3 --with-static-binutils=/usr Check the logs for full command output.
2020-09-07T09:44:04,397 Exception information:
2020-09-07T09:44:04,397 Traceback (most recent call last):
2020-09-07T09:44:04,397   File "/usr/lib/python3.8/site-packages/pip/_internal/req/req_install.py", line 827, in install
2020-09-07T09:44:04,397     success = install_legacy(
2020-09-07T09:44:04,397   File "/usr/lib/python3.8/site-packages/pip/_internal/operations/install/legacy.py", line 86, in install
2020-09-07T09:44:04,397     raise LegacyInstallFailure
2020-09-07T09:44:04,397 pip._internal.operations.install.legacy.LegacyInstallFailure
2020-09-07T09:44:04,397 
2020-09-07T09:44:04,397 During handling of the above exception, another exception occurred:
2020-09-07T09:44:04,397 
2020-09-07T09:44:04,397 Traceback (most recent call last):
2020-09-07T09:44:04,397   File "/usr/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 188, in _main
2020-09-07T09:44:04,397     status = self.run(options, args)
2020-09-07T09:44:04,397   File "/usr/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 185, in wrapper
2020-09-07T09:44:04,397     return func(self, options, args)
2020-09-07T09:44:04,397   File "/usr/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 398, in run
2020-09-07T09:44:04,397     installed = install_given_reqs(
2020-09-07T09:44:04,397   File "/usr/lib/python3.8/site-packages/pip/_internal/req/__init__.py", line 67, in install_given_reqs
2020-09-07T09:44:04,397     requirement.install(
2020-09-07T09:44:04,397   File "/usr/lib/python3.8/site-packages/pip/_internal/req/req_install.py", line 845, in install
2020-09-07T09:44:04,397     six.reraise(*exc.parent)
2020-09-07T09:44:04,397   File "/usr/lib/python3.8/site-packages/six.py", line 703, in reraise
2020-09-07T09:44:04,397     raise value
2020-09-07T09:44:04,397   File "/usr/lib/python3.8/site-packages/pip/_internal/operations/install/legacy.py", line 74, in install
2020-09-07T09:44:04,397     runner(
2020-09-07T09:44:04,397   File "/usr/lib/python3.8/site-packages/pip/_internal/utils/subprocess.py", line 270, in runner
2020-09-07T09:44:04,397     call_subprocess(
2020-09-07T09:44:04,397   File "/usr/lib/python3.8/site-packages/pip/_internal/utils/subprocess.py", line 241, in call_subprocess
2020-09-07T09:44:04,397     raise InstallationError(exc_msg)
2020-09-07T09:44:04,397 pip._internal.exceptions.InstallationError: Command errored out with exit status 1: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-m6th6xrx/pybfd3/setup.py'"'"'; __file__='"'"'/tmp/pip-install-m6th6xrx/pybfd3/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-alzfvxww/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/bidski/.local/include/python3.8/pybfd3 --with-static-binutils=/usr Check the logs for full command output.
2020-09-07T09:44:04,553 Removed build tracker: '/tmp/pip-req-tracker-adk6ascr'
2020-09-07T09:44:25,915 User install by explicit request
2020-09-07T09:44:26,012 Created temporary directory: /tmp/pip-ephem-wheel-cache-vpnkuoz1
2020-09-07T09:44:26,012 Created temporary directory: /tmp/pip-req-tracker-q7xbq9cm
2020-09-07T09:44:26,012 Initialized build tracking at /tmp/pip-req-tracker-q7xbq9cm
2020-09-07T09:44:26,012 Created build tracker: /tmp/pip-req-tracker-q7xbq9cm
2020-09-07T09:44:26,012 Entered build tracker: /tmp/pip-req-tracker-q7xbq9cm
2020-09-07T09:44:26,012 Created temporary directory: /tmp/pip-install-59mxtpid
2020-09-07T09:44:26,082 1 location(s) to search for versions of pybfd3:
2020-09-07T09:44:26,082 * https://pypi.org/simple/pybfd3/
2020-09-07T09:44:26,082 Fetching project page and analyzing links: https://pypi.org/simple/pybfd3/
2020-09-07T09:44:26,082 Getting page https://pypi.org/simple/pybfd3/
2020-09-07T09:44:26,082 Found index url https://pypi.org/simple
2020-09-07T09:44:26,082 Getting credentials from keyring for https://pypi.org/simple
2020-09-07T09:44:26,083 Getting credentials from keyring for pypi.org
2020-09-07T09:44:26,083 Looking up "https://pypi.org/simple/pybfd3/" in the cache
2020-09-07T09:44:26,083 Request header has "max_age" as 0, cache bypassed
2020-09-07T09:44:26,083 Starting new HTTPS connection (1): pypi.org:443
2020-09-07T09:44:26,128 https://pypi.org:443 "GET /simple/pybfd3/ HTTP/1.1" 304 0
2020-09-07T09:44:26,144   Found link https://files.pythonhosted.org/packages/8c/0a/496786eb8f9765f3453f698910b06ba968f18870b6afa61a6bc0ef2dd41d/pybfd3-0.1.1.tar.gz#sha256=0279a655f2c30c98a131d49bdad741aa98ba9b027d48f280dbf0c820f4af73d1 (from https://pypi.org/simple/pybfd3/), version: 0.1.1
2020-09-07T09:44:26,145   Found link https://files.pythonhosted.org/packages/5d/84/9c12bc403b3d83722db888062b34112c4d0089eecbd08ea6fb4f9e957ae2/pybfd3-0.1.2.tar.gz#sha256=f0d6b8212b84aaa70896ae04d85fb96773fb81cf304cca4565646e634fe6cfb8 (from https://pypi.org/simple/pybfd3/), version: 0.1.2
2020-09-07T09:44:26,145   Found link https://files.pythonhosted.org/packages/70/f0/85856d699783e4a725632fe7a9ae69cc9beae0df306e49113086fdefd824/pybfd3-0.1.3.tar.gz#sha256=1dd067d8c457aa2502acb8e25d4b14add0dde9ff81a37d60a25fb63413c767a1 (from https://pypi.org/simple/pybfd3/), version: 0.1.3
2020-09-07T09:44:26,145   Found link https://files.pythonhosted.org/packages/0c/b0/a3d1a689757297508336ff2bb910cb233d22e716695432d2fe4f78764f9e/pybfd3-0.1.4.tar.gz#sha256=983da41a09ff2fff770f3c84e566b6adac37c9559690653b4f740a0c75fdcdcf (from https://pypi.org/simple/pybfd3/), version: 0.1.4
2020-09-07T09:44:26,145 Given no hashes to check 4 links for project 'pybfd3': discarding no candidates
2020-09-07T09:44:26,146 Using version 0.1.4 (newest of versions: 0.1.1, 0.1.2, 0.1.3, 0.1.4)
2020-09-07T09:44:26,146 Collecting pybfd3
2020-09-07T09:44:26,146   Created temporary directory: /tmp/pip-unpack-os452u0v
2020-09-07T09:44:26,147   Getting credentials from keyring for files.pythonhosted.org
2020-09-07T09:44:26,147   Looking up "https://files.pythonhosted.org/packages/0c/b0/a3d1a689757297508336ff2bb910cb233d22e716695432d2fe4f78764f9e/pybfd3-0.1.4.tar.gz" in the cache
2020-09-07T09:44:26,147   Current age based on date: 1705
2020-09-07T09:44:26,147   Ignoring unknown cache-control directive: immutable
2020-09-07T09:44:26,147   Freshness lifetime from max-age: 365000000
2020-09-07T09:44:26,147   The response is "fresh", returning cached response
2020-09-07T09:44:26,147   365000000 > 1705
2020-09-07T09:44:26,147   Using cached pybfd3-0.1.4.tar.gz (48 kB)
2020-09-07T09:44:26,152   Added pybfd3 from https://files.pythonhosted.org/packages/0c/b0/a3d1a689757297508336ff2bb910cb233d22e716695432d2fe4f78764f9e/pybfd3-0.1.4.tar.gz#sha256=983da41a09ff2fff770f3c84e566b6adac37c9559690653b4f740a0c75fdcdcf to build tracker '/tmp/pip-req-tracker-q7xbq9cm'
2020-09-07T09:44:26,153     Running setup.py (path:/tmp/pip-install-59mxtpid/pybfd3/setup.py) egg_info for package pybfd3
2020-09-07T09:44:26,153     Created temporary directory: /tmp/pip-pip-egg-info-_7h71p5k
2020-09-07T09:44:26,153     Running command python setup.py egg_info
2020-09-07T09:44:26,402     running egg_info
2020-09-07T09:44:26,402     creating /tmp/pip-pip-egg-info-_7h71p5k/pybfd3.egg-info
2020-09-07T09:44:26,402     writing /tmp/pip-pip-egg-info-_7h71p5k/pybfd3.egg-info/PKG-INFO
2020-09-07T09:44:26,402     writing dependency_links to /tmp/pip-pip-egg-info-_7h71p5k/pybfd3.egg-info/dependency_links.txt
2020-09-07T09:44:26,403     writing requirements to /tmp/pip-pip-egg-info-_7h71p5k/pybfd3.egg-info/requires.txt
2020-09-07T09:44:26,403     writing top-level names to /tmp/pip-pip-egg-info-_7h71p5k/pybfd3.egg-info/top_level.txt
2020-09-07T09:44:26,403     writing manifest file '/tmp/pip-pip-egg-info-_7h71p5k/pybfd3.egg-info/SOURCES.txt'
2020-09-07T09:44:26,415     reading manifest file '/tmp/pip-pip-egg-info-_7h71p5k/pybfd3.egg-info/SOURCES.txt'
2020-09-07T09:44:26,415     reading manifest template 'MANIFEST.in'
2020-09-07T09:44:26,416     writing manifest file '/tmp/pip-pip-egg-info-_7h71p5k/pybfd3.egg-info/SOURCES.txt'
2020-09-07T09:44:26,429   Source in /tmp/pip-install-59mxtpid/pybfd3 has version 0.1.4, which satisfies requirement pybfd3 from https://files.pythonhosted.org/packages/0c/b0/a3d1a689757297508336ff2bb910cb233d22e716695432d2fe4f78764f9e/pybfd3-0.1.4.tar.gz#sha256=983da41a09ff2fff770f3c84e566b6adac37c9559690653b4f740a0c75fdcdcf
2020-09-07T09:44:26,429   Removed pybfd3 from https://files.pythonhosted.org/packages/0c/b0/a3d1a689757297508336ff2bb910cb233d22e716695432d2fe4f78764f9e/pybfd3-0.1.4.tar.gz#sha256=983da41a09ff2fff770f3c84e566b6adac37c9559690653b4f740a0c75fdcdcf from build tracker '/tmp/pip-req-tracker-q7xbq9cm'
2020-09-07T09:44:26,521 Requirement already satisfied: future in /usr/lib/python3.8/site-packages (from pybfd3) (0.18.2)
2020-09-07T09:44:26,522 Skipping wheel build for pybfd3, due to binaries being disabled for it.
2020-09-07T09:44:26,843 Installing collected packages: pybfd3
2020-09-07T09:44:26,844   Created temporary directory: /tmp/pip-record-xu6bqrva
2020-09-07T09:44:26,844     Running command /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-59mxtpid/pybfd3/setup.py'"'"'; __file__='"'"'/tmp/pip-install-59mxtpid/pybfd3/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-xu6bqrva/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /root/.local/include/python3.8/pybfd3 --with-static-binutils=/usr
2020-09-07T09:44:27,086     usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
2020-09-07T09:44:27,086        or: setup.py --help [cmd1 cmd2 ...]
2020-09-07T09:44:27,086        or: setup.py --help-commands
2020-09-07T09:44:27,086        or: setup.py cmd --help

2020-09-07T09:44:27,087     error: option --single-version-externally-managed not recognized
2020-09-07T09:44:27,097 ERROR: Command errored out with exit status 1: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-59mxtpid/pybfd3/setup.py'"'"'; __file__='"'"'/tmp/pip-install-59mxtpid/pybfd3/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-xu6bqrva/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /root/.local/include/python3.8/pybfd3 --with-static-binutils=/usr Check the logs for full command output.
2020-09-07T09:44:27,098 Exception information:
2020-09-07T09:44:27,098 Traceback (most recent call last):
2020-09-07T09:44:27,098   File "/usr/lib/python3.8/site-packages/pip/_internal/req/req_install.py", line 827, in install
2020-09-07T09:44:27,098     success = install_legacy(
2020-09-07T09:44:27,098   File "/usr/lib/python3.8/site-packages/pip/_internal/operations/install/legacy.py", line 86, in install
2020-09-07T09:44:27,098     raise LegacyInstallFailure
2020-09-07T09:44:27,098 pip._internal.operations.install.legacy.LegacyInstallFailure
2020-09-07T09:44:27,098 
2020-09-07T09:44:27,098 During handling of the above exception, another exception occurred:
2020-09-07T09:44:27,098 
2020-09-07T09:44:27,098 Traceback (most recent call last):
2020-09-07T09:44:27,098   File "/usr/lib/python3.8/site-packages/pip/_internal/cli/base_command.py", line 188, in _main
2020-09-07T09:44:27,098     status = self.run(options, args)
2020-09-07T09:44:27,098   File "/usr/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 185, in wrapper
2020-09-07T09:44:27,098     return func(self, options, args)
2020-09-07T09:44:27,098   File "/usr/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 398, in run
2020-09-07T09:44:27,098     installed = install_given_reqs(
2020-09-07T09:44:27,098   File "/usr/lib/python3.8/site-packages/pip/_internal/req/__init__.py", line 67, in install_given_reqs
2020-09-07T09:44:27,098     requirement.install(
2020-09-07T09:44:27,098   File "/usr/lib/python3.8/site-packages/pip/_internal/req/req_install.py", line 845, in install
2020-09-07T09:44:27,098     six.reraise(*exc.parent)
2020-09-07T09:44:27,098   File "/usr/lib/python3.8/site-packages/six.py", line 703, in reraise
2020-09-07T09:44:27,098     raise value
2020-09-07T09:44:27,098   File "/usr/lib/python3.8/site-packages/pip/_internal/operations/install/legacy.py", line 74, in install
2020-09-07T09:44:27,098     runner(
2020-09-07T09:44:27,098   File "/usr/lib/python3.8/site-packages/pip/_internal/utils/subprocess.py", line 270, in runner
2020-09-07T09:44:27,098     call_subprocess(
2020-09-07T09:44:27,098   File "/usr/lib/python3.8/site-packages/pip/_internal/utils/subprocess.py", line 241, in call_subprocess
2020-09-07T09:44:27,098     raise InstallationError(exc_msg)
2020-09-07T09:44:27,098 pip._internal.exceptions.InstallationError: Command errored out with exit status 1: /usr/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-59mxtpid/pybfd3/setup.py'"'"'; __file__='"'"'/tmp/pip-install-59mxtpid/pybfd3/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-xu6bqrva/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /root/.local/include/python3.8/pybfd3 --with-static-binutils=/usr Check the logs for full command output.
2020-09-07T09:44:27,256 Removed build tracker: '/tmp/pip-req-tracker-q7xbq9cm'
b-2-r commented

Can you please just try:

$ sudo pip install -v pybfd3

What does pip say?

@b-2-r sorry, I should have mentioned. The pip output above is from add --verbose to the command line

b-2-r commented

Puh... Unfortunately I don't have the time to further investigate on this issue.
Would you be willing to continue working on this and then share your results via a PR?

b-2-r commented

@Bidski Well done! I merged your PR and updated pybfd3 to version 0.1.5 (also on PyPi). The README now contains a changelog section. Thanks again for your support!