Skip to content

Commit

Permalink
Merge pull request #2463 from devitocodes/setupfix
Browse files Browse the repository at this point in the history
deps: fix deprecated pkg_resources
  • Loading branch information
mloubout committed Oct 7, 2024
2 parents 7e2694e + 72b50a3 commit e9f54d7
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 8 deletions.
92 changes: 89 additions & 3 deletions .github/workflows/docker-bases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,45 @@ jobs:
############## Basic gcc CPU ##########################
#######################################################
deploy-cpu-bases:
name: "cpu-base"
runs-on: ubuntu-latest
name: cpu-${{ matrix.platform }}
runs-on: ${{ matrix.os }}
env:
DOCKER_BUILDKIT: "1"
REGISTRY_IMAGE: "devitocodes/bases:cpu-gcc"

strategy:
fail-fast: false

matrix:
name: [gcc-arm, gcc-amd64]

include:
- name: gcc-arm
platform: linux/arm
os: macos-latest

- name: gcc-amd64
platform: linux/amd64
os: ubuntu-latest

steps:
- name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
- name: Checkout devito
uses: actions/checkout@v4

- name: Check event name
run: echo ${{ github.event_name }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

Expand All @@ -52,15 +79,74 @@ jobs:
run: docker system prune -a -f

- name: GCC image
uses: docker/build-push-action@v5
id: build
uses: docker/build-push-action@v6
with:
context: .
file: './docker/Dockerfile.cpu'
push: true
target: 'gcc'
build-args: 'arch=gcc'
platform: ${{ platform.platform }}
tags: 'devitocodes/bases:cpu-gcc'
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true

- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ env.PLATFORM_PAIR }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1

merge:
runs-on: ubuntu-latest
needs:
- deploy-cpu-bases

env:
DOCKER_BUILDKIT: "1"
REGISTRY_IMAGE: "devitocodes/bases:cpu-gcc"

steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
#######################################################
############## Intel OneApi CPU #######################
Expand Down
20 changes: 15 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
import versioneer

import os
import pkg_resources
try:
import importlib.metadata as metadata
get_version = lambda x: metadata.version(x)
PkgNotFound = metadata.PackageNotFoundError
parse_version = lambda x: metadata.version(x)
except ImportError:
import pkg_resources
get_version = lambda x: pkg_resources.get_distribution(x).version
PkgNotFound = pkg_resources.DistributionNotFound
parse_version = lambda x: pkg_resources.parse_version(x)

from setuptools import setup, find_packages


Expand All @@ -23,13 +33,13 @@ def numpy_compat(required):
# Check if sympy is installed and enforce numpy version accordingly.
# If sympy isn't installed, enforce sympy>=1.12.1 and numpy>=2.0
try:
sympy_version = pkg_resources.get_distribution("sympy").version
min_ver2 = pkg_resources.parse_version("1.12.1")
if pkg_resources.parse_version(sympy_version) < min_ver2:
sympy_version = get_version("sympy")
min_ver2 = parse_version("1.12.1")
if parse_version(sympy_version) < min_ver2:
new_reqs.extend([f"numpy>{numpy_lb},<2.0", f"sympy=={sympy_version}"])
else:
new_reqs.extend([f"numpy>=2.0,<{numpy_ub}", f"sympy=={sympy_version}"])
except pkg_resources.DistributionNotFound:
except PkgNotFound:
new_reqs.extend([f"sympy>=1.12.1,<{sympy_ub}", f"numpy>=2.0,<{numpy_ub}"])

return new_reqs
Expand Down

0 comments on commit e9f54d7

Please sign in to comment.