From a44566ef08d97a7f253ea5af8ea0f728f51e24ba Mon Sep 17 00:00:00 2001 From: Michele Fabbri Date: Tue, 24 May 2022 13:08:41 +0100 Subject: [PATCH 1/4] init ci --- .flake8 | 2 +- .github/workflows/ci.yml | 41 ++++++++++++++++++++++++++++++++++++++++ .gitignore | 3 +++ .travis.yml | 25 ------------------------ requirements.txt | 2 +- 5 files changed, 46 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/ci.yml delete mode 100644 .travis.yml diff --git a/.flake8 b/.flake8 index 9ebe579..8689cb4 100644 --- a/.flake8 +++ b/.flake8 @@ -1,5 +1,5 @@ [flake8] -max-line-length = 99 +max-line-length = 130 ignore = W504 exclude = .git, diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..ea09a70 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,41 @@ +name: CI + +on: + push: + branches: [ master, develop, ci_and_pypi ] # TODO: remove additional branch when deploying to production + pull_request: + branches: [ master, develop ] + +jobs: + build: + name: build (${{ matrix.python-version }}, ${{ matrix.os }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + max-parallel: 3 + matrix: + os: ["ubuntu-latest", "macos-latest", "windows-latest"] + python-version: ["3.8", "3.9"] + steps: + - name: Clone repo + uses: actions/checkout@v3 + with: + ref: ci_and_pypi # TODO: remove when deploying to master + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install deps + run: | + python -m pip install --upgrade pip + python -m pip install flake8 pytest + pip install -r requirements.txt + pip install -e . + # TODO: enable flake8 and tests when we have a better handle on what is important +# - name: Flake8 +# run: | +# python -m flake8 +# - name: Tests +# run: | +# cd tests +# python -m unittest discover diff --git a/.gitignore b/.gitignore index 7640b7a..438dc89 100644 --- a/.gitignore +++ b/.gitignore @@ -135,3 +135,6 @@ dmypy.json .vscode/ scratch/ + +# pycharm +.idea/* \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6324eff..0000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -language: python -python: - - "3.7" -# command to install dependencies -install: - - pip install -r requirements.txt - - pip install -e . - # install develop branch of ibllib - - pip install git+https://github.com/int-brain-lab/ibllib.git@develop - - # command to run tests -before_script: - - echo "exec('from oneibl.one import ONE; ONE(silent=True)')" | python - - sed -i 's|null|"'$IBLFLATIRONPASS'"|g' /home/travis/.one_params - # command to run tests - -script: - - bash ./run_tests - - flake8 . - -# only build master and develop (PRs are built for all branches) -branches: - only: - - master - - develop diff --git a/requirements.txt b/requirements.txt index f5cbdcb..eabf653 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ easyqc ibllib +PyQt5 pyqtgraph simpleITK -PyQt5 From 2277700a3d1037b913831ca0975f6feb412a6ad9 Mon Sep 17 00:00:00 2001 From: Michele Fabbri Date: Tue, 24 May 2022 13:52:47 +0100 Subject: [PATCH 2/4] init pypi --- .github/workflows/pypi.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/pypi.yml diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml new file mode 100644 index 0000000..bb94b4f --- /dev/null +++ b/.github/workflows/pypi.yml @@ -0,0 +1,33 @@ +# This workflow will upload a Python Package using Twine when a release is created +# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries +name: Upload Python Package + +on: + release: + types: [published] + +permissions: + contents: read + +jobs: + deploy: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: '3.x' + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + - name: Build and publish + env: + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + run: | + python setup.py sdist bdist_wheel + twine upload dist/* From 4e7195094ea24cfcc536c1ea432966e6a7357032 Mon Sep 17 00:00:00 2001 From: Michele Fabbri Date: Tue, 24 May 2022 16:21:49 +0100 Subject: [PATCH 3/4] setup for pypi template --- __init__.py | 1 + setup.py | 58 ++++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 52 insertions(+), 7 deletions(-) diff --git a/__init__.py b/__init__.py index e69de29..b3c06d4 100644 --- a/__init__.py +++ b/__init__.py @@ -0,0 +1 @@ +__version__ = "0.0.1" \ No newline at end of file diff --git a/setup.py b/setup.py index ef3f9ee..1e14487 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,56 @@ -from setuptools import setup, find_packages +import sys +from pathlib import Path + +from setuptools import find_packages, setup + +CURRENT_DIRECTORY = Path(__file__).parent.absolute() +CURRENT_PYTHON = sys.version_info[:2] +REQUIRED_PYTHON = (3, 8) +VER_ERR_MSG = """ +========================== +Unsupported Python version +========================== +This version of ibllib requires Python {}.{}, but you're trying to install it on Python {}.{}. +""" +if CURRENT_PYTHON < REQUIRED_PYTHON: + sys.stderr.write(VER_ERR_MSG.format(*REQUIRED_PYTHON + CURRENT_PYTHON)) + sys.exit(1) + +with open("README.md", "r") as f: + long_description = f.read() + +with open("requirements.txt") as f: + require = [x.strip() for x in f.readlines() if not x.startswith("git+")] + + +def read(rel_path): + here = Path(__file__).parent.absolute() + with open(here.joinpath(rel_path), "r") as fp: + return fp.read() + + +def get_version(rel_path): + for line in read(rel_path).splitlines(): + if line.startswith("__version__"): + delim = '"' if '"' in line else "'" + return line.split(delim)[1] + else: + raise RuntimeError("Unable to find version string.") -with open('requirements.txt') as f: - require = [x.strip() for x in f.readlines() if not x.startswith('git+')] setup( - name='iblapps', - version='0.1', - packages=find_packages(), + name="iblapps", + version=get_version("__init__.py"), + python_requires=">={}.{}".format(*REQUIRED_PYTHON), + description="IBL Applications", + license="MIT", + long_description=long_description, + long_description_content_type="text/markdown", + author="IBL Staff", + url="https://www.internationalbrainlab.com/", + packages=find_packages(exclude=["scratch"]), # same as name include_package_data=True, - install_requires=require + # external packages as dependencies + install_requires=require, + scripts=[], ) From 7f0ae9d114b85895b40af22f4f3abbd4a25e18f0 Mon Sep 17 00:00:00 2001 From: Michele Fabbri Date: Mon, 30 May 2022 15:55:26 +0100 Subject: [PATCH 4/4] minor changes for testing pypi --- .flake8 | 1 - requirements.txt | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.flake8 b/.flake8 index 8689cb4..1182c13 100644 --- a/.flake8 +++ b/.flake8 @@ -1,6 +1,5 @@ [flake8] max-line-length = 130 -ignore = W504 exclude = .git, __pycache__, diff --git a/requirements.txt b/requirements.txt index eabf653..80b5c34 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ easyqc +flake8 ibllib PyQt5 pyqtgraph