tensorchord / envd

🏕️ Reproducible development environment
https://envd.tensorchord.ai/
Apache License 2.0
1.96k stars 156 forks source link

feat(pypi): Release pypi package for macos #294

Closed VoVAllen closed 2 years ago

VoVAllen commented 2 years ago

Description

Release pypi package for macos

gaocegege commented 2 years ago

I can help with this.

gaocegege commented 2 years ago

https://github.com/mosecorg/mosec/blob/main/.github/workflows/package.yml#L57

I dived into the mosec CI. it builds wheels on ubuntu and macOS.

I am wondering if it is possible to build multi-platform wheels on Linux. /cc @kemingy

kemingy commented 2 years ago

https://github.com/mosecorg/mosec/blob/main/.github/workflows/package.yml#L57

I dived into the mosec CI. it builds wheels on ubuntu and macOS.

I am wondering if it is possible to build multi-platform wheels on Linux. /cc @kemingy

It's possible. The reason why I have to use two OS is that hyper requires GCC.

gaocegege commented 2 years ago

Gotcha, thanks.

VoVAllen commented 2 years ago

pypi has an official project to build package across platform https://github.com/pypa/cibuildwheel

gaocegege commented 2 years ago

pypi has an official project to build packages across platforms https://github.com/pypa/cibuildwheel

I think it builds on different platforms according to the sample it provides.

name: Build

on: [push, pull_request]

jobs:
  build_wheels:
    name: Build wheels on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-20.04, windows-2019, macOS-10.15]

    steps:
      - uses: actions/checkout@v2

      # Used to host cibuildwheel
      - uses: actions/setup-python@v2

      - name: Install cibuildwheel
        run: python -m pip install cibuildwheel==2.6.1

      - name: Build wheels
        run: python -m cibuildwheel --output-dir wheelhouse
        # to supply options, put them in 'env', like:
        # env:
        #   CIBW_SOME_OPTION: value

      - uses: actions/upload-artifact@v2
        with:
          path: ./wheelhouse/*.whl
gaocegege commented 2 years ago

I think the cibuildwheel can replace logic in our release.yaml:

-    - name: Build wheel
-      run: |      
-          python -m pip install --upgrade pip
-          python -m pip install twine wheel auditwheel setuptools_scm
-          python setup.py bdist_wheel
-          auditwheel repair dist/*.whl
-          pushd wheelhouse
-          for file in *.whl ; do mv $file ${file//"cp39-cp39"/"py2.py3-none"} ; done
-          popd
+      - name: Install cibuildwheel
+        run: python -m pip install cibuildwheel==2.6.1
+
+      - name: Build wheels
+        run: python -m cibuildwheel --output-dir wheelhouse
+        # to supply options, put them in 'env', like:
+        # env:
+        #   CIBW_SOME_OPTION: value
VoVAllen commented 2 years ago

The core tricky part is that our python tag and abi tag are manually configured, but not automatically generated. Need to include this for file in *.whl ; do mv $file ${file//"cp39-cp39"/"py2.py3-none"}.

gaocegege commented 2 years ago

Python 2.7 fails to build the wheel.

      Traceback (most recent call last):
        File "<string>", line 1, in <module>
        File "/private/var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/pip-req-build-c2p5N5/setup.py", line 38
          def build_extension(self, ext: Extension) -> None:
                                       ^
      SyntaxError: invalid syntax
      ----------------------------------------

Let's use cibuildwheel2.x to skip python 2.x for now.

gaocegege commented 2 years ago

https://pypi.org/project/envd/#files

It should work.