Skip to content

Commit

Permalink
Set python 3.8 as min. Remove manylinux container build. (#256)
Browse files Browse the repository at this point in the history
* Set python 3.8 as min Python version. Remove manylinux container
  • Loading branch information
idavis authored Oct 19, 2023
1 parent 0cc4e9a commit aba3036
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 173 deletions.
5 changes: 2 additions & 3 deletions .github/actions/install-llvm/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ runs:
shell: pwsh
if: ${{ (inputs.os == 'ubuntu-20.04') && (steps.cache-llvm.outputs.cache-hit != 'true') }}
- name: Windows - Install build dependencies, ninja
run: |
run: |
choco install --accept-license -y ninja
choco uninstall -y llvm
shell: pwsh
Expand All @@ -55,7 +55,6 @@ runs:

- name: Install LLVM
run: |
$target_prefix = if("${{ inputs.target }}" -eq "manylinux") {"manylinux-"} else {""}
./build.ps1 -t "$($target_prefix)install-llvm-from-source"
./build.ps1 -t install-llvm-from-source
shell: pwsh
if: ${{ steps.cache-llvm.outputs.cache-hit != 'true' }}
13 changes: 6 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ jobs:
target: "checks",
env: {},
}
- {
os: "ubuntu-20.04",
arch: "amd64",
target: "manylinux",
env: {},
}
- {
os: "ubuntu-20.04",
arch: "amd64",
Expand All @@ -60,6 +54,11 @@ jobs:
with:
toolchain: 1.64.0
components: rustfmt clippy
- uses: actions/checkout@v4
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
python-version: 3.8
- name: Install LLVM
uses: ./.github/actions/install-llvm
with:
Expand All @@ -83,7 +82,7 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: manylinux-artifacts
path: target/wheels/*manylinux_2_17*.whl
path: target/wheels/*manylinux_2_*.whl
if: ${{ matrix.config.os == 'ubuntu-20.04' }}
- name: Artifacts
uses: actions/upload-artifact@v2
Expand Down
9 changes: 2 additions & 7 deletions .github/workflows/llvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
matrix:
config:
- {
os: "ubuntu-22.04",
os: "ubuntu-20.04",
arch: "amd64",
env: {},
}
Expand All @@ -39,7 +39,7 @@ jobs:
submodules: 'recursive'
- name: Linux - Install build dependencies, ccache, ninja
run: sudo apt-get install -y ccache ninja-build
if: ${{ matrix.config.os == 'ubuntu-22.04' }}
if: ${{ matrix.config.os == 'ubuntu-20.04' }}
- name: Windows - Install build dependencies, sccache, ninja
run: choco install --accept-license -y sccache ninja
if: ${{ matrix.config.os == 'windows-2019' }}
Expand All @@ -52,11 +52,6 @@ jobs:
- name: "Build and Package LLVM"
run: ./build.ps1 -t package-llvm
shell: pwsh
if: ${{ matrix.config.os != 'ubuntu-22.04' }}
- name: "Build and Package LLVM for manylinux"
run: ./build.ps1 -t package-manylinux-llvm
shell: pwsh
if: ${{ matrix.config.os == 'ubuntu-22.04' }}
- name: Artifacts
uses: actions/upload-artifact@v3
with:
Expand Down
3 changes: 0 additions & 3 deletions docs/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,3 @@ be linked into the rest of the build.
The `build.ps1`, `maturin` builds all generate Python wheels to the
`target/wheels` folder. The default Python3 installation will be used targeting
Python ABI 3.7.

The manylinux support uses a Docker image in the build scripts to run the builds
in the CI environment.
11 changes: 5 additions & 6 deletions eng/Dockerfile.examples
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@

ARG RELEASE=jammy

FROM buildpack-deps:buster-scm AS buster
FROM buildpack-deps:bullseye-scm AS bullseye

RUN wget https://packages.microsoft.com/config/debian/10/packages-microsoft-prod.deb \
&& dpkg -i packages-microsoft-prod.deb \
&& rm packages-microsoft-prod.deb \
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
&& echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-bullseye-prod bullseye main" > /etc/apt/sources.list.d/microsoft.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends powershell python3-minimal python3-pip python3-setuptools sudo \
&& rm -rf /var/lib/apt/lists/*

FROM buildpack-deps:bullseye-scm AS bullseye
FROM buildpack-deps:bookworm-scm AS bookworm

RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
&& echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-bullseye-prod bullseye main" > /etc/apt/sources.list.d/microsoft.list \
&& echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-debian-bookworm-prod bookworm main" > /etc/apt/sources.list.d/microsoft.list \
&& apt-get update \
&& apt-get install -y --no-install-recommends powershell python3-minimal python3-pip python3-setuptools sudo \
&& rm -rf /var/lib/apt/lists/*
Expand Down
64 changes: 0 additions & 64 deletions eng/Dockerfile.manylinux

This file was deleted.

89 changes: 9 additions & 80 deletions eng/psakefile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,13 @@ Properties {
$VscodeSettingsJson = Join-Path $Root .vscode settings.json
$DocsRoot = Join-Path $Root docs
$DocsBuild = Join-Path $DocsRoot _build
$ManylinuxTag = "manylinux2014_x86_64_maturin"
$ManylinuxRoot = "/io"
$AuditWheelTag = "manylinux_2_31_x86_64"
$Python = Resolve-Python
}

task default -depends build, run-examples
task build -depends qirlib, pyqir
task checks -depends cargo-fmt, cargo-clippy, black, mypy
task manylinux -depends build-manylinux-container-image, run-manylinux-container-image, run-examples-in-containers

task run-manylinux-container-image -preaction { Write-CacheStats } -postaction { Write-CacheStats } {
$llvmDir = Resolve-InstallationDirectory
$llvmMount = @("-v", "$($llvmDir):/tmp/llvm")
Write-BuildLog "Running container image: $ManylinuxTag"
$ioVolume = "${Root}:$ManylinuxRoot"
$userName = Get-LinuxContainerUserName

Invoke-LoggedCommand {
docker run --rm `
--user $userName `
--volume $ioVolume @llvmMount `
--env QIRLIB_CACHE_DIR=/tmp/llvm `
--workdir $ManylinuxRoot `
$ManylinuxTag `
conda run --no-capture-output pwsh build.ps1 -t default
}
}

task cargo-fmt {
Invoke-LoggedCommand -workingDirectory $Root -errorMessage "Please run 'cargo fmt --all' before pushing" {
Expand Down Expand Up @@ -77,16 +57,20 @@ task qirlib -depends init {
task pyqir -depends init {
$env:MATURIN_PEP517_ARGS = (Get-CargoArgs) -Join " "
Get-Wheels pyqir | Remove-Item
Invoke-LoggedCommand { pip --verbose wheel --wheel-dir $Wheels $Pyqir }
Invoke-LoggedCommand { & $Python -m pip --verbose wheel --wheel-dir $Wheels $Pyqir }

if ($IsLinux) {
Invoke-LoggedCommand { & $Python -m pip install auditwheel patchelf }
}
if (Test-CommandExists auditwheel) {
$unauditedWheels = Get-Wheels pyqir
Invoke-LoggedCommand { auditwheel repair --wheel-dir $Wheels $unauditedWheels }
Invoke-LoggedCommand { auditwheel show $unauditedWheels }
Invoke-LoggedCommand { auditwheel repair --wheel-dir $Wheels --plat $AuditWheelTag $unauditedWheels }
$unauditedWheels | Remove-Item
}

$packages = Get-Wheels pyqir | ForEach-Object { "$_[test]" }
Invoke-LoggedCommand { pip install --force-reinstall $packages }
Invoke-LoggedCommand { & $Python -m pip install --force-reinstall $packages }
Invoke-LoggedCommand -workingDirectory $Pyqir { pytest }
}

Expand Down Expand Up @@ -179,41 +163,6 @@ task install-llvm-from-source -depends configure-sccache -postaction { Write-Cac
Assert (Test-LlvmConfig $installationDirectory) "install-llvm-from-source failed to install a usable LLVM installation"
}

task manylinux-install-llvm-from-source -depends build-manylinux-container-image -preaction { Write-CacheStats } -postaction { Write-CacheStats } {
$llvmDir = Resolve-InstallationDirectory
$llvmMount = @("-v", "$($llvmDir):/tmp/llvm")
Write-BuildLog "Running container image: $ManylinuxTag"
$ioVolume = "${Root}:$ManylinuxRoot"
$userName = Get-LinuxContainerUserName

Invoke-LoggedCommand {
docker run --rm `
--user $userName `
--volume $ioVolume @llvmMount `
--workdir $ManylinuxRoot `
$ManylinuxTag `
conda run --no-capture-output pwsh build.ps1 -t install-llvm-from-source
}
}

task package-manylinux-llvm -depends build-manylinux-container-image -preaction { Write-CacheStats } -postaction { Write-CacheStats } {
$llvmDir = Resolve-InstallationDirectory
$llvmMount = @("-v", "$($llvmDir):/tmp/llvm")
Write-BuildLog "Running container image: $ManylinuxTag"
$ioVolume = "${Root}:$ManylinuxRoot"
$userName = Get-LinuxContainerUserName

Invoke-LoggedCommand {
docker run --rm `
--user $userName `
--volume $ioVolume @llvmMount `
--workdir $ManylinuxRoot `
--env QIRLIB_PKG_DEST=$ManylinuxRoot/target/manylinux `
$ManylinuxTag `
conda run --no-capture-output pwsh build.ps1 -t package-llvm
}
}

task package-llvm {
if ($IsWindows) {
Include vcvars.ps1
Expand All @@ -236,32 +185,12 @@ task package-llvm {
}
}

task build-manylinux-container-image {
Write-BuildLog "Building container image manylinux-llvm-builder"
$RustVersion = (rustc --version) -split " " -match "^(\d+\.)?(\d+\.)?(\*|\d+)$"
Write-BuildLog "Found rustc version $RustVersion"
Invoke-LoggedCommand -workingDirectory (Join-Path $Root eng) {
$user = Get-LinuxContainerUserName
$uid = Get-LinuxContainerUserId
$gid = Get-LinuxContainerGroupId
docker build `
--build-arg USERNAME=$user `
--build-arg USER_UID=$uid `
--build-arg USER_GID=$gid `
--build-arg RUST_TOOLCHAIN=$RustVersion `
--tag $ManylinuxTag `
-f Dockerfile.manylinux `
$Root
}
}

# This is only usable if building for manylinux
task run-examples-in-containers {
$user = Get-LinuxContainerUserName
$uid = Get-LinuxContainerUserId
$gid = Get-LinuxContainerGroupId

foreach ($release in @("buster", "bullseye", "focal", "jammy")) {
foreach ($release in @("bullseye", "bookworm", "focal", "jammy")) {
exec -workingDirectory (Join-Path $Root eng) {
Get-Content Dockerfile.examples | docker build `
--build-arg RELEASE=$release `
Expand Down
2 changes: 1 addition & 1 deletion pyqir/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ llvm-sys-110 = { package = "llvm-sys", version = "110.0", optional = true }
llvm-sys-120 = { package = "llvm-sys", version = "120.2", optional = true }
llvm-sys-130 = { package = "llvm-sys", version = "130.0", optional = true }
llvm-sys-140 = { package = "llvm-sys", version = "140.0", optional = true }
pyo3 = { version = "0.17", features = ["abi3-py37", "extension-module"] }
pyo3 = { version = "0.17", features = ["abi3-py38", "extension-module"] }
qirlib = { path = "../qirlib" }

[features]
Expand Down
4 changes: 2 additions & 2 deletions pyqir/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
[project]
name = "pyqir"
version = "0.10.0"
requires-python = ">= 3.7"
requires-python = ">= 3.8"
classifiers = [
"License :: OSI Approved :: MIT License",
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python",
"Programming Language :: Rust",
"Operating System :: MacOS",
Expand Down

0 comments on commit aba3036

Please sign in to comment.