Skip to content

Commit a47618c

Browse files
TrybneticderNarr
andauthored
Adds support for pypoetry (https://python-poetry.org) (#222)
* introduces python poetry to maintain and build the package * allows building wheels for PyPI (fixes #212) * uses `pyproject.toml` instead of `setup.py` and thus fixes #143 and fixes #137 * sets up Github Actions for general testing (replaces Travis) * bumps version to 1.0.0-beta Co-authored-by: Konstantin (Tino) Sering <[email protected]>
1 parent dc5acf7 commit a47618c

21 files changed

+317
-457
lines changed

.github/workflows/python-test.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Linux & OSX tests
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
build:
13+
name: ${{ matrix.os }} ${{ matrix.python-version }}
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest, macOS-latest]
17+
python-version: ['3.8', '3.10']
18+
poetry-version: [1.1.13]
19+
fail-fast: false
20+
runs-on: ${{ matrix.os }}
21+
steps:
22+
- uses: actions/checkout@v2
23+
24+
- name: Set up Python ${{ matrix.python-version }}
25+
uses: actions/setup-python@v2
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
29+
- name: Get full Python version
30+
id: full-python-version
31+
run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")
32+
33+
- name: Setup poetry
34+
uses: abatilo/[email protected]
35+
with:
36+
poetry-version: ${{ matrix.poetry-version }}
37+
38+
- name: Update PATH
39+
if: ${{ runner.os != 'Windows' }}
40+
run: echo "$HOME/.local/bin" >> $GITHUB_PATH
41+
42+
- name: Update Path for Windows
43+
if: ${{ runner.os == 'Windows' }}
44+
run: echo "$APPDATA\Python\Scripts" >> $GITHUB_PATH
45+
46+
- name: Configure poetry
47+
run: poetry config virtualenvs.in-project true
48+
49+
- name: Set up cache
50+
uses: actions/cache@v2
51+
id: cache
52+
with:
53+
path: .venv
54+
key: venv-cache-${{ runner.os }}-${{ steps.full-python-version.outputs.version }}-${{ hashFiles('**/poetry.lock') }}
55+
56+
- name: Install dependencies
57+
run: poetry install
58+
59+
- name: Run linux tests
60+
if: ${{ runner.os == 'Linux' }}
61+
run: poetry run pytest --cov=pyndl --cov-report=xml --disable-pytest-warnings
62+
63+
- name: Run tests on other distributions (skip linux-only tests)
64+
if: ${{ runner.os != 'Linux' }}
65+
run: poetry run pytest --no-linux
66+
67+
- name: Upload coverage to Codecov
68+
uses: codecov/codecov-action@v2
69+
with:
70+
file: ./coverage.xml
71+
flags: unittests
72+
env_vars: OS,PYTHON

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pyndl/ndl_parallel.c
33
pyndl/ndl_openmp.c
44
pyndl/corr_parallel.c
55
pyndl/wh_parallel.c
6+
pyndl/correlation_openmp.c
67
latex/
78
*.pyc
89
__pycache__/
@@ -28,4 +29,7 @@ doc/data/levent.tab.filtered
2829
doc/data/weights.nc
2930

3031
# copybutton js script
31-
doc/source/_static/copybutton.js
32+
copybutton.js
33+
34+
# pypoetry
35+
poetry.lock

.readthedocs.yml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
1+
# .readthedocs.yaml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Set the version of Python and other tools you might need
9+
build:
10+
os: ubuntu-20.04
11+
tools:
12+
python: "3.9"
13+
14+
# Build documentation in the docs/ directory with Sphinx
15+
sphinx:
16+
configuration: doc/source/conf.py
17+
18+
# If using Sphinx, optionally build your docs in additional formats such as PDF
19+
formats: all
20+
21+
# Optionally declare the Python requirements required to build your docs
122
python:
2-
setup_py_install: true
3-
pip_install: true
4-
extra_requirements:
5-
- docs
23+
install:
24+
- path: .
25+
- requirements: doc/requirements.txt

.travis.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

MANIFEST.in

Lines changed: 0 additions & 16 deletions
This file was deleted.

Makefile

Lines changed: 0 additions & 28 deletions
This file was deleted.

README.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
Pyndl - Naive Discriminative Learning in Python
33
===============================================
44

5-
.. image:: https://travis-ci.com/quantling/pyndl.svg?branch=master
6-
:target: https://travis-ci.com/quantling/pyndl
5+
.. image:: https://github.com/quantling/pyndl/actions/workflows/python-test.yml/badge.svg?branch=master
6+
:target: https://github.com/quantling/pyndl/actions/workflows/python-test.yml
77

8-
.. image:: https://coveralls.io/repos/github/quantling/pyndl/badge.svg?branch=master
9-
:target: https://coveralls.io/github/quantling/pyndl?branch=master
8+
.. image:: https://codecov.io/gh/quantling/pyndl/branch/master/graph/badge.svg?token=2GWUXRA9PD
9+
:target: https://codecov.io/gh/quantling/pyndl
1010

1111
.. image:: https://img.shields.io/lgtm/grade/python/g/quantling/pyndl.svg?logo=lgtm&logoWidth=18
1212
:target: https://lgtm.com/projects/g/quantling/pyndl/context:python
@@ -87,4 +87,3 @@ Acknowledgments
8787
This research was supported by an ERC advanced Grant (no. 742545) and by the
8888
Alexander von Humboldt Professorship awarded to R. H. Baayen and by the
8989
University of Tübingen.
90-

setup.py renamed to build.py

Lines changed: 13 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from setuptools import setup, Extension
1+
from setuptools import Extension
22
from setuptools.command.build_ext import build_ext as _build_ext
33
import sys
44

@@ -9,27 +9,11 @@ class build_ext(_build_ext):
99
def finalize_options(self):
1010
_build_ext.finalize_options(self)
1111
# Prevent numpy from thinking it is still in its setup process:
12-
__builtins__.__NUMPY_SETUP__ = False
12+
#__builtins__.__NUMPY_SETUP__ = False
1313
import numpy
1414
self.include_dirs.append(numpy.get_include())
1515

1616

17-
pkg = __import__('pyndl')
18-
19-
author = pkg.__author__
20-
email = pkg.__author_email__
21-
22-
version = pkg.__version__
23-
classifiers = pkg.__classifiers__
24-
25-
description = pkg.__description__
26-
27-
def load_requirements(fn):
28-
"""Read a requirements file and create a list that can be used in setup."""
29-
with open(fn, 'r') as f:
30-
return [x.rstrip() for x in list(f) if x and not x.startswith('#')]
31-
32-
3317
ndl_parallel = Extension("pyndl.ndl_parallel", ["pyndl/ndl_parallel.pyx"])
3418
ndl_openmp = Extension("pyndl.ndl_openmp", ["pyndl/ndl_openmp.pyx"],
3519
extra_compile_args=['-fopenmp'], extra_link_args=['-fopenmp'])
@@ -46,30 +30,14 @@ def load_requirements(fn):
4630
elif sys.platform.startswith('darwin'):
4731
ext_modules = [ndl_parallel] # skip openmp installation on macos for now
4832

49-
setup(
50-
name='pyndl',
51-
version=version,
52-
license='MIT',
53-
description=description,
54-
long_description=open('README.rst', encoding="utf-8").read(),
55-
author=author,
56-
author_email=email,
57-
url='https://github.com/quantling/pyndl',
58-
classifiers=classifiers,
59-
platforms='Linux',
60-
packages=['pyndl'],
61-
setup_requires=['numpy', 'cython'],
62-
install_requires=load_requirements('requirements.txt'),
63-
extras_require={
64-
'tests': [
65-
'pylint',
66-
'pytest',
67-
'pycodestyle'],
68-
'docs': [
69-
'sphinx >= 1.4',
70-
'sphinx_rtd_theme',
71-
'numpydoc',
72-
'easydev']},
73-
ext_modules=ext_modules,
74-
cmdclass={'build_ext': build_ext}
75-
)
33+
34+
def build(setup_kwargs):
35+
"""
36+
This function is mandatory in order to build the extensions.
37+
"""
38+
setup_kwargs.update({
39+
'ext_modules': ext_modules,
40+
'cmdclass': {
41+
'build_ext': build_ext
42+
}
43+
})

doc/requirements.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
sphinx>=1.4
2+
sphinx_rtd_theme>=1.0.0
3+
notebook>=6.4.10
4+
seaborn>=0.11.2
5+
numpydoc>=1.2
6+
easydev>=0.9.35
7+
nbsphinx>=0.8.8

doc/source/about.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ Authors
77
*pyndl* was mainly developed by
88
`Konstantin Sering <https://github.com/derNarr>`_,
99
`Marc Weitz <https://github.com/trybnetic>`_,
10-
`David-Elias Künstle <https://github.com/dekuenstle/>`_
11-
and `Lennart Schneider <https://github.com/sumny>`_. For the full list of
10+
`David-Elias Künstle <https://github.com/dekuenstle/>`_,
11+
`Lennart Schneider <https://github.com/sumny>`_ and
12+
`Elnaz Shafaei-Bajestan <https://github.com/elnazsh>`_. For the full list of
1213
contributors have a look at `Github's Contributor summary
1314
<https://github.com/quantling/pyndl/contributors>`_.
1415

0 commit comments

Comments
 (0)