smartfile / python-libarchive

Libarchive wrapper for Python.
BSD 3-Clause "New" or "Revised" License
23 stars 10 forks source link

Cannot build on OSX 10.11 with XCode 7 toolchain #5

Closed bsergean closed 2 years ago

bsergean commented 8 years ago
Collecting python-libarchive
  Downloading python-libarchive-3.1.2-1.tar.gz (73kB)
    100% |████████████████████████████████| 81kB 612kB/s 
Building wheels for collected packages: python-libarchive
  Running setup.py bdist_wheel for python-libarchive ... error
  Complete output from command /Users/bsergeant/sandbox/venv/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/qz/cb1zd5756hnd2tykv7z5sn_j8408d8/T/pip-build-AP10r8/python-libarchive/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bdist_wheel -d /var/folders/qz/cb1zd5756hnd2tykv7z5sn_j8408d8/T/tmpuip1HQpip-wheel- --python-tag cp27:
  /Users/bsergeant/sandbox/venv/lib/python2.7/site-packages/setuptools/dist.py:331: UserWarning: Normalizing '3.1.2-1' to '3.1.2.post1'
    normalized_version,
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.11-intel-2.7
  creating build/lib.macosx-10.11-intel-2.7/libarchive
  copying libarchive/__init__.py -> build/lib.macosx-10.11-intel-2.7/libarchive
  copying libarchive/_libarchive.py -> build/lib.macosx-10.11-intel-2.7/libarchive
  copying libarchive/tar.py -> build/lib.macosx-10.11-intel-2.7/libarchive
  copying libarchive/zip.py -> build/lib.macosx-10.11-intel-2.7/libarchive
  running build_ext
  building 'libarchive.__libarchive' extension
  creating build/temp.macosx-10.11-intel-2.7
  creating build/temp.macosx-10.11-intel-2.7/libarchive
  cc -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -Ilibarchive -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c libarchive/_libarchive_wrap.c -o build/temp.macosx-10.11-intel-2.7/libarchive/_libarchive_wrap.o
  libarchive/_libarchive_wrap.c:2351:23: warning: explicitly assigning value of variable of type 'int' to itself [-Wself-assign]
                    res = SWIG_AddCast(res);
                    ~~~ ^              ~~~
  libarchive/_libarchive_wrap.c:2354:23: warning: explicitly assigning value of variable of type 'int' to itself [-Wself-assign]
                    res = SWIG_AddCast(res);
                    ~~~ ^              ~~~
  libarchive/_libarchive_wrap.c:2876:9: warning: variable 'res' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
      if (PyType_Ready(tp) < 0)
          ^~~~~~~~~~~~~~~~~~~~
  libarchive/_libarchive_wrap.c:2900:10: note: uninitialized use occurs here
    return res;
           ^~~
  libarchive/_libarchive_wrap.c:2876:5: note: remove the 'if' if its condition is always false
      if (PyType_Ready(tp) < 0)
      ^~~~~~~~~~~~~~~~~~~~~~~~~
  libarchive/_libarchive_wrap.c:2857:10: note: initialize the variable 'res' to silence this warning
    int res;
           ^
            = 0
  libarchive/_libarchive_wrap.c:5747:14: warning: explicitly assigning value of variable of type 'void *' to itself [-Wself-assign]
    clientdata = clientdata;
    ~~~~~~~~~~ ^ ~~~~~~~~~~
  4 warnings generated.
  libarchive/_libarchive_wrap.c:2351:23: warning: explicitly assigning value of variable of type 'int' to itself [-Wself-assign]
                    res = SWIG_AddCast(res);
                    ~~~ ^              ~~~
  libarchive/_libarchive_wrap.c:2354:23: warning: explicitly assigning value of variable of type 'int' to itself [-Wself-assign]
                    res = SWIG_AddCast(res);
                    ~~~ ^              ~~~
  libarchive/_libarchive_wrap.c:2876:9: warning: variable 'res' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
      if (PyType_Ready(tp) < 0)
          ^~~~~~~~~~~~~~~~~~~~
  libarchive/_libarchive_wrap.c:2900:10: note: uninitialized use occurs here
    return res;
           ^~~
  libarchive/_libarchive_wrap.c:2876:5: note: remove the 'if' if its condition is always false
      if (PyType_Ready(tp) < 0)
      ^~~~~~~~~~~~~~~~~~~~~~~~~
  libarchive/_libarchive_wrap.c:2857:10: note: initialize the variable 'res' to silence this warning
    int res;
           ^
            = 0
  libarchive/_libarchive_wrap.c:3357:15: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
      int len = PyString_Size(str);
          ~~~   ^~~~~~~~~~~~~~~~~~
  libarchive/_libarchive_wrap.c:5747:14: warning: explicitly assigning value of variable of type 'void *' to itself [-Wself-assign]
    clientdata = clientdata;
    ~~~~~~~~~~ ^ ~~~~~~~~~~
  5 warnings generated.
  cc -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -Wl,-F. build/temp.macosx-10.11-intel-2.7/libarchive/_libarchive_wrap.o -larchive -o build/lib.macosx-10.11-intel-2.7/libarchive/__libarchive.so -l:libarchive.so.13.1.2
  ld: library not found for -l:libarchive.so.13.1.2
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  error: command 'cc' failed with exit status 1

  ----------------------------------------
  Failed building wheel for python-libarchive
  Running setup.py clean for python-libarchive
