diff --git a/.github/workflows/docker-build-image.yml b/.github/workflows/docker-build-image.yml index 56e43e4f..8715c9e6 100644 --- a/.github/workflows/docker-build-image.yml +++ b/.github/workflows/docker-build-image.yml @@ -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 @@ -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 \ No newline at end of file diff --git a/.github/workflows/release-pypi-core.yml b/.github/workflows/release-pypi-core.yml index 662bd6a0..bdd01e1b 100644 --- a/.github/workflows/release-pypi-core.yml +++ b/.github/workflows/release-pypi-core.yml @@ -1,6 +1,9 @@ on: - push: - branches: [ core ] + pull_request: + branches: [ main ] + types: + - labeled + - synchronize env: PYPI_TOKEN: ${{ secrets.PYPI_UNDERTHESEA_CORE_API_TOKEN }} @@ -8,10 +11,10 @@ env: 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 }} @@ -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 @@ -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 @@ -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 @@ -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 @@ -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 \ No newline at end of file + poetry run maturin publish --username __token__ --interpreter $PYTHON \ No newline at end of file diff --git a/extensions/docker/build-image/Dockerfile b/extensions/docker/build-image/Dockerfile index ee4b97fc..30ca6739 100644 --- a/extensions/docker/build-image/Dockerfile +++ b/extensions/docker/build-image/Dockerfile @@ -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 @@ -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 diff --git a/extensions/docker/build-image/README.md b/extensions/docker/build-image/README.md index 7702de05..44779b77 100644 --- a/extensions/docker/build-image/README.md +++ b/extensions/docker/build-image/README.md @@ -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 diff --git a/extensions/underthesea_core/Cargo.toml b/extensions/underthesea_core/Cargo.toml index 07822dfd..a8563cd8 100644 --- a/extensions/underthesea_core/Cargo.toml +++ b/extensions/underthesea_core/Cargo.toml @@ -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 "] @@ -31,7 +31,7 @@ rayon = "1.5" crfs = "0.1" [dependencies.pyo3] -version = "0.15.0" +version = "0.21" features = ["extension-module"] [dev-dependencies] diff --git a/extensions/underthesea_core/pyproject.toml b/extensions/underthesea_core/pyproject.toml index 7696f9df..f7896102 100644 --- a/extensions/underthesea_core/pyproject.toml +++ b/extensions/underthesea_core/pyproject.toml @@ -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"]