diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index b299d56d..a4c763d1 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -20,6 +20,13 @@ jobs: run: | python -m pip install --upgrade pip pip install ".[docs,tutorials]" + # if there is doc or tutorial requirements.txt file then install it + if [ -f ./docs/tutorials/requirements.txt ]; then + pip install -r ./docs/tutorials/requirements.txt + fi + if [ -f ./docs/requirements.txt ]; then + pip install -r ./docs/requirements.txt + fi - name: Build and Commit uses: sphinx-notes/pages@2.1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b89559af..67f9c35f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,15 +1,29 @@ name: Release on: + # uncomment the following to only release on push to main + # this is not recommended as it will not release if the tests fail + # however it is faster and can be used for testing push: - branches: [main] - pull_request: - branches: [main] + branches: + - main + # uncomment the following to only release on a successful workflow run + # this is recommended as it will only release if the tests pass + # this however cause you to test twice which might be not be ideal + # if you oncomment this + # workflow_run: + # workflows: ["Tests"] + # types: + # - completed jobs: release: runs-on: ubuntu-latest concurrency: release + # if the workflow run was successful and the branch is main: + # only uncomment this if you uncomment the workflow_run above + # if: ${{ github.event.workflow_run.conclusion == 'success' && github.ref == 'refs/heads/main' }} + # only uncomment this if you run on push to main if: ${{ github.ref == 'refs/heads/main' }} steps: # Checkout action is required for token to persist @@ -21,11 +35,12 @@ jobs: - name: Python Semantic Release uses: relekang/python-semantic-release@v7.32.0 with: + git_committer_name: release-bot github_token: ${{ secrets.RELEASE }} - # Remember to copy the [semantic_release] section from setup.cfg + # Remember to copy the [semantic_release] section from pyproject.toml # as well # To enable pypi, - # 1) Set upload_to_pypi to true in setup.cfg and + # 1) Set upload_to_pypi to true in pyproject.toml and # 2) Set the pypi_token in the repo # 3) Uncomment the two lines below repository_username: __token__ diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index b8c34c7a..09cb9109 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -32,7 +32,12 @@ jobs: shell: bash run: | python -m pip install --upgrade pip + # Assumes the package have the tests extra pip install ".[tests]" + # if there is a ./tests/requirements.txt file then install it + if [ -f ./tests/requirements.txt ]; then + pip install -r ./tests/requirements.txt + fi - name: Run and write pytest shell: bash @@ -43,7 +48,13 @@ jobs: - name: Install dependencies for notebooks shell: bash run: | + # Assumes the package have the tutorials extra pip install ".[tutorials]" + # if there is a tutorials requirements.txt file then install it + if [ -f ./tests/requirements.txt ]; then + pip install -r ./docs/tutorials/requirements.txt + fi + - name: Convert and run notebooks shell: bash diff --git a/docs/installation.rst b/docs/installation.rst index d19931cf..b5567d3b 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -16,4 +16,10 @@ package using the following commands: git clone https://github.com/hlasse/TextDescriptives - pip install -e ".[style,tests,docs,tutorials]" \ No newline at end of file + pip install -e ".[style,tests,docs,tutorials]" + + # pip install specific dependencies for each + # as not e.g. links currently can't be included in extra + # dependencies + pip install -r tests/requirements.txt + pip install -r docs/tutorials/requirements.txt diff --git a/docs/tutorials/requirements.txt b/docs/tutorials/requirements.txt new file mode 100644 index 00000000..32d74dea --- /dev/null +++ b/docs/tutorials/requirements.txt @@ -0,0 +1,5 @@ +# only for requirements which can't be specified in the pyproject.toml file +# e.g. links to wheels which is not allowed in pyproject.toml on pypi + +# spacy pipeline +https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.2.0/en_core_web_sm-3.2.0.tar.gz \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 72908f84..03166982 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,7 +33,7 @@ keywords = [ ] dependencies = [ - "spacy>=3.1.0<3.5.0", + "spacy>=3.1.0,<3.5.0", "numpy>=1.20.0,<1.24.0", "pandas>=1.0.0,<1.6.0", "pyphen>=0.11.0,<0.12.0", @@ -57,8 +57,6 @@ style = [ tests = [ "pytest>=7.1.3,<7.3.0", "pytest-cov>=3.0.0,<3.0.1", - # the @ allows installing using a link - "en-core-web-sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.2.0/en_core_web_sm-3.2.0.tar.gz", ] docs = [ "sphinx>=5.3.0,<5.4.0", @@ -73,7 +71,6 @@ tutorials = [ "jupyter", "seaborn", "matplotlib", - "en-core-web-sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.2.0/en_core_web_sm-3.2.0.tar.gz", ] [project.readme] @@ -91,7 +88,7 @@ name = "Apache License 2.0" where = ["src"] [build-system] -requires = ["setuptools"] +requires = ["setuptools>=61.0.0", "wheel", "setuptools_scm"] build-backend = "setuptools.build_meta" [tool.coverage.run] @@ -121,6 +118,7 @@ branch = "main" version_variable = [ "pyproject.toml:version" ] +build_command = "python -m pip install build; python -m build" upload_to_pypi = true upload_to_release = true diff --git a/setup.py b/setup.py deleted file mode 100644 index 7f1a1763..00000000 --- a/setup.py +++ /dev/null @@ -1,4 +0,0 @@ -from setuptools import setup - -if __name__ == "__main__": - setup() diff --git a/tests/requirements.txt b/tests/requirements.txt new file mode 100644 index 00000000..32d74dea --- /dev/null +++ b/tests/requirements.txt @@ -0,0 +1,5 @@ +# only for requirements which can't be specified in the pyproject.toml file +# e.g. links to wheels which is not allowed in pyproject.toml on pypi + +# spacy pipeline +https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.2.0/en_core_web_sm-3.2.0.tar.gz \ No newline at end of file