From afad48b7dfd533ab658d617d959eaaad46e5b781 Mon Sep 17 00:00:00 2001 From: Daniel Alley Date: Fri, 14 Feb 2020 12:17:08 -0500 Subject: [PATCH] Automatically build and upload PyPI packages on release Using Github Actions --- .../workflows/python_build_and_publish.yml | 33 +++++++++++++++++++ pyproject.toml | 1 + src/python/CMakeLists.txt | 9 ++--- 3 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/python_build_and_publish.yml diff --git a/.github/workflows/python_build_and_publish.yml b/.github/workflows/python_build_and_publish.yml new file mode 100644 index 00000000..e037f4d3 --- /dev/null +++ b/.github/workflows/python_build_and_publish.yml @@ -0,0 +1,33 @@ +name: Python package build and publish + +on: [push] + # release: + # types: [published] + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: 3.8 + - name: Install dependencies + run: | + python3 -m pip install --upgrade pip + pip3 install scikit-build twine + - name: Build Python sdist + run: python3 setup.py sdist + - name: Build manylinux Python wheels + uses: RalfG/python-wheels-manylinux-build@v0.2.1-manylinux2014_x86_64 + with: + python-versions: 'cp36-cp36m cp37-cp37m cp38-cp38' + build-requirements: 'scikit-build' + system-packages: 'make cmake bzip2-devel expat-devel file-devel glib2-devel libcurl-devel libmodulemd2-devel libxml2-devel openssl-devel sqlite-devel zchunk-devel zlib-devel xz-devel rpm-devel' + - name: Publish wheels to PyPI + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + twine upload dist/*.tar.gz diff --git a/pyproject.toml b/pyproject.toml index f1307772..34ae493e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,2 +1,3 @@ [build-system] requires = ["setuptools", "wheel", "scikit-build"] +build-backend = "setuptools.build_meta" diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index 20376540..6d719daf 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -28,6 +28,7 @@ if (NOT SKBUILD) endif (NOT SKBUILD) EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c "from sys import stdout; from distutils import sysconfig; stdout.write(sysconfig.get_python_lib(True))" OUTPUT_VARIABLE PYTHON_INSTALL_DIR) +INCLUDE_DIRECTORIES (${PYTHON_INCLUDE_DIR}) INCLUDE_DIRECTORIES (${PYTHON_INCLUDE_PATH}) MESSAGE(STATUS "Python install dir is ${PYTHON_INSTALL_DIR}") @@ -71,14 +72,8 @@ TARGET_LINK_LIBRARIES(_createrepo_c ${CURL_LIBRARY} ) -IF (SKBUILD) - find_package(PythonExtensions REQUIRED) - python_extension_module(_createrepo_c) -ELSE () - TARGET_LINK_LIBRARIES(_createrepo_c ${PYTHON_LIBRARY}) -ENDIF () - IF (NOT SKBUILD) + TARGET_LINK_LIBRARIES(_createrepo_c ${PYTHON_LIBRARY}) FILE(COPY createrepo_c/__init__.py DESTINATION createrepo_c) ENDIF()