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

build: use PEP517/518 conventions #100

Merged
merged 80 commits into from
Jan 6, 2021
Merged
Show file tree
Hide file tree
Changes from 76 commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
c3276b4
chore: clean useless comments
deepcharles Dec 29, 2020
a018c4c
style: sort imports
deepcharles Jan 2, 2021
eac0d97
test: add __init__.py to collect coverage
deepcharles Jan 2, 2021
dc75a26
build: adopt PEP 517/518 for setup.py
deepcharles Jan 2, 2021
f59ceb8
build: adopt PEP 517/518 for pyproject.toml
deepcharles Jan 2, 2021
1abd0ae
test: add pytest-cov options in pyproject.toml
deepcharles Jan 2, 2021
1d4b1b6
ci: clean upload-to-pypi gh action
deepcharles Jan 2, 2021
4a517f2
ci: clean check-docs gh action
deepcharles Jan 2, 2021
68a1e9f
ci: clean check-linting gh action
deepcharles Jan 2, 2021
9c15492
ci: clean publish-doc-to-remote gh action
deepcharles Jan 2, 2021
1ec438e
ci: clean run-coverage gh action
deepcharles Jan 2, 2021
135b502
ci: clean run-tests gh action
deepcharles Jan 2, 2021
cf15017
style: remove useless imports
deepcharles Jan 2, 2021
afa2c91
style: remove useless comments
deepcharles Jan 2, 2021
c4f89f4
build: bump version (dev)
deepcharles Jan 2, 2021
61ffa7e
chore: clean useless comments
deepcharles Dec 29, 2020
6c29374
style: sort imports
deepcharles Jan 2, 2021
518d1f0
test: add __init__.py to collect coverage
deepcharles Jan 2, 2021
4b41a22
build: adopt PEP 517/518 for setup.py
deepcharles Jan 2, 2021
aa9bf33
build: adopt PEP 517/518 for pyproject.toml
deepcharles Jan 2, 2021
83f48e8
test: add pytest-cov options in pyproject.toml
deepcharles Jan 2, 2021
2280980
ci: clean upload-to-pypi gh action
deepcharles Jan 2, 2021
0f15fb6
ci: clean check-docs gh action
deepcharles Jan 2, 2021
eb94f7e
ci: clean check-linting gh action
deepcharles Jan 2, 2021
a076817
ci: clean publish-doc-to-remote gh action
deepcharles Jan 2, 2021
45cd32c
ci: clean run-coverage gh action
deepcharles Jan 2, 2021
79efc0d
ci: clean run-tests gh action
deepcharles Jan 2, 2021
cf77355
style: remove useless imports
deepcharles Jan 2, 2021
3cb5153
style: remove useless comments
deepcharles Jan 2, 2021
51f5914
build: bump version (dev)
deepcharles Jan 2, 2021
daec5c2
Merge branch 'better-setup' of https://github.com/deepcharles/rupture…
deepcharles Jan 2, 2021
7bf0d94
test: fix py-coverage options
deepcharles Jan 2, 2021
e92ccf6
chore: clean useless file
deepcharles Jan 2, 2021
e2110f2
ci: correct circleci job
deepcharles Jan 2, 2021
af8bd7f
style: sort imports
deepcharles Jan 2, 2021
5713286
style: sort imports
deepcharles Jan 2, 2021
d9c5002
ci: fix typo
deepcharles Jan 2, 2021
3162fe3
ci: fix typo
deepcharles Jan 2, 2021
c9bc9e9
ci: add verbose when installing ruptures
deepcharles Jan 2, 2021
8e53535
build: update MANIFEST.in
deepcharles Jan 2, 2021
7a5dd86
build: remove one level of verbose
deepcharles Jan 2, 2021
710d80a
build: remove one level of verbose
deepcharles Jan 2, 2021
2ec5081
build: fix typo in MANIFEST.in
deepcharles Jan 2, 2021
a7bf217
build: add test import
deepcharles Jan 2, 2021
0a4657e
fix: relative import
deepcharles Jan 2, 2021
3fc4910
fix: relative import
deepcharles Jan 2, 2021
4f5eb23
fix: relative import
deepcharles Jan 2, 2021
2a8a72f
fix: relative import
deepcharles Jan 2, 2021
deff40c
build: remove verbose
deepcharles Jan 2, 2021
51ca05d
fix: relative import
deepcharles Jan 2, 2021
efd6e88
fix: relative import
deepcharles Jan 2, 2021
e4a5618
chore: test sys.path
deepcharles Jan 2, 2021
b848c39
style: clean debug commands
deepcharles Jan 3, 2021
8ad8f5c
build: fix find_packages
deepcharles Jan 3, 2021
8d50ca6
style: cleaner setup.py
deepcharles Jan 3, 2021
3b7ebba
ci: print find_packages (debug)
deepcharles Jan 3, 2021
a5ef228
ci: print find_packages (debug)
deepcharles Jan 3, 2021
889e134
build: old-fashioned find_packages
deepcharles Jan 3, 2021
a6bb2cc
fix: try different import
deepcharles Jan 3, 2021
753df98
build: change layout (use src folder) in setup.cfg
deepcharles Jan 3, 2021
1d472ba
build: change layout (put package in src/)
deepcharles Jan 3, 2021
ccfe94a
test: cleaner gh action for tests
deepcharles Jan 3, 2021
3342ec0
ci: cleaner install in coverage gh action
deepcharles Jan 3, 2021
51bf186
ci: update covered folder in test coverage
deepcharles Jan 3, 2021
a341809
ci: add pytest-cov to ruptures[test] flavour
deepcharles Jan 3, 2021
4207844
ci: test if pytest-cov is installed
deepcharles Jan 3, 2021
d3b18ea
style: renaming step in gh action
deepcharles Jan 3, 2021
3856879
ci: change arg to collect coverage
deepcharles Jan 3, 2021
ffb3c18
ci: arg to collect coverage
deepcharles Jan 3, 2021
8740008
ci: change pytest-cov argument
deepcharles Jan 3, 2021
81a915e
chore: delete useless files
deepcharles Jan 4, 2021
c92fe3f
style: clean debug statement
deepcharles Jan 4, 2021
e2ebb55
style: clean useless statements in MANIFEST.IN
deepcharles Jan 4, 2021
954d0ec
style: clean .gitignore
deepcharles Jan 4, 2021
07530f6
docs: update CONTRIBUTING.md
deepcharles Jan 4, 2021
1b9a33a
chore: revert .flake8 deletion
deepcharles Jan 4, 2021
24422e9
chore: set the version back to current production version
oboulant Jan 4, 2021
0dd496b
ci: Removing CircleCI
oboulant Jan 4, 2021
e60f584
refactor: removing some dependencies
oboulant Jan 4, 2021
262a694
fix: typo
oboulant Jan 4, 2021
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
20 changes: 6 additions & 14 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "requirements-dev.txt" }}
- v1-dependencies-{{ checksum "pyproject.toml" }}-{{ checksum "setup.cfg" }}-{{ checksum "setup.py" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

Expand All @@ -33,29 +33,21 @@ jobs:
python3 -m venv venv
. venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
python setup.py install


- save_cache:
paths:
- ./venv
key: v1-dependencies-{{ checksum "requirements-dev.txt" }}
key: v1-dependencies-{{ checksum "pyproject.toml" }}-{{ checksum "setup.cfg" }}-{{ checksum "setup.py" }}

# run tests!
# this example uses Django's built-in test-runner
# other common Python testing frameworks include pytest and nose
# https://pytest.org
# https://nose.readthedocs.io
- run:
name: run tests
command: |
. venv/bin/activate
mkdir test-reports
py.test --junitxml=test-reports/junit.xml tests/
python -m pip install .[dev]
python -m pytest
oboulant marked this conversation as resolved.
Show resolved Hide resolved

- store_test_results:
path: test-reports
path: coverage.xml

- store_artifacts:
path: test-reports
path: coverage.xml
11 changes: 3 additions & 8 deletions .github/workflows/check-docs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Pull Request Docs Check"
name: "Check docs"
on:
- pull_request

Expand All @@ -7,19 +7,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.x
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
# Semantic version range syntax or exact version of a Python version
python-version: '3.8'
# You can test your matrix by printing the current Python version
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install ruptures and dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
python setup.py install
python -m pip install .[dev]
- name: Run notebooks
run: |
jupyter nbconvert --inplace --to notebook --ExecutePreprocessor.kernel_name=python --execute $(find ./docs -name '*.ipynb')
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/check-linting.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: check-linting
name: Check linting

on:
push:
Expand All @@ -18,7 +18,7 @@ jobs:
- name: Install pre-commit hooks
run: |
python -m pip install --upgrade pip
pip install pre-commit
python -m pip install pre-commit
- name: Run pre-commit hooks
run: |
pre-commit run --all-files
13 changes: 4 additions & 9 deletions .github/workflows/publish-doc-to-remote.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Publish doc to website on new release (or manual trigger)
name: "docs"
# Publish docs to website on new release (or manual trigger)
name: "Publish docs online"

on:
release:
Expand All @@ -14,23 +14,18 @@ jobs:
- name: Set up Python 3.x
uses: actions/setup-python@v2
with:
# Semantic version range syntax or exact version of a Python version
python-version: '3.8'
# You can test your matrix by printing the current Python version
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install ruptures and dependecies
run: |
python -m pip install --upgrade pip
if [ -f requirements-dev.txt ]; then pip install -r requirements-dev.txt; fi
python setup.py install
python -m pip install .[dev]
- name: Run notebooks
run: |
jupyter nbconvert --inplace --to notebook --ExecutePreprocessor.kernel_name=python --execute $(find ./docs -name '*.ipynb')
- name: Build documentation
run: |
mkdocs build
- name: Publish documentation to remote
- name: Publish documentation to remote repo
uses: selenehyun/gh-push@master
env:
GITHUB_TOKEN: ${{ secrets.DOC_PUSHER_ACCESS_TOKEN }}
Expand Down
22 changes: 9 additions & 13 deletions .github/workflows/run-test-coverage.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# This workflow will install Python dependencies, run tests, generate coverage report and upload it to codecov
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
# This workflow will install Python dependencies, run tests, generate coverage
# report and upload it to codecov.
# For more information, see:
# https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: coverage
name: Run tests with coverage

on:
push:
Expand All @@ -14,26 +16,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.x
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install pytest-cov
- name: Install ruptures
run: |
python setup.py install
python -m pip install --upgrade pip
python -m pip install .[test]
- name: Test with pytest
run: |
pytest --cov-report=xml --cov=ruptures tests/

python -m pytest
- name: Upload to Codecov
run: |
bash <(curl -s https://codecov.io/bash)

- uses: actions/upload-artifact@v2
with:
path: coverage.xml
13 changes: 4 additions & 9 deletions .github/workflows/run-test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: build
name: Run tests

on:
push:
Expand All @@ -18,22 +18,17 @@ jobs:
exclude:
- os: windows-latest
python-version: 3.9

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
- name: Install ruptures
run: |
python setup.py install
python -m pip install --upgrade pip
python -m pip install .[test]
- name: Test with pytest
run: |
pytest
python -m pytest
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish to Pypi (sdist and wheels)
name: Upload package to Pypi

on:
workflow_dispatch:
Expand Down Expand Up @@ -48,9 +48,7 @@ jobs:
- name: Install cibuildwheel and dependencies
run: |
python -m pip install --upgrade pip
python -m pip install cibuildwheel
pip install -r requirements-dev.txt
pip install setuptools wheel twine
python -m pip install cibuildwheel setuptools wheel twine
oboulant marked this conversation as resolved.
Show resolved Hide resolved

- name: Build wheels
env:
Expand All @@ -59,7 +57,7 @@ jobs:
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python -m cibuildwheel --output-dir wheelhouse
twine upload wheelhouse/*.whl
python -m twine upload wheelhouse/*.whl

- uses: actions/upload-artifact@v2
with:
Expand All @@ -69,26 +67,21 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.x
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
# Semantic version range syntax or exact version of a Python version
python-version: '3.8'
# You can test your matrix by printing the current Python version
- name: Display Python version
run: python -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements-dev.txt
pip install setuptools wheel twine
- name: Build
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist
twine upload dist/*.tar.gz
python -m twine upload dist/*.tar.gz
- uses: actions/upload-artifact@v2
with:
path: dist/*.tar.gz
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,4 @@ docs/build/*
.Trashes
ehthumbs.db
Thumbs.db
site/
ruptures/utils/_utils/convert_path_matrix.c
ruptures/detection/_detection/continuous_linear_cpd.c
ruptures/detection/_detection/ekcpd.c
site/
36 changes: 14 additions & 22 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@

In all following steps, it is highly recommended to use a virtual environment.

### Install the requirements

Several packages are needed to compile, format and test the code.
They are listed in `requirements-dev.txt` and can be installed with the following command.

### Install the development version

It is important that you contribute to the latest version of the code.
Expand All @@ -20,33 +15,30 @@ git clone https://github.com/deepcharles/ruptures
cd ruptures
```

Then install the downloaded package.
Then install the downloaded package with `pip`.

```
python -m pip install --verbose --no-build-isolation --editable .
python -m pip install --editable .[dev]
```

#### With pip
```
pip install -r requirements-dev.txt
```
Note that `python -m` can be omitted most of the times, but within virtualenvs, it can prevent certain errors.
Also, in certain terminals (such as zsh), the square brackets must be escaped, e.g. replace `.[dev]` by `.\[dev\]`.

#### With conda
```
conda --file requirements-dev.txt
```

Then run the following command to install the `pre-commit` hooks.
```
pre-commit install
```
In addition to `numpy`, `scipy` and `ruptures`, this command will install all packages needed to develop `ruptures`.
The exact list of librairies can be found in the [`setup.cfg` file](https://github.com/deepcharles/ruptures/blob/master/setup.cfg) (section `[options.extras_require]`).

### Pre-commit hooks

We use `pre-commit` to run Git hooks before submitting the code to review.
These hook scripts perform simple tasks before each commit (code formatting mostly).
To activate the hooks, simply run the following command in your terminal.

```
pre-commit install
```


Note that if you try to commit a non-compliant (i.e. badly formatted) file, `pre-commit` will modify this file and make the commit fail.
If you try to commit a non-compliant (i.e. badly formatted) file, `pre-commit` will modify this file and make the commit fail.
However you need to stage the new changes **yourself** as `pre-commit` will not do that for you (this is by design; see [here](https://github.com/pre-commit/pre-commit/issues/806) or [here](https://github.com/pre-commit/pre-commit/issues/747)).
Fortunately, `pre-commit` outputs useful messages.

Expand All @@ -61,7 +53,7 @@ If you want to manually run all pre-commit hooks on a repository, run `pre-commi
The following command executes the test suite.

```
pytest
python -m pytest
```

### Write docstrings
Expand Down
10 changes: 0 additions & 10 deletions README.rst

This file was deleted.

4 changes: 0 additions & 4 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ nav:
- Binseg: code-reference/detection/binseg-reference.md
- BottomUp: code-reference/detection/bottomup-reference.md
- Window: code-reference/detection/window-reference.md
# - GreedyAR: code-reference/detection/greedyar-reference.md
# - GreedyLinear: code-reference/detection/greedylinear-reference.md
# - Omp: code-reference/detection/omp-reference.md
# - OmpK: code-reference/detection/ompk-reference.md
- Cost functions:
- 'CostL1': code-reference/costs/costl1-reference.md
- 'CostL2': code-reference/costs/costl2-reference.md
Expand Down
11 changes: 10 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[build-system]
# Minimum requirements for the build system to execute.
requires = [
"setuptools",
"setuptools>=38.3.0", # version with most `setup.cfg` bugfixes
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tiny suggestion: I recommend >=42 for use in pyproject.toml. I spend about an hour once debugging a broken build, and it turned out I didn't specify a minimum, and it was grabbing a cached copy of 41.somthing instead of the latest version, which had critical bugs for PEP 517 builds. If you don't make a PEP 517 build, then this is ignored anyway, and if you are building PEP 517, you want 42+ and can always get it. ;) See https://scikit-hep.org/developer/packaging#pep-517518-support-high-priority

PS: Great work on the NumPy requirements, that's what I came here to look at. :)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might have been 40.something, but whatever it was the devs told me to go with 42+.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, we will make the change then!

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See https://scikit-hep.org/developer/packaging#pep-517518-support-high-priority

Nice read!

PS: Great work on the NumPy requirements, that's what I came here to look at. :)

Many thanks! I

"wheel",
"Cython>=0.28.5",

Expand All @@ -28,3 +28,12 @@ requires = [

"scipy>=0.19.1",
]
build-backend = "setuptools.build_meta"

# pytest config
# For more information, see:
# https://docs.pytest.org/en/stable/customize.html#pyproject-toml
[tool.pytest.ini_options]
minversion = "6.0"
addopts = "--cov-report=xml --cov-report=term:skip-covered --cov=ruptures"
testpaths = ["tests"]
16 changes: 0 additions & 16 deletions ruptures/__init__.py

This file was deleted.

Loading