Failed to build python-libarchive
Installing collected packages: python-libarchive
  Running setup.py install for python-libarchive ... error
    Complete output from command /Users/bsergeant/sandbox/venv/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/qz/cb1zd5756hnd2tykv7z5sn_j8408d8/T/pip-build-AP10r8/python-libarchive/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/qz/cb1zd5756hnd2tykv7z5sn_j8408d8/T/pip-xJ6Gy7-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/bsergeant/sandbox/venv/include/site/python2.7/python-libarchive:
    /Users/bsergeant/sandbox/venv/lib/python2.7/site-packages/setuptools/dist.py:331: UserWarning: Normalizing '3.1.2-1' to '3.1.2.post1'
      normalized_version,
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.11-intel-2.7
    creating build/lib.macosx-10.11-intel-2.7/libarchive
    copying libarchive/__init__.py -> build/lib.macosx-10.11-intel-2.7/libarchive
    copying libarchive/_libarchive.py -> build/lib.macosx-10.11-intel-2.7/libarchive
    copying libarchive/tar.py -> build/lib.macosx-10.11-intel-2.7/libarchive
    copying libarchive/zip.py -> build/lib.macosx-10.11-intel-2.7/libarchive
    running build_ext
    building 'libarchive.__libarchive' extension
    creating build/temp.macosx-10.11-intel-2.7
    creating build/temp.macosx-10.11-intel-2.7/libarchive
    cc -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe -Ilibarchive -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c libarchive/_libarchive_wrap.c -o build/temp.macosx-10.11-intel-2.7/libarchive/_libarchive_wrap.o
    libarchive/_libarchive_wrap.c:2351:23: warning: explicitly assigning value of variable of type 'int' to itself [-Wself-assign]
                      res = SWIG_AddCast(res);
                      ~~~ ^              ~~~
    libarchive/_libarchive_wrap.c:2354:23: warning: explicitly assigning value of variable of type 'int' to itself [-Wself-assign]
                      res = SWIG_AddCast(res);
                      ~~~ ^              ~~~
    libarchive/_libarchive_wrap.c:2876:9: warning: variable 'res' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
        if (PyType_Ready(tp) < 0)
            ^~~~~~~~~~~~~~~~~~~~
    libarchive/_libarchive_wrap.c:2900:10: note: uninitialized use occurs here
      return res;
             ^~~
    libarchive/_libarchive_wrap.c:2876:5: note: remove the 'if' if its condition is always false
        if (PyType_Ready(tp) < 0)
        ^~~~~~~~~~~~~~~~~~~~~~~~~
    libarchive/_libarchive_wrap.c:2857:10: note: initialize the variable 'res' to silence this warning
      int res;
             ^
              = 0
    libarchive/_libarchive_wrap.c:5747:14: warning: explicitly assigning value of variable of type 'void *' to itself [-Wself-assign]
      clientdata = clientdata;
      ~~~~~~~~~~ ^ ~~~~~~~~~~
    4 warnings generated.
    libarchive/_libarchive_wrap.c:2351:23: warning: explicitly assigning value of variable of type 'int' to itself [-Wself-assign]
                      res = SWIG_AddCast(res);
                      ~~~ ^              ~~~
    libarchive/_libarchive_wrap.c:2354:23: warning: explicitly assigning value of variable of type 'int' to itself [-Wself-assign]
                      res = SWIG_AddCast(res);
                      ~~~ ^              ~~~
    libarchive/_libarchive_wrap.c:2876:9: warning: variable 'res' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
        if (PyType_Ready(tp) < 0)
            ^~~~~~~~~~~~~~~~~~~~
    libarchive/_libarchive_wrap.c:2900:10: note: uninitialized use occurs here
      return res;
             ^~~
    libarchive/_libarchive_wrap.c:2876:5: note: remove the 'if' if its condition is always false
        if (PyType_Ready(tp) < 0)
        ^~~~~~~~~~~~~~~~~~~~~~~~~
    libarchive/_libarchive_wrap.c:2857:10: note: initialize the variable 'res' to silence this warning
      int res;
             ^
              = 0
    libarchive/_libarchive_wrap.c:3357:15: warning: implicit conversion loses integer precision: 'Py_ssize_t' (aka 'long') to 'int' [-Wshorten-64-to-32]
        int len = PyString_Size(str);
            ~~~   ^~~~~~~~~~~~~~~~~~
    libarchive/_libarchive_wrap.c:5747:14: warning: explicitly assigning value of variable of type 'void *' to itself [-Wself-assign]
      clientdata = clientdata;
      ~~~~~~~~~~ ^ ~~~~~~~~~~
    5 warnings generated.
    cc -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -Wl,-F. build/temp.macosx-10.11-intel-2.7/libarchive/_libarchive_wrap.o -larchive -o build/lib.macosx-10.11-intel-2.7/libarchive/__libarchive.so -l:libarchive.so.13.1.2
    ld: library not found for -l:libarchive.so.13.1.2
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    error: command 'cc' failed with exit status 1

    ----------------------------------------
