From feffddd014321fcf73b96d9cbdfe2ebef1ef0b88 Mon Sep 17 00:00:00 2001 From: Wissam Antoun Date: Sun, 17 Jul 2022 13:40:11 +0200 Subject: [PATCH] enables publishing to pipy with ci/cd --- .github/workflows/publish-to-pypi.yml | 36 +++++++++++++++++++++ .github/workflows/publish-to-test-pypi.yml | 37 ++++++++++++++++++++++ README.md | 17 +++++++++- setup.py | 33 ++++++++++++++++++- 4 files changed, 121 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/publish-to-pypi.yml create mode 100644 .github/workflows/publish-to-test-pypi.yml diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml new file mode 100644 index 0000000..b3a870d --- /dev/null +++ b/.github/workflows/publish-to-pypi.yml @@ -0,0 +1,36 @@ +name: Publish AraBERT 📦 to TestPyPI + +on: workflow_dispatch + +jobs: + build-n-publish: + name: Build and publish + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@master + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + + - name: Install pypa/build + run: >- + python -m + pip install + build + --user + + - name: Build a binary wheel and a source tarball + run: >- + python -m + build + --sdist + --wheel + --outdir dist/ + . + + - name: Publish distribution 📦 to PyPI + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.PYPI_API_TOKEN }} diff --git a/.github/workflows/publish-to-test-pypi.yml b/.github/workflows/publish-to-test-pypi.yml new file mode 100644 index 0000000..aba0664 --- /dev/null +++ b/.github/workflows/publish-to-test-pypi.yml @@ -0,0 +1,37 @@ +name: Publish AraBERT 📦 to TestPyPI + +on: workflow_dispatch + +jobs: + build-n-publish: + name: Build and publish + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@master + - name: Set up Python 3.10 + uses: actions/setup-python@v3 + with: + python-version: "3.10" + + - name: Install pypa/build + run: >- + python -m + pip install + build + --user + + - name: Build a binary wheel and a source tarball + run: >- + python -m + build + --sdist + --wheel + --outdir dist/ + . + + - name: Publish distribution 📦 to Test PyPI + uses: pypa/gh-action-pypi-publish@master + with: + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository_url: https://test.pypi.org/legacy/ diff --git a/README.md b/README.md index 21518a7..80bf773 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # AraBERTv2 / AraGPT2 / AraELECTRA ![visitors](https://visitor-badge.glitch.me/badge?page_id=wissamantoun.arabert) +[![PyPI version](https://badge.fury.io/py/arabert.svg)](https://badge.fury.io/py/arabert)

@@ -21,9 +22,23 @@ cd arabert && git checkout 6a58ca118911ef311cbe8cdcdcc1d03601123291 ``` # Update -- **8-Oct-2021**: New AraBERT models that better supports tweets and emojies. +- **8-Oct-2021:** New AraBERT models that better supports tweets and emojies. - **13-Sep-2021:** Arabic NLP Demo Space on HuggingFace [![Open Space](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://huggingface.co/spaces/aubmindlab/Arabic-NLP) - **02-Apr-2021:** AraELECTRA powered Arabic Wikipedia QA system [![Open in Streamlit](https://static.streamlit.io/badges/streamlit_badge_black_white.svg)](https://share.streamlit.io/wissamantoun/arabic-wikipedia-qa-streamlit/main) +- **17-jul-2022:** You can now install arabert via `pip install arabert` + +# Installation + +Install AraBERT from PyPI: +```bash +pip install arabert +``` + +and then you can use it: +```python +from arabert import ArabertPreprocessor +from arabert.aragpt2.grover.modeling_gpt2 import GPT2LMHeadModel +``` # AraBERTv2 diff --git a/setup.py b/setup.py index 88dfd94..62b3219 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,36 @@ from setuptools import find_packages, setup + +def get_long_description(): + with open("README.md", "r", encoding="utf-8") as f: + long_description = f.read() + + long_description = long_description.replace( + "[Read More...](#AraBERT)", + "[Read More...](https://github.com/aub-mind/arabert/tree/master/arabert)", + ) + long_description = long_description.replace( + "[Read More...](#AraGPT2)", + "[Read More...](https://github.com/aub-mind/arabert/tree/master/aragpt2)", + ) + long_description = long_description.replace( + "[Read More...](#AraELECTRA)", + "[Read More...](https://github.com/aub-mind/arabert/tree/master/araelectra)", + ) + long_description = long_description.replace( + "[preprocessing function](#Preprocessing)", + "https://github.com/aub-mind/arabert#preprocessing", + ) + long_description = long_description.replace( + "[Dataset Section](#Dataset)", "https://github.com/aub-mind/arabert#Dataset" + ) + long_description = long_description.replace( + "https://github.com/aub-mind/arabert/blob/master/", + "https://raw.githubusercontent.com/aub-mind/arabert/master/", + ) + return long_description + + setup( name="arabert", version="1.0.0", @@ -10,7 +41,7 @@ description="AraBERT is a Python library that contains the" "code for the AraBERT, AraGPT2 and AraELECTRA models with" "the preprocessing scripts.", - long_description=open("README.md", "r", encoding="utf-8").read(), + long_description=get_long_description(), long_description_content_type="text/markdown", install_requires=["PyArabic", "farasapy"], py_modules=["arabert.preprocess"],