diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 13371e7c..446eb151 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -1,7 +1,18 @@ # Workflow to build and test wheels. name: Wheel builder -on: [push, pull_request] +on: + workflow_dispatch: + pull_request: + push: + branches: + - main + tags: + - v** + release: + types: + - published + concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} @@ -10,9 +21,62 @@ concurrency: permissions: contents: read # to fetch code (actions/checkout) +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }}-manylinux2014 + FALLBACK_TAG: ghcr.io/${{ github.repository }}-manylinux2014:main + jobs: + build-custom-manylinux: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + outputs: + tag: ${{ steps.meta.outputs.labels || env.FALLBACK_TAG }} + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Get changed Dockerfile + id: changed-files-specific + uses: tj-actions/changed-files@de0eba32790fb9bf87471b32855a30fc8f9d5fc6 #v37.4.0 + with: + files: | + Dockerfile-manylinux + + - name: Log in to the Container registry + uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc #v2.2.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + if: steps.changed-files-specific.outputs.any_changed == 'true' + id: meta + uses: docker/metadata-action@818d4b7b91585d195f67373fd9cb0332e31a7175 #v4.6.0 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + if: steps.changed-files-specific.outputs.any_changed == 'true' + uses: docker/build-push-action@2eb1c1961a95fc15694676618e422e8ba1d63825 #v4.1.1 + with: + context: . + file: ./Dockerfile-manylinux + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build_wheels: name: Build wheel for ${{ matrix.python }}-${{ matrix.buildplat[1] }} + needs: build-custom-manylinux + permissions: + packages: read runs-on: ${{ matrix.buildplat[0] }} strategy: # Ensure that a wheel builder finishes even if another fails @@ -51,10 +115,17 @@ jobs: python-version: "3.x" - name: ccache - uses: hendrikmuhs/ccache-action@v1.2 + uses: hendrikmuhs/ccache-action@ca3acd2731eef11f1572ccb126356c2f9298d35e #v1.2.9 with: key: ${{ matrix.python }}-${{ matrix.buildplat[1] }} + - name: Log in to the Container registry + uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc #v2.2.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build wheels uses: pypa/cibuildwheel@66b46d086804a9e9782354100d96a3a445431bca # v2.14.0 env: @@ -62,12 +133,82 @@ jobs: CIBW_BUILD: ${{ matrix.python }}-${{ matrix.buildplat[1] }} CIBW_ENVIRONMENT: USE_CCACHE=1 CCACHE_DIR=/.ccache CIBW_CONTAINER_ENGINE: "docker; create_args: '--volume=${{ github.workspace }}/.ccache:/.ccache'" + # overriede before-all in pyproject.toml + CIBW_BEFORE_ALL: "" + CIBW_MANYLINUX_X86_64_IMAGE: ${{ needs.build-custom-manylinux.outputs.tag }} - uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2 with: name: ${{ matrix.python }}-${{ startsWith(matrix.buildplat[1], 'macosx') && 'macosx' || matrix.buildplat[1] }} path: ./wheelhouse/*.whl -# + + test_upload_pypi: + # TODO: create an sdist that can build without a custom environment + needs: [build_wheels] + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + strategy: + matrix: + buildplat: + - [ubuntu-20.04, manylinux_x86_64] + #- [ubuntu-20.04, musllinux_x86_64] + #- [macos-12, macosx_x86_64] + #- [windows-2019, win_amd64] + python: ["cp39", "cp310", "cp311", "cp312"] # "pp39" + exclude: + # Don't build PyPy 32-bit windows + - buildplat: [windows-2019, win32] + python: "pp39" + - buildplat: [ ubuntu-20.04, musllinux_x86_64 ] + python: "pp39" + + environment: pypi + permissions: + id-token: write + steps: + - uses: actions/download-artifact@v3 + with: + name: ${{ matrix.python }}-${{ startsWith(matrix.buildplat[1], 'macosx') && 'macosx' || matrix.buildplat[1] }} + path: dist + + - uses: pypa/gh-action-pypi-publish@f8c70e705ffc13c3b4d1221169b84f12a75d6ca8 #v1.8.8 + with: + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository_url: https://test.pypi.org/legacy/ + + upload_pypi: + # TODO: create an sdist that can build without a custom environment + if: github.event_name == 'release' + needs: [build_wheels] + runs-on: ubuntu-latest + strategy: + matrix: + buildplat: + - [ubuntu-20.04, manylinux_x86_64] + #- [ubuntu-20.04, musllinux_x86_64] + #- [macos-12, macosx_x86_64] + #- [windows-2019, win_amd64] + python: ["cp39", "cp310", "cp311", "cp312"] # "pp39" + exclude: + # Don't build PyPy 32-bit windows + - buildplat: [windows-2019, win32] + python: "pp39" + - buildplat: [ ubuntu-20.04, musllinux_x86_64 ] + python: "pp39" + + environment: pypi + permissions: + id-token: write + steps: + - uses: actions/download-artifact@v3 + with: + name: ${{ matrix.python }}-${{ startsWith(matrix.buildplat[1], 'macosx') && 'macosx' || matrix.buildplat[1] }} + path: dist + + - uses: pypa/gh-action-pypi-publish@release/v1 + with: + password: ${{ secrets.PYPI_API_TOKEN }} + # build_sdist: # name: Build sdist # runs-on: ubuntu-latest diff --git a/Dockerfile-manylinux b/Dockerfile-manylinux new file mode 100644 index 00000000..a702b8b8 --- /dev/null +++ b/Dockerfile-manylinux @@ -0,0 +1,20 @@ +FROM quay.io/pypa/manylinux2014_x86_64:2023-07-14-55e4124 + +RUN yum -y install epel-release && \ + yum repolist + +RUN yum install -y \ + qt5-qtbase-devel qt5-qtsvg-devel \ + rapidjson-devel bison flex doxygen bzip2-devel flex-devel \ + boost-devel \ + boost-python boost-filesystem \ + boost-regex boost-wave \ + python36-devel libxml2-devel \ + qwt-devel \ + ccache \ + eigen3-devel \ + wget + +RUN wget http://lemon.cs.elte.hu/pub/sources/lemon-1.3.1.tar.gz; +RUN tar -xzf lemon-1.3.1.tar.gz; cd lemon-1.3.1; mkdir build; cd build; cmake ..; make install; cd ../.. + diff --git a/builder.py b/builder.py index 07f564b0..d9f78182 100644 --- a/builder.py +++ b/builder.py @@ -73,7 +73,7 @@ class ExtensionBuilder(build_ext): env["CXXFLAGS"] = '{} -DVERSION_INFO=\\"{}\\"'.format(env.get("CXXFLAGS", ""), self.distribution.get_version()) build_dir = os.path.join(self.build_temp, ext.sourcedir_rel) - install_dir = os.path.join(extdir, 'Coriolis') + install_dir = os.path.join(extdir, 'coriolis') os.makedirs(build_dir,exist_ok=True) if "USE_CCACHE" in env: @@ -122,6 +122,7 @@ class ExtensionBuilder(build_ext): def build(setup_kwargs: Dict[str, Any]) -> None: cmake_modules = [ CMakeExtension("coloquinte", sourcedir="coloquinte"), + CMakeExtension("lefdef", sourcedir="lefdef"), CMakeExtension("Hurricane", sourcedir="hurricane"), CMakeExtension("crlcore", sourcedir="crlcore"), CMakeExtension("flute", sourcedir="flute"), @@ -134,7 +135,7 @@ def build(setup_kwargs: Dict[str, Any]) -> None: CMakeExtension("bora", sourcedir="bora"), CMakeExtension("karakaze", sourcedir="karakaze"), #CMakeExtension("knik", sourcedir="knik"), - #CMakeExtension("unicorn", sourcedir="unicorn"), + CMakeExtension("unicorn", sourcedir="unicorn"), CMakeExtension("tutorial", sourcedir="tutorial"), CMakeExtension("cumulus", sourcedir="cumulus"), CMakeExtension("stratus1", sourcedir="stratus1"), diff --git a/Coriolis/__init__.py b/coriolis/__init__.py similarity index 100% rename from Coriolis/__init__.py rename to coriolis/__init__.py diff --git a/pyproject.toml b/pyproject.toml index d8159ea1..0c4612fa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.poetry] -name = "Coriolis" +name = "coriolis-eda" version = "0.0.0" description = "Place and Route for semiconductors" authors = ["Jean-Paul Chaput "] @@ -7,7 +7,7 @@ readme = "README.rst" homepage = "https://github.com/lip6/coriolis" repository = "https://github.com/lip6/coriolis" packages = [ - { include = "Coriolis"}, + { include = "coriolis"}, ] include = [ "COPYRIGHT.rst", @@ -45,7 +45,14 @@ include = [ [tool.poetry-dynamic-versioning] enable = true vcs = "git" -style = "semver" +style = "pep440" +format-jinja = """ + {%- if distance == 0 -%} + {{ serialize_pep440(base, stage, revision) }} + {%- else -%} + {{ serialize_pep440(bump_version(base), stage="a", revision=distance) }} + {%- endif -%} +""" [tool.poetry.dependencies] python = "^3.8" @@ -63,10 +70,10 @@ script = "builder.py" generate-setup-file = true [tool.poetry.scripts] -blif2vst = 'Coriolis:blif2vst' -tutorial = 'Coriolis:tutorial' -unittests = 'Coriolis:unittests' -yosys_coriolis = 'Coriolis:yosys_coriolis' +blif2vst = 'coriolis:blif2vst' +tutorial = 'coriolis:tutorial' +unittests = 'coriolis:unittests' +yosys_coriolis = 'coriolis:yosys_coriolis' [build-system] requires = ["poetry-core", "setuptools", "cmake", "ninja", "patchelf", "poetry-dynamic-versioning"]