Command "/Users/bsergeant/sandbox/venv/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/qz/cb1zd5756hnd2tykv7z5sn_j8408d8/T/pip-build-AP10r8/python-libarchive/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/qz/cb1zd5756hnd2tykv7z5sn_j8408d8/T/pip-xJ6Gy7-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/bsergeant/sandbox/venv/include/site/python2.7/python-libarchive" failed with error code 1 in /private/var/folders/qz/cb1zd5756hnd2tykv7z5sn_j8408d8/T/pip-build-AP10r8/python-libarchive/
jmgurney commented 2 years ago

I ran into the same issue. setting LIBARCHIVE_PREFIX works, but I added some autodetect code to make it work on MacOSX. The code is in this repo: https://www.funkthat.com/gitea/jmg/python-libarchive, specifically this commit: https://www.funkthat.com/gitea/jmg/python-libarchive/commit/6d4fbd86fcc14c50a7460e77bf589c7ada94d76c

This is tested on 12.4 Monterey.

bsergean commented 2 years ago

I actually can't remember at all why I needed that ... is it easy to make a pull request from your code change ? Or should we close this ticket and let your comment 'stand out' so people can use your workaround ?

jmgurney commented 2 years ago

As you can see, I created a PR for it.

The simple reason this is needed is that, at least for me, I have libarchive installed in /opt/local because of MacPorts, and the default configuration does not look there to link it.

bsergean commented 2 years ago

Ah I see. Great, thanks for making this library better, I hope your PR will be merged.

cabarnes commented 2 years ago

This is fixed in 4.2.1