diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..e163e529 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,41 @@ + + +name: Publish + +on: + push: + branches: + - main + release: + types: [published] + +permissions: + contents: read + +jobs: + call-test-build: + uses: ./.github/workflows/testbuild.yml + + publish-artifacts: + environment: production + needs: call-test-build + runs-on: ubuntu-latest + steps: + - name: Download all artifacts + uses: actions/download-artifact@v3 + with: + path: artifacts + - name: List files + run: ls -R artifacts + - name: Gather artifacts + run: | + mkdir dist + mv artifacts/source/*.tar.gz dist/ + mv artifacts/wheels-macos-latest/*.whl dist/ + mv artifacts/wheels-ubuntu-latest/*.whl dist/ + mv artifacts/wheels-windows-latest/*.whl dist/ + - name: Publish package + uses: pypa/gh-action-pypi-publish@v1.5.1 + with: + verbose: true + password: ${{ secrets.API_TOKEN_PYPI }} diff --git a/.github/workflows/pull_request.yml b/.github/workflows/testbuild.yml similarity index 86% rename from .github/workflows/pull_request.yml rename to .github/workflows/testbuild.yml index 46516d3c..232f6dce 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/testbuild.yml @@ -1,8 +1,12 @@ -name: pull_request_builds +name: Test and Build on: pull_request: types: [opened, synchronize, reopened] + workflow_call: + +permissions: + contents: read jobs: @@ -10,6 +14,8 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - uses: actions/setup-python@v4 with: python-version: '3.10' @@ -35,6 +41,8 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - uses: actions/setup-python@v4 with: python-version: ${{ matrix.python-version }} @@ -58,6 +66,10 @@ jobs: run: pip install -r tests/requirements.txt - name: Unit tests run: pytest + - name: Check package compliance + run: | + pip install -q twine + twine check dist/* - name: Store artifact uses: actions/upload-artifact@v3 with: @@ -74,6 +86,8 @@ jobs: os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - uses: actions/setup-python@v4 with: python-version: '3.10' @@ -85,8 +99,10 @@ jobs: uses: pypa/cibuildwheel@v2.11.1 with: output-dir: dist - - name: Install test dependencies - run: pip install -r tests/requirements.txt + - name: Check package compliance + run: | + pip install -q twine + twine check dist/* - name: Store artifact uses: actions/upload-artifact@v3 with: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 142f7dd9..73bb6adf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,6 +8,12 @@ Your cycle 5. When you're done with the feature, ask for reviews from two team members or ask the maintainers for help. 6. When the reviewers have approved the Pull Request, they will merge it into the master branch. At this point you want to checkout the master branch again and pull so that you have your latest changes, and can open a new branch for a new feature. +Here is an example shell command to build rsatoolbox, install it in your environment, and run the unit tests on it, in one go: + +```sh +python -m build && sleep 1 && pip install --pre --force-reinstall dist/*.whl && pytest +``` + Rules ===== @@ -22,6 +28,14 @@ Rules or alternatively, ping @ilogue or @HeikoSchuett and we will assign reviewers. +Deployment +========== + + +- when a PR is merged into the branch main, it is build as a pre-release (or "development") package and uploaded to pypi. The latest pre-release version can be installed using `pip install --pre rsatoolbox` +- when a release tag is added to the branch main, the package is instead marked as a released (or "stable") version. + + Naming scheme ============= diff --git a/README.md b/README.md index 7374e4e9..2b61dd87 100644 --- a/README.md +++ b/README.md @@ -14,12 +14,13 @@ Conceived during the RSA retreat 2019 in Blue Mountains. #### Getting Started -The easiest way to install rsatoolbox is with pip: +To install the latest stable version of rsatoolbox with pip: ```sh pip install rsatoolbox ``` + here is a simple code sample: ```python diff --git a/docs/source/conf.py b/docs/source/conf.py index 0b7fda19..f171a7c1 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -14,6 +14,7 @@ # import os import sys +from pkg_resources import get_distribution sys.path.insert(0, os.path.abspath('.')) sys.path.insert(0, os.path.abspath('../')) @@ -23,10 +24,11 @@ copyright = '2021, rsatoolbox authors' author = 'rsatoolbox authors' +# The full version +release = get_distribution('rsatoolbox').version + # The short X.Y version -version = '0.0' -# The full version, including alpha/beta/rc tags -release = '0.0.5' +version = '.'.join(release.split('.')[:2]) # -- General configuration --------------------------------------------------- diff --git a/docs/source/getting_started.rst b/docs/source/getting_started.rst index 9a99cc55..6513d4e9 100644 --- a/docs/source/getting_started.rst +++ b/docs/source/getting_started.rst @@ -3,12 +3,20 @@ Getting started =============== -The easiest way to install rsatoolbox is with pip: +To install the latest release of rsatoolbox: .. code-block:: sh pip install rsatoolbox + +To get the bleeding edge or "pre-release" version: + +.. code-block:: sh + + pip install --pre rsatoolbox + + To use rsatoolbox: .. code-block:: python diff --git a/pyproject.toml b/pyproject.toml index 52ff084d..7e72c643 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,11 +1,12 @@ [build-system] requires = [ "setuptools~=65.3", - "setuptools-scm", + "setuptools-scm[toml]~=7.0.0", "wheel", "numpy>=1.21.2", "scipy", - "cython~=3.0.0a11" + "cython~=3.0.0a11", + "twine~=4.0.1" ] build-backend = "setuptools.build_meta" @@ -13,11 +14,10 @@ build-backend = "setuptools.build_meta" name = "rsatoolbox" description = "Representational Similarity Analysis (RSA) in Python" requires-python = ">=3.7,<3.11" -version = "0.0.5" authors = [ {name="rsatoolbox authors"}, ] -keywords = ["neuroscience "] +keywords = ["neuroscience"] license = {file = "LICENSE"} classifiers = [ 'Programming Language :: Python', @@ -31,11 +31,17 @@ classifiers = [ 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', ] -dynamic = ["readme", "dependencies"] +dynamic = ["readme", "dependencies", "version"] -[tool.setuptools] -packages = ["rsatoolbox"] -package-dir = {"" = "src"} +[project.urls] +homepage = "https://github.com/rsagroup/rsatoolbox" +documentation = "https://rsatoolbox.readthedocs.io/" + +[tool.setuptools_scm] +local_scheme = "no-local-version" + +[tool.setuptools.packages.find] +where = ["src"] [tool.setuptools.dynamic] readme = {file = "README.md"} diff --git a/setup.py b/setup.py index 3bd25133..873737d6 100644 --- a/setup.py +++ b/setup.py @@ -1,17 +1,14 @@ +"""Setup.py now only remains as a build script for the cython extensions. +Using setup.py for other things is now deprecated: + setup.py test -> pytest + setup.py develop -> pip install -e +""" from setuptools import setup, Extension -from Cython.Build import build_ext ## missing dev time req -from os.path import isfile +import setuptools_scm # noqa # pylint: disable=unused-import +from Cython.Build import build_ext -test_requires = [] -if isfile('tests/requirements.txt'): - with open('tests/requirements.txt') as reqfile: - test_requires = reqfile.read().splitlines() setup( - tests_require=test_requires, - test_suite='tests', - url = "https://github.com/rsagroup/rsatoolbox", - zip_safe = False, ext_modules = [ Extension( "rsatoolbox.cengine.similarity",