Skip to content

Commit 286938e

Browse files
authored
Add Python Release Action to publish pyiceberg_core dist to Pypi (#705)
1 parent 697a200 commit 286938e

File tree

5 files changed

+177
-2
lines changed

5 files changed

+177
-2
lines changed

.github/workflows/bindings_python_ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
- uses: actions/checkout@v4
6868
- uses: actions/setup-python@v5
6969
with:
70-
python-version: 3.8
70+
python-version: 3.9
7171
- uses: PyO3/maturin-action@v1
7272
with:
7373
working-directory: "bindings/python"
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
name: Publish Python 🐍 distribution 📦 to PyPI
19+
20+
on:
21+
push:
22+
tags:
23+
- '*'
24+
pull_request:
25+
branches:
26+
- main
27+
paths:
28+
- ".github/workflows/release_python.yml"
29+
workflow_dispatch:
30+
31+
env:
32+
rust_msrv: "1.77.1"
33+
34+
concurrency:
35+
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
36+
cancel-in-progress: true
37+
38+
permissions:
39+
contents: read
40+
41+
jobs:
42+
sdist:
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
- uses: PyO3/maturin-action@v1
47+
with:
48+
working-directory: "bindings/python"
49+
command: sdist
50+
args: -o dist
51+
- name: Upload sdist
52+
uses: actions/upload-artifact@v3
53+
with:
54+
name: wheels
55+
path: bindings/python/dist
56+
57+
wheels:
58+
runs-on: "${{ matrix.os }}"
59+
strategy:
60+
matrix:
61+
include:
62+
- { os: windows-latest }
63+
- { os: macos-latest, target: "universal2-apple-darwin" }
64+
- { os: ubuntu-latest, target: "x86_64" }
65+
- { os: ubuntu-latest, target: "aarch64" }
66+
- { os: ubuntu-latest, target: "armv7l" }
67+
steps:
68+
- uses: actions/checkout@v4
69+
- uses: actions/setup-python@v4
70+
with:
71+
python-version: 3.9
72+
- name: Setup Rust toolchain
73+
uses: ./.github/actions/setup-builder
74+
with:
75+
rust-version: ${{ env.rust_msrv }}
76+
- uses: PyO3/maturin-action@v1
77+
with:
78+
target: ${{ matrix.target }}
79+
manylinux: auto
80+
working-directory: "bindings/python"
81+
command: build
82+
args: --release -o dist
83+
env:
84+
# Workaround ring 0.17 build issue
85+
CFLAGS_aarch64_unknown_linux_gnu: "-D__ARM_ARCH=8"
86+
- name: Upload wheels
87+
uses: actions/upload-artifact@v3
88+
with:
89+
name: wheels
90+
path: bindings/python/dist
91+
92+
pypi-publish:
93+
name: Publish Python 🐍 distribution 📦 to Pypi
94+
needs: [ sdist, wheels ]
95+
runs-on: ubuntu-latest
96+
# Only publish to PyPi if the tag is not a pre-release
97+
if: ${{ startsWith(github.ref, 'refs/tags/') && !contains(github.ref, '-') }}
98+
99+
environment:
100+
name: pypi
101+
url: https://pypi.org/p/pyiceberg_core
102+
103+
permissions:
104+
id-token: write # IMPORTANT: mandatory for trusted publishing
105+
106+
steps:
107+
- name: Download all the dists
108+
uses: actions/download-artifact@v3
109+
with:
110+
name: wheels
111+
path: bindings/python/dist
112+
- name: Publish to PyPI
113+
uses: pypa/gh-action-pypi-publish@release/v1
114+
115+
with:
116+
skip-existing: true
117+
packages-dir: bindings/python/dist
118+
119+
testpypi-publish:
120+
name: Publish Python 🐍 distribution 📦 to TestPypi
121+
needs: [ sdist, linux ]
122+
runs-on: ubuntu-latest
123+
# Only publish to TestPyPi if the tag is a pre-release
124+
if: ${{ startsWith(github.ref, 'refs/tags/') && contains(github.ref, '-')}}
125+
126+
environment:
127+
name: testpypi
128+
url: https://test.pypi.org/p/pyiceberg_core
129+
130+
permissions:
131+
id-token: write # IMPORTANT: mandatory for trusted publishing
132+
133+
steps:
134+
- name: Download all the dists
135+
uses: actions/download-artifact@v3
136+
with:
137+
name: wheels
138+
path: bindings/python/dist
139+
- name: Publish to TestPyPI
140+
uses: pypa/gh-action-pypi-publish@release/v1
141+
with:
142+
repository-url: https://test.pypi.org/legacy/
143+
skip-existing: true
144+
packages-dir: bindings/python/dist

bindings/python/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ crate-type = ["cdylib"]
3232

3333
[dependencies]
3434
iceberg = { path = "../../crates/iceberg" }
35-
pyo3 = { version = "0.22.3", features = ["extension-module"] }
35+
pyo3 = { version = "0.22.3", features = ["extension-module", "abi3-py39"] }
3636
arrow = { version = "53", features = ["pyarrow"] }
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!--
2+
~ Licensed to the Apache Software Foundation (ASF) under one
3+
~ or more contributor license agreements. See the NOTICE file
4+
~ distributed with this work for additional information
5+
~ regarding copyright ownership. The ASF licenses this file
6+
~ to you under the Apache License, Version 2.0 (the
7+
~ "License"); you may not use this file except in compliance
8+
~ with the License. You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing,
13+
~ software distributed under the License is distributed on an
14+
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
~ KIND, either express or implied. See the License for the
16+
~ specific language governing permissions and limitations
17+
~ under the License.
18+
-->
19+
20+
# Pyiceberg Core
21+
22+
This project is used to build an iceberg-rust powered core for pyiceberg, and intended for use only by pyiceberg.
23+
24+
Install via PyPI:
25+
26+
```
27+
pip install pyiceberg_core
28+
```

bindings/python/pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,14 @@ build-backend = "maturin"
2222
[project]
2323
name = "pyiceberg_core"
2424
version = "0.0.1"
25+
readme = "project-description.md"
2526
classifiers = [
2627
"Development Status :: 4 - Beta",
2728
"Intended Audience :: Developers",
2829
"License :: OSI Approved :: Apache Software License",
2930
"Operating System :: OS Independent",
31+
"Programming Language :: Python :: 3.9",
32+
"Programming Language :: Python :: 3.10",
3033
"Programming Language :: Python :: 3.11",
3134
"Programming Language :: Python :: 3.12",
3235
]

0 commit comments

Comments
 (0)