smartfile / python-libarchive

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

Publish wheels to PyPI #21

Closed mxmlnkn closed 2 years ago

mxmlnkn commented 2 years ago

Currently, installing this package with pip might fail with this error (excerpt from CI):

gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/usr/local/include -Ilibarchive -I/opt/hostedtoolcache/Python/3.6.15/x64/include/python3.6m -c libarchive/_libarchive_wrap.c -o build/temp.linux-x86_64-3.6/libarchive/_libarchive_wrap.o
libarchive/_libarchive_wrap.c:2712:10: fatal error: archive.h: No such file or directory
 2712 | #include <archive.h>
      |          ^~~~~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1

Installing libarchive-dev on Ubuntu fixes this but it is an additional step the user has to be made aware of.

To ease installation issues like this one, providing wheels would be very much appreciated. Even better if it bundles libarchive, which thanks to its permissive license should be possible to do. It seems like @Vadiml1024 already tried to set up a CI for this. Personally, I'm using a pyproject.toml and the build package to build the tarball and cibuildwheel to build the wheels for my C++ indexed_bzip2/pragzip.

mxmlnkn commented 2 years ago

Unrelated low-impact issue: Archive.denit should probably be renamed Archive.deinit or maybe something more normal like close. I was confused why I couldn't find it with Ctrl+F. Note that changing it would be an API break, so maybe just add an alternative or increment to the version 5.m.p.

cabarnes commented 2 years ago

@mxmlnkn I just added a deploy action to the repository. I don't know when I'll have a chance to work on adding wheels to the PyPI deployment. If you would like to create a PR that adds that support, I would be willing to consider it. I know that @Vadiml1024 was doing something similar, but I didn't want that much change all at once. As you know, I missed a couple things as it was.

mxmlnkn commented 2 years ago

@cabarnes Understood. I should have some time the coming weeks, I might get around to do this. The missing wheels and some (thread-)safe file objects to the contained files (related to #23) are the two blockers for me right now. Thank you for keeping this project alive.

Vadiml1024 commented 2 years ago

I can easily produce a PR with with my github workflow which produces a wheel containing dependent shared libs. however it produces only linux targeted wheel.

Vadiml1024 commented 2 years ago

@mxmlnkn I just added a deploy action to the repository. I don't know when I'll have a chance to work on adding wheels to the PyPI deployment. If you would like to create a PR that adds that support, I would be willing to consider it. I know that @Vadiml1024 was doing something similar, but I didn't want that much change all at once. As you know, I missed a couple things as it was.

Just created PR (https://github.com/smartfile/python-libarchive/pull/27) with workflow to build wheel embedding libs

cabarnes commented 2 years ago

@mxmlnkn @Vadiml1024 The PR has been merged and version 4.2.0b1 has been deployed. Can you both test that the wheels are working proplery?

mxmlnkn commented 2 years ago

It installs correctly for me locally as well as on my CI.

Note that, because it is a pre-relase, installation works only when explicitly requesting the version with python-libarchive==4.2.0b1.

python3 -c 'import libarchive; print(libarchive.version())' prints 3.6.1 even though I only have libarchive 3.6.0 installed on my system, so, I presume that statically linking against libarchive while creating the wheel also works.

I'm positively surprised that it also has Python 3.6 wheels. That way I can keep my Python 3.6 CI for a bit longer.

Vadiml1024 commented 2 years ago

Well, it is not really statically linked. It's actually the wheel includes shared libs.

mxmlnkn commented 2 years ago

Well, it is not really statically linked. It's actually the wheel includes shared libs.

Ah ok, you are right. I can see all the shared libraries in my local site-packages folder. Interesting to know.

cabarnes commented 2 years ago

I'm positively surprised that it also has Python 3.6 wheels.

Yes, it seems that it built everything, which I think is good.

Everything works for me on Ubuntu 20.04. I will do the final release of 4.2.0 today. Thanks for your help @mxmlnkn and @Vadiml1024 !

cabarnes commented 2 years ago

4.2.0 has been released