Pebaz / nimporter

Compile Nim Extensions for Python On Import!
MIT License
824 stars 33 forks source link

Release GH Action works on Mac but not Linux/Windows #38

Closed Benjamin-Lee closed 3 years ago

Benjamin-Lee commented 3 years ago

I'm a bit stumped as to what's going wrong since Windows and Linux give different errors. On Mac, it seems to be working.

Here's the GH action. The parts that I modified are the installation steps in which I first install my package and then the dependencies for the CLI package.

The errors I'm getting can be seen here for Linux and here for Windows. Briefly, on Linux, I'm getting this:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
IndexError: list index out of range

On Windows, I'm not able to use the python3 function:

python3: D:\a\_temp\ea2d772e-0efd-40be-942c-5d46b8d41f17.ps1:8
Line |
   8 |  python3 setup.py bdist_wheel
     |  ~~~~~~~
     | The term 'python3' is not recognized as the name of a cmdlet, function, script file, or operable
     | program. Check the spelling of the name, or if a path was included, verify that the path is correct
     | and try again.

Do you have any suggestions? I'm so happy that librtd is finally close to release!

Pebaz commented 3 years ago

@Benjamin-Lee thanks for reaching out!

Couple things:

Let me know how it goes! :)

Benjamin-Lee commented 3 years ago

Thanks for the advice @Pebaz. Your Windows suggestion worked perfectly but Linux was a tough nut to crack. I ended up spending the day working on packaging and found a way to compile true manylinux wheels for all modern Python version. To do so, I had to run the build in a Docker container provided by PyPA:

jobs:
  build-linux:
    runs-on: ubuntu-latest
    container:
      image: quay.io/pypa/manylinux2014_x86_64
    steps:
      - uses: actions/checkout@v2
      - run: |
          curl -O https://nim-lang.org/choosenim/init.sh
          sh init.sh -y
      - name: Build and publish
        env:
          TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
          TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
        run: |
          export PATH=/github/home/.nimble/bin:$PATH
          cd $GITHUB_WORKSPACE
          choosenim 1.4.0
          nim -v
          cd librtd
          nimble install -Y
          cd ../librtd-py/librtdpy
          nimble install -Y
          cd ../
          for PYBIN in /opt/python/*/bin/; do 
            if ! test $PYBIN -ef /opt/python/cp35-cp35m/bin/; then
              "${PYBIN}/pip" install setuptools wheel twine nimporter>=1.0.2
              "${PYBIN}/pip" wheel . --no-deps -w wheelhouse/
            fi
          done
          mkdir repaired
          for whl in wheelhouse/*.whl; do
              auditwheel repair "$whl" -w repaired
          done
          /opt/python/cp39-cp39/bin/twine upload repaired/*

Similarly, I added Python 3.5-3.9 builds for Windows and Mac. The full build script is here. Feel free to take anything from it for the example build script.

Pebaz commented 3 years ago

Fantastic! Glad to hear it 👏 Thank you for sharing this!

Pebaz commented 3 years ago

Closing due to issue being resolved! 😁