Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ci and pypi #60

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[flake8]
max-line-length = 99
ignore = W504
max-line-length = 130
exclude =
.git,
__pycache__,
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
33 changes: 33 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -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/*
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -135,3 +135,6 @@ dmypy.json
.vscode/

scratch/

# pycharm
.idea/*
25 changes: 0 additions & 25 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.0.1"
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
easyqc
flake8
ibllib
PyQt5
pyqtgraph
simpleITK
PyQt5
58 changes: 51 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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=[],
)