Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-729: Support Python 3.12 #738

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
16 changes: 9 additions & 7 deletions .github/workflows/docker-build-image.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
on:
push:
branches:
- 'core'
pull_request:
branches: [ main ]
types:
- labeled
- synchronize

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/build_rust
VERSION: 1.0.0
VERSION: 2.0.0a0

jobs:
docker:
if: contains(github.event.head_commit.message, 'Docker build image')
runs-on: ubuntu-latest
if: ${{ github.event.label.name == 'docker-build-image' }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -38,9 +40,9 @@ jobs:
uses: docker/build-push-action@v2
with:
context: .
file: ./extensions/docker/Dockerfile
file: ./extensions/docker/build-image/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
cache-to: type=gha,mode=max
55 changes: 29 additions & 26 deletions .github/workflows/release-pypi-core.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
on:
push:
branches: [ core ]
pull_request:
branches: [ main ]
types:
- labeled
- synchronize

env:
PYPI_TOKEN: ${{ secrets.PYPI_UNDERTHESEA_CORE_API_TOKEN }}

jobs:
source_distribute:
name: "Source Distribute"
if: contains(github.event.head_commit.message, 'Publish Underthesea Core')
if: ${{ github.event.label.name == 'release-pypi-core' }}
runs-on: ubuntu-latest
container:
image: ghcr.io/undertheseanlp/underthesea/build_rust:1.0.0
image: ghcr.io/undertheseanlp/underthesea/build_rust:2.0.0a0
env:
HOME: /root
PYTHON: python${{ matrix.python-version }}
Expand Down Expand Up @@ -40,17 +43,17 @@ jobs:
twine upload ./target/wheels/* -u __token__ -p "$PYPI_TOKEN"
linux:
name: "Linux"
if: contains(github.event.head_commit.message, 'Publish Underthesea Core')
if: ${{ github.event.label.name == 'release-pypi-core' }}
runs-on: ubuntu-latest
container:
image: ghcr.io/undertheseanlp/underthesea/build_rust:1.0.0
image: ghcr.io/undertheseanlp/underthesea/build_rust:2.0.0a0
env:
HOME: /root
PYTHON: python${{ matrix.python-version }}
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v1
- name: Create environment and install package dependencies
Expand All @@ -67,17 +70,17 @@ jobs:
env:
MATURIN_PASSWORD: ${{ secrets.PYPI_UNDERTHESEA_CORE_API_TOKEN }}
run: |
$PYTHON -m poetry run maturin build --release --no-sdist --strip --interpreter python${{ matrix.python-version }}
$PYTHON -m poetry run maturin build --release --strip --only-binary --interpreter python${{ matrix.python-version }}
find ./target/wheels/
$PYTHON -m poetry run maturin publish --username __token__ --no-sdist --interpreter python${{ matrix.python-version }}
$PYTHON -m poetry run maturin publish --username __token__ --interpreter python${{ matrix.python-version }}
windows:
name: "Windows"
if: contains(github.event.head_commit.message, 'Publish Underthesea Core')
if: ${{ github.event.label.name == 'release-pypi-core' }}
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
Expand All @@ -102,17 +105,17 @@ jobs:
env:
MATURIN_PASSWORD: ${{ secrets.PYPI_UNDERTHESEA_CORE_API_TOKEN }}
run: |
poetry run maturin build --release --no-sdist --strip --interpreter python
poetry run maturin build --release --strip --interpreter --only-binary python
dir target\wheels\
poetry run maturin publish --username __token__ --no-sdist --interpreter python
macos-x86:
name: "MacOS x86"
if: contains(github.event.head_commit.message, 'Publish Underthesea Core')
runs-on: macos-latest
poetry run maturin publish --username __token__ --interpreter python
macos-x64:
name: "MacOS x64"
if: ${{ github.event.label.name == 'release-pypi-core' }}
runs-on: macos-13
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
Expand All @@ -138,18 +141,18 @@ jobs:
env:
MATURIN_PASSWORD: ${{ secrets.PYPI_UNDERTHESEA_CORE_API_TOKEN }}
run: |
poetry run maturin build --release --no-sdist --strip --interpreter python${{ matrix.python-version }}
poetry run maturin build --release --strip --interpreter --only-binary python${{ matrix.python-version }}
find ./target/wheels/
pip install target/wheels/underthesea_core*.whl
poetry run maturin publish --username __token__ --no-sdist --interpreter python${{ matrix.python-version }}
poetry run maturin publish --username __token__ --interpreter python${{ matrix.python-version }}
macos-arm:
name: "MacOS ARM"
if: contains(github.event.head_commit.message, 'Publish Underthesea Core')
runs-on: self-hosted
if: ${{ github.event.label.name == 'release-pypi-core' }}
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -166,8 +169,8 @@ jobs:
PYTHON: /Users/anhv/anaconda3/envs/python${{ matrix.python-version }}/bin/python${{ matrix.python-version }}
MATURIN_PASSWORD: ${{ secrets.PYPI_UNDERTHESEA_CORE_API_TOKEN }}
run: |
export PATH="${PWD}/poetry/bin:${PATH}"
export PATH="${PWD}/poetry/bin:${PATH}"
$PYTHON --version
poetry run maturin build --release --no-sdist --strip --interpreter $PYTHON
poetry run maturin build --release --strip --interpreter --only-binary $PYTHON
find ./target/wheels/
poetry run maturin publish --username __token__ --no-sdist --interpreter $PYTHON
poetry run maturin publish --username __token__ --interpreter $PYTHON
12 changes: 10 additions & 2 deletions extensions/docker/build-image/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,16 @@ RUN echo 'export PATH=/opt/conda/bin:$PATH' > /etc/profile.d/conda.sh && \
wget --quiet https://repo.anaconda.com/miniconda/Miniconda3-4.5.11-Linux-x86_64.sh -O ~/miniconda.sh && \
/bin/bash ~/miniconda.sh -b -p /opt/conda && \
rm ~/miniconda.sh
ENV PATH /opt/conda/bin:$PATH

ENV PATH /opt/conda/bin:$PATH
RUN conda config --set ssl_verify False
RUN conda update conda
ENV PATH /opt/conda/envs/python3.7/bin:$PATH
ENV PATH /opt/conda/envs/python3.8/bin:$PATH
ENV PATH /opt/conda/envs/python3.9/bin:$PATH
ENV PATH /opt/conda/envs/python3.10/bin:$PATH
ENV PATH /opt/conda/envs/python3.11/bin:$PATH
ENV PATH /opt/conda/envs/python3.12/bin:$PATH

# python 3.7
RUN conda create -f -y -n python3.7 python=3.7
Expand All @@ -55,8 +57,14 @@ RUN ln -s /opt/conda/envs/python3.10/bin/python3.10 /usr/bin/python3.10
RUN source activate python3.10 && conda install -y pip
RUN python3.10 -m pip install poetry

# python 3.11
# # python 3.11
RUN conda create -f -y -n python3.11 python=3.11
RUN ln -s /opt/conda/envs/python3.11/bin/python3.11 /usr/bin/python3.11
RUN source activate python3.11 && conda install -y pip
RUN python3.11 -m pip install poetry

# python 3.12
RUN conda create -f -y -n python3.12 python=3.12
RUN ln -s /opt/conda/envs/python3.12/bin/python3.12 /usr/bin/python3.12
RUN source activate python3.12 && conda install -y pip
RUN python3.12 -m pip install poetry
2 changes: 1 addition & 1 deletion extensions/docker/build-image/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Environments:
* gcc
* glibc 2.17
* Cargo
* Python: 3.7, 3.8, 3.9, 3.10, 3.11
* Python: 3.7, 3.8, 3.9, 3.10, 3.11, 3.12

# Steps to build docker

Expand Down
4 changes: 2 additions & 2 deletions extensions/underthesea_core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "underthesea_core"
version = "1.0.4"
version = "2.0.0-alpha.0"
homepage = "https://github.com/undertheseanlp/underthesea/tree/main/extensions/underthesea_core"
repository = "https://github.com/undertheseanlp/underthesea/"
authors = ["Vu Anh <[email protected]>"]
Expand Down Expand Up @@ -31,7 +31,7 @@ rayon = "1.5"
crfs = "0.1"

[dependencies.pyo3]
version = "0.15.0"
version = "0.21"
features = ["extension-module"]

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions extensions/underthesea_core/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ repository = "https://github.com/undertheseanlp/underthesea/"
homepage = "https://github.com/undertheseanlp/underthesea/tree/main/extensions/underthesea_core"

[tool.poetry.dependencies]
python = "^3.5"
python = "^3.8"

[tool.poetry.dev-dependencies]
maturin = "^0.9.4"
maturin = "^1.6.0"

[build-system]
requires = ["setuptools"]
Expand Down
Loading