Skip to content

Commit 7fac5ac

Browse files
authored
Merge pull request #17 from ddelange/ci-cd
Prepare for release
2 parents 4913b5b + 3580434 commit 7fac5ac

File tree

12 files changed

+119
-2391
lines changed

12 files changed

+119
-2391
lines changed

.gitattributes

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/CD.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This workflows will upload a Python Package using Twine when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
name: CD
5+
6+
on:
7+
release:
8+
types: [created]
9+
10+
jobs:
11+
deploy:
12+
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
with:
18+
fetch-depth: 0
19+
- name: Set up Python
20+
uses: actions/setup-python@v2
21+
with:
22+
python-version: '3.x'
23+
- name: Install dependencies
24+
run: |
25+
pip install -U pip setuptools wheel
26+
pip install setuptools wheel twine
27+
- name: Build and publish
28+
env:
29+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
30+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
31+
run: |
32+
python setup.py sdist bdist_wheel --universal
33+
twine upload dist/*

.github/workflows/CI.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: CI
5+
on:
6+
pull_request:
7+
push:
8+
branches: master
9+
10+
jobs:
11+
build:
12+
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
python-version: [2.7, 3.4, 3.5, 3.6, 3.7, 3.8]
17+
18+
steps:
19+
- uses: actions/checkout@v2
20+
with:
21+
fetch-depth: 0
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
- name: Install dependencies
27+
run: |
28+
pip install -U pip setuptools wheel
29+
pip install pytest flake8 'mock ; python_version < "3"' -e .
30+
- name: Lint with flake8
31+
run: |
32+
# stop the build if there are Python syntax errors or undefined names
33+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
34+
- name: Test with pytest
35+
run: |
36+
pytest -s --strict -vv --cache-clear --maxfail=1

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,6 @@ docs/_build/
5555

5656
# PyBuilder
5757
target/
58+
59+
# setuptools_scm
60+
autotime/_version.py

MANIFEST.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include versioneer.py
2-
include autotime/_version.py
1+
global-exclude *
2+
include autotime/*.py
33
include LICENSE
44
include README.md

README.md

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,31 @@ Time everything in IPython
33

44
## Installation:
55

6-
```
6+
```console
77
$ pip install ipython-autotime
88
```
99

1010
## Examples
1111

1212
```python
1313
In [1]: %load_ext autotime
14-
time: 1433692.87 s
14+
time: 295 µs
1515

1616
In [2]: x = 1
17-
time: 730.99 us
18-
19-
In [3]: x + 2
20-
Out[3]: 3
21-
time: 2.50 ms
17+
time: 519 µs
2218

23-
In [4]: x + ''
19+
In [3]: x / 0
2420
---------------------------------------------------------------------------
25-
TypeError Traceback (most recent call last)
26-
<ipython-input-5-bde712cacec5> in <module>()
27-
----> 1 x + ''
21+
ZeroDivisionError Traceback (most recent call last)
22+
<ipython-input-3-034eb0c6102b> in <module>
23+
----> 1 x/0
2824

29-
TypeError: unsupported operand type(s) for +: 'int' and 'str'
30-
time: 156.05 ms
25+
ZeroDivisionError: division by zero
26+
time: 79.7 ms
3127
```
3228

3329
## Want to turn it off?
3430

3531
```python
36-
In [5]: %unload_ext autotime
32+
In [4]: %unload_ext autotime
3733
```

autotime/__init__.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from __future__ import print_function
22

3+
from ._version import version as __version__
4+
35
try:
46
from time import monotonic
57
except ImportError:
@@ -9,7 +11,6 @@
911

1012

1113
class LineWatcher(object):
12-
1314
"""Class that implements a basic timer.
1415
1516
Notes
@@ -27,19 +28,17 @@ def stop(self):
2728

2829

2930
timer = LineWatcher()
31+
start = timer.start
32+
stop = timer.stop
3033

3134

3235
def load_ipython_extension(ip):
33-
timer.start()
34-
ip.events.register('pre_run_cell', timer.start)
35-
ip.events.register('post_run_cell', timer.stop)
36+
start()
37+
ip.events.register('pre_run_cell', start)
38+
ip.events.register('post_run_cell', stop)
3639

3740

3841
def unload_ipython_extension(ip):
39-
ip.events.unregister('pre_run_cell', timer.start)
40-
ip.events.unregister('post_run_cell', timer.stop)
41-
42+
ip.events.unregister('pre_run_cell', start)
43+
ip.events.unregister('post_run_cell', stop)
4244

43-
from ._version import get_versions
44-
__version__ = get_versions()['version']
45-
del get_versions

0 commit comments

Comments
 (0)