Package: c2f
Is Python an interpreted or compiled language? Trick question. It’s actually
both. With tools like Cython, we can take the compilation step further and
remove the interpreter loop almost entirely. Cython produces binaries much like
C++, Go, and Rust do. Now with GitHub Actions the cross-platform build and
release process can be automated for free for Open Source projects. This is an
enormous opportunity to make the Python ecosystem 20-50% faster with a single
pull request. This lightning talk walks through a GitHub workflow that
publishes Cython-optimized wheels to PyPI. Discover how Cython can turbo-charge
your Python code and GitHub Actions can simplify your cross-platform release
process for free.SF Python Holiday Party 2019Grant JenksDec. 4, 2019grantjenks.com/docs/cython-for-allgithub.com/grantjenks/python-c2fpypi.org/project/c2f/#filesIs Python interpreted or compiled?...?...?...?c2f.py"Celsius to Fahrenheit Library"defconvert(celsius:float)->float:"Convert Celsius to Fahrenheit"fahrenheit=celsius*1.8+32returnfahrenheitc2f.cpython-38.pyc>>>importc2f>>>dis.dis(c2f.convert)6           0 LOAD_FAST                0 (celsius)
              2 LOAD_CONST               1 (1.8)
              4 BINARY_MULTIPLY
              6 LOAD_CONST               2 (32)
              8 BINARY_ADD
             10 STORE_FAST               1 (fahrenheit)
  7          12 LOAD_FAST                1 (fahrenheit)
             14 RETURN_VALUEsetup.pyfromsetuptoolsimportsetupfromCython.Buildimportcythonizesetup(name='c2f',version='0.0.0',py_modules=['c2f'],ext_modules=cythonize('c2f.py'),)c2f.c$cythonc2f.pystaticPyObject*__pyx_convert(double__pyx_v_celsius){double__pyx_v_fahrenheit;PyObject*__pyx_r=NULL;__pyx_v_fahrenheit=((__pyx_v_celsius*1.8)+32.0);__pyx_r=PyFloat_FromDouble(__pyx_v_fahrenheit);return__pyx_r;}c2f.so$pythonsetup.pybdist_wheel___pyx_convert:pushrbpmovrbp,rspsubrsp,16movsdxmm0,qwordptr[rbp-8]mulsdxmm0,qwordptr[rip+1379]addsdxmm0,qwordptr[rip+1379]call502<PyFloat_FromDouble...>addrsp,16poprbpret.github/workflows/release.ymlname:releaseon:push:tags:-v*jobs:build-linux-cp38:runs-on:ubuntu-latestcontainer:quay.io/pypa/manylinux2014_x86_64steps:...Matrix Buildbuild-macos:runs-on:macos-lateststrategy:max-parallel:4matrix:python-version:[3.5,3.6,3.7,3.8]steps:...Mac Build Steps-name:Set up Python ${{ matrix.python-version }} x64uses:actions/setup-python@v1with:python-version:${{ matrix.python-version }}architecture:x64-name:Install package dependenciesrun:pip install cython wheel-name:Build binary wheelrun:python setup.py bdist_wheelLinux auditwheel Tool-name:Build binary wheelrun:/opt/python/cp38-cp38/bin/python setup.py bdist_wheel-name:Apply auditwheel for manylinux wheelrun:auditwheel repair -w dist dist/*-name:Remove linux wheelrun:rm dist/*-linux_x86_64.whlWindows Build Steps-name:Download Build Tools for Visual Studio 2019run:Invoke-WebRequest -Uri https://aka.ms/vs/16/rel...-name:Run vs_buildtools.exe installrun:./vs_buildtools.exe --quiet --wait --norestart ...Store Build Artifacts-name:Archive dist artifactsuses:actions/upload-artifact@v1with:name:dist-macos-${{ matrix.python-version }}path:distSource Distributionupload:needs:[build-linux-cp35,...]runs-on:ubuntu-lateststeps:...-name:Install dependenciesrun:pip install -r requirements.txt-name:Create source distrun:python setup.py sdistStage Binary Wheels-name:Stage linux 3.8uses:actions/download-artifact@v1with:name:dist-linux-3.8-run:mv -v dist-linux-3.8/* dist/-name:Stage macos 3.8uses:actions/download-artifact@v1with:name:dist-macos-3.8-run:mv -v dist-macos-3.8/* dist/...Upload with Twine-name:Upload with twineenv:TWINE_USERNAME:${{ secrets.TWINE_USERNAME }}TWINE_PASSWORD:${{ secrets.TWINE_PASSWORD }}run:|ls -l dist/*pip install twinetwine upload dist/*Cythonize all the Things!PLEASE STEAL THE CODE!grantjenks.com/docs/cython-for-allgithub.com/grantjenks/python-c2fpypi.org/project/c2f/#filesCythonize all the Things!Cythonize all the Things!Cythonize all the Things!Cythonize all the Things!Cythonize all the Things!Cythonize all the Things!AppendixDumping Assembly$gcc-g-shared-pthread-fPIC-fwrapv-O2-Wall-fno-strict-aliasing-I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8-L/Library/Frameworks/Python.framework/Versions/3.8/lib-oc2f.soc2f.c-lpython3.8$objdump-S-df=___pyx_pw_3c2f_1convertc2f.soGit Tagging$gittag-av0.0.2-mv0.0.2$gitpush$gitpush--tags