drufat / triangle

Python bindings to the triangle library
GNU Lesser General Public License v3.0
236 stars 54 forks source link

Build Wheels In Github Actions #51

Closed mikedh closed 4 years ago

mikedh commented 4 years ago

Hey, thanks for all the great work on the triangle binding! I love the minimal nature and reliability, which is probably why a bunch of upstream packages have started depending on triangle too. To hopefully help, this PR uses cibuildwheel and Github Actions to build compiled wheels for Windows, Linux, and MacOS for a bunch flavors of Python:

triangle-20200404-cp27-cp27m-macosx_10_9_x86_64.whl
triangle-20200404-cp27-cp27m-manylinux1_i686.whl
triangle-20200404-cp27-cp27m-manylinux1_x86_64.whl
triangle-20200404-cp27-cp27m-manylinux2010_i686.whl
triangle-20200404-cp27-cp27m-manylinux2010_x86_64.whl
triangle-20200404-cp27-cp27m-win32.whl
triangle-20200404-cp27-cp27m-win_amd64.whl
triangle-20200404-cp27-cp27mu-manylinux1_i686.whl
triangle-20200404-cp27-cp27mu-manylinux1_x86_64.whl
triangle-20200404-cp27-cp27mu-manylinux2010_i686.whl
triangle-20200404-cp27-cp27mu-manylinux2010_x86_64.whl
triangle-20200404-cp35-cp35m-macosx_10_9_x86_64.whl
triangle-20200404-cp35-cp35m-manylinux1_i686.whl
triangle-20200404-cp35-cp35m-manylinux1_x86_64.whl
triangle-20200404-cp35-cp35m-manylinux2010_i686.whl
triangle-20200404-cp35-cp35m-manylinux2010_x86_64.whl
triangle-20200404-cp35-cp35m-win32.whl
triangle-20200404-cp35-cp35m-win_amd64.whl
triangle-20200404-cp36-cp36m-macosx_10_9_x86_64.whl
triangle-20200404-cp36-cp36m-manylinux1_i686.whl
triangle-20200404-cp36-cp36m-manylinux1_x86_64.whl
triangle-20200404-cp36-cp36m-manylinux2010_i686.whl
triangle-20200404-cp36-cp36m-manylinux2010_x86_64.whl
triangle-20200404-cp36-cp36m-win32.whl
triangle-20200404-cp36-cp36m-win_amd64.whl
triangle-20200404-cp37-cp37m-macosx_10_9_x86_64.whl
triangle-20200404-cp37-cp37m-manylinux1_i686.whl
triangle-20200404-cp37-cp37m-manylinux1_x86_64.whl
triangle-20200404-cp37-cp37m-manylinux2010_i686.whl
triangle-20200404-cp37-cp37m-manylinux2010_x86_64.whl
triangle-20200404-cp37-cp37m-win32.whl
triangle-20200404-cp37-cp37m-win_amd64.whl
triangle-20200404-cp38-cp38-macosx_10_9_x86_64.whl
triangle-20200404-cp38-cp38-manylinux1_i686.whl
triangle-20200404-cp38-cp38-manylinux1_x86_64.whl
triangle-20200404-cp38-cp38-manylinux2010_i686.whl
triangle-20200404-cp38-cp38-manylinux2010_x86_64.whl
triangle-20200404-cp38-cp38-win32.whl
triangle-20200404-cp38-cp38-win_amd64.whl

A few thoughts:

drufat commented 4 years ago

Thanks for your contribution. I would be happy to merge this. I just have questions about Github secrets. 1) Does this mean I have to share my PyPI password with Github? 2) Are builds uploaded after every commit, or only after a release?

mikedh commented 4 years ago

No problem!

Does this mean I have to share my PyPI password with Github?

Yeah to release wheels automatically to PyPi you'd have to add your password on Github. Here are Github's docs on the interface and security they use for secrets. You could also skip this and manually download the wheels.zip artifact from the build, and run the twine upload command from your local machine.

Are builds uploaded after every commit, or only after a release?

Good question, right now it's running the whole matrix on every push or pull request. You may want to change this to be just on master, or on tags: Github actions filtering for branches and tags

drufat commented 4 years ago

I just released a new version using your build system. Can you test that it works?

mikedh commented 4 years ago

Awesome! It should be running self-tests so wheel builds should fail if there are issues. I confirmed pip is installing it nicely using the wheel in both Windows and Linux, and triangulate is functioning:

Windows:

(base) C:\Users\mik3d>pip install triangle
Collecting triangle
  Downloading triangle-20200424-cp37-cp37m-win_amd64.whl (1.4 MB)
     |████████████████████████████████| 1.4 MB 2.2 MB/s
Requirement already satisfied: numpy in c:\users\mik3d\anaconda3\lib\site-packages (from triangle) (1.18.1)
Installing collected packages: triangle
Successfully installed triangle-20200424

(base) C:\Users\mik3d>ipython -i
Python 3.7.6 (default, Jan  8 2020, 20:23:39) [MSC v.1916 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.12.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from triangle import triangulate

In [2]: v = [[0,0], [1,0], [1,1], [1,0]]

In [3]: triangulate({"vertices": v}, "a0.2")
Out[3]:
{'vertices': array([[0.        , 0.        ],
        [1.        , 0.        ],
        [1.        , 1.        ],
        [1.        , 0.        ],
        [0.64644661, 0.64644661],
        [0.5       , 0.14644661]]),
 'vertex_markers': array([[1],
        [1],
        [1],
        [0],
        [1],
        [0]], dtype=int32),
 'triangles': array([[0, 5, 4],
        [1, 4, 5],
        [0, 1, 5],
        [1, 2, 4]], dtype=int32)}```

Linux:


mikedh@orbital:~$ pip install --upgrade triangle
Collecting triangle
  Downloading https://files.pythonhosted.org/packages/41/05/e05880ba496a73428b78372562dbf0287fc562244b9253fa96df15b12e0c/triangle-20200424-cp36-cp36m-manylinux2010_x86_64.whl (1.9MB)
     |████████████████████████████████| 1.9MB 2.2MB/s 
Requirement already satisfied, skipping upgrade: numpy in /home/mikedh/miniconda/lib/python3.6/site-packages (from triangle) (1.16.4)
Installing collected packages: triangle
  Found existing installation: triangle 20170429
    Uninstalling triangle-20170429:
      Successfully uninstalled triangle-20170429
Successfully installed triangle-20200424
WARNING: You are using pip version 19.3.1; however, version 20.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

mikedh@orbital:~$ cd trimesh/tests
mikedh@orbital:tests$ python test_extrude.py 
DEBUG        primitives.py:799   creating mesh for Extrusion primitive
...

----------------------------------------------------------------------
Ran 1 test in 3.102s

OK```
Helveg commented 3 years ago

@mikedh you're the caped hero the Python packaging community needs ;) Keep it up