Skip to content
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
115 changes: 115 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: CI

on:
push:
branches: [ main, master, dev ]
pull_request:
branches: [ main, master, dev ]

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
qt-version: ["qt5", "qt6"]
exclude:
# PyQt6 might have issues on some older Python versions
- python-version: "3.9"
qt-version: "qt6"

steps:
- uses: actions/checkout@v4

# Set up display for GUI testing on Linux
- name: Set up display (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y xvfb herbstluftwm
export DISPLAY=:99.0
Xvfb :99 -screen 0 1400x900x24 -ac +extension GLX +render &
sleep 3
herbstluftwm &
sleep 1
env:
DISPLAY: :99.0

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"

- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}

- name: Install dependencies
run: uv sync --dev --extra ${{ matrix.qt-version }}

- name: Install phylib from branch
run: |
if [ "${{ github.ref_name }}" = "master" ]; then
uv add "git+https://github.com/cortex-lab/phylib.git@master"
elif [ "${{ github.ref_name }}" = "dev" ]; then
uv add "git+https://github.com/cortex-lab/phylib.git@dev"
else
uv add "git+https://github.com/cortex-lab/phylib.git@${{ github.ref_name }}"
fi
shell: bash

- name: Install additional test dependencies
run: |
uv add "git+https://github.com/kwikteam/klusta.git"
uv add "git+https://github.com/kwikteam/klustakwik2.git"

- name: Lint with ruff
run: uv run ruff check phy

- name: Check formatting with ruff
run: uv run ruff format --check phy

- name: Test with pytest (Linux)
if: runner.os == 'Linux'
run: uv run make test-full
env:
DISPLAY: :99.0
QT_QPA_PLATFORM: offscreen

- name: Test with pytest (Windows/macOS)
if: runner.os != 'Linux'
run: uv run pytest --cov=phy --cov-report=xml phy
env:
QT_QPA_PLATFORM: offscreen

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

build:
runs-on: ubuntu-latest
needs: test

steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"

- name: Set up Python
run: uv python install 3.9

- name: Build package
run: uv build

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
local_tests
contrib
data
doc
Expand Down
64 changes: 51 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,74 @@ clean-build:
rm -fr build/
rm -fr dist/
rm -fr *.egg-info
rm -fr .eggs/

clean-pyc:
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +

clean: clean-build clean-pyc
clean-test:
rm -fr .tox/
rm -f .coverage
rm -fr htmlcov/
rm -fr .pytest_cache/
rm -fr .ruff_cache/

clean: clean-build clean-pyc clean-test

install:
uv sync --dev --extra qt5

install-qt6:
uv sync --dev --extra qt6

lint:
flake8 phy
uv run ruff check phy

format:
uv run ruff format phy

format-check:
uv run ruff format --check phy

lint-fix:
uv run ruff check --fix phy

# Test everything except apps.
test: lint
py.test -xvv --cov-report= --cov=phy phy --ignore=phy/apps/ --cov-append
coverage report --omit */phy/apps/*,*/phy/plot/gloo/*
# Test everything except apps
test: lint format-check
uv run pytest -xvv --cov-report= --cov=phy phy --ignore=phy/apps/ --cov-append
uv run coverage report --omit "*/phy/apps/*,*/phy/plot/gloo/*"

# Test just the apps.
# Test just the apps
test-apps: lint
py.test --cov-report term-missing --cov=phy.apps phy/apps/ --cov-append
uv run pytest --cov-report term-missing --cov=phy.apps phy/apps/ --cov-append

# Test everything.
# Test everything
test-full: test test-apps
coverage report --omit */phy/plot/gloo/*
uv run coverage report --omit "*/phy/plot/gloo/*"

test-fast:
uv run pytest phy

doc:
python3 tools/api.py && python tools/extract_shortcuts.py && python tools/plugins_doc.py
uv run python tools/api.py && uv run python tools/extract_shortcuts.py && uv run python tools/plugins_doc.py

build:
python3 setup.py sdist --formats=zip
uv build

upload:
twine upload dist/*
uv publish

upload-test:
uv publish --publish-url https://test.pypi.org/legacy/

coverage:
uv run coverage html

dev: install lint format test

ci: lint format-check test-full build

.PHONY: clean-build clean-pyc clean-test clean install install-qt6 lint format format-check lint-fix test test-apps test-full test-fast doc build upload upload-test coverage dev ci
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
44 changes: 29 additions & 15 deletions setup.py → deprecated/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"""Installation script."""


#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Imports
#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------

import os
import os.path as op
Expand All @@ -15,15 +15,18 @@
from setuptools import setup


#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Setup
#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------


def _package_tree(pkgroot):
path = op.dirname(__file__)
subdirs = [op.relpath(i[0], path).replace(op.sep, '.')
for i in os.walk(op.join(path, pkgroot))
if '__init__.py' in i[2]]
subdirs = [
op.relpath(i[0], path).replace(op.sep, '.')
for i in os.walk(op.join(path, pkgroot))
if '__init__.py' in i[2]
]
return subdirs


Expand Down Expand Up @@ -52,23 +55,34 @@ def _package_tree(pkgroot):
setup(
name='phy',
version=version,
license="BSD",
license='BSD',
description='Interactive visualization and manual spike sorting of large-scale ephys data',
long_description=readme,
long_description_content_type="text/markdown",
long_description_content_type='text/markdown',
author='Cyrille Rossant (cortex-lab/UCL/IBL)',
author_email='cyrille.rossant+pypi@gmail.com',
url='https://phy.cortexlab.net',
packages=_package_tree('phy'),
package_dir={'phy': 'phy'},
package_data={
'phy': ['*.vert', '*.frag', '*.glsl', '*.npy', '*.gz', '*.txt', '*.json',
'*.html', '*.css', '*.js', '*.prb', '*.ttf', '*.png'],
'phy': [
'*.vert',
'*.frag',
'*.glsl',
'*.npy',
'*.gz',
'*.txt',
'*.json',
'*.html',
'*.css',
'*.js',
'*.prb',
'*.ttf',
'*.png',
],
},
entry_points={
'console_scripts': [
'phy = phy.apps:phycli'
],
'console_scripts': ['phy = phy.apps:phycli'],
},
install_requires=require,
include_package_data=True,
Expand All @@ -78,7 +92,7 @@ def _package_tree(pkgroot):
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Natural Language :: English',
"Framework :: IPython",
'Framework :: IPython',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
],
Expand Down
10 changes: 5 additions & 5 deletions phy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
# -*- coding: utf-8 -*-
# flake8: noqa

"""phy: interactive visualization and manual spike sorting of large-scale ephys data."""


#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Imports
#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------

import atexit
import logging
Expand All @@ -22,9 +21,9 @@
from .utils.plugin import IPlugin, get_plugin, discover_plugins


#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Global variables and functions
#------------------------------------------------------------------------------
# ------------------------------------------------------------------------------

__author__ = 'Cyrille Rossant'
__email__ = 'cyrille.rossant at gmail.com'
Expand All @@ -50,4 +49,5 @@ def on_exit(): # pragma: no cover
def test(): # pragma: no cover
"""Run the full testing suite of phy."""
import pytest

pytest.main()
Loading