Skip to content

Commit a0b2b44

Browse files
committed
Update build systems
- Add Makefile with targets for common development commands. - Use/enforce isort. Repair sort order in various code files. - Update .travis.yml to use latest linux dist - Just use requirements.txt for development requirements. setup.py captures installation requirements.
1 parent 66a0e40 commit a0b2b44

File tree

18 files changed

+139
-79
lines changed

18 files changed

+139
-79
lines changed

.travis.yml

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,40 @@
1-
dist: xenial
21
language: python
2+
os: linux
3+
dist: bionic
34
cache: pip
45

5-
matrix:
6+
python:
7+
- '3.8'
8+
- '3.7'
9+
- '3.6'
10+
- '2.7'
11+
- 'pypy3'
12+
- 'nightly'
13+
14+
env:
15+
- MAKE_TARGET=test
16+
17+
jobs:
618
include:
7-
- python: '2.7'
8-
env:
9-
- COVERAGE=--cov
10-
- FLAKE8=--flake8
11-
- python: 'pypy2.7-6.0'
12-
- python: '3.4'
13-
- python: '3.5'
14-
- python: '3.6'
15-
- python: '3.7'
16-
env:
17-
- COVERAGE=--cov
18-
- FLAKE8=--flake8
19-
- python: 'pypy3.5-6.0'
20-
- python: '3.8-dev'
21-
- python: 'nightly'
19+
- python: '3.8'
20+
env: MAKE_TARGET=lint
21+
- python: '3.8'
22+
env: MAKE_TARGET=coverage
2223
allow_failures:
23-
- python: '3.8-dev'
2424
- python: 'nightly'
2525

2626
install:
27-
- pip install -r requirements-dev.txt
28-
- if [ -n "$COVERAGE" ]; then pip install coveralls; fi
29-
- pip install -e .
27+
- |
28+
if [ "$MAKE_TARGET" = "coverage" ]; then
29+
pip install coveralls
30+
fi
31+
- pip install --upgrade -r requirements.txt -e .
3032

3133
script:
32-
- py.test $FLAKE8 $COVERAGE
34+
- make "$MAKE_TARGET"
3335

3436
after_success:
35-
- if [ -n "$COVERAGE" ]; then coveralls; fi
37+
- |
38+
if [ "$MAKE_TARGET" = "coverage" ]; then
39+
coveralls
40+
fi

Makefile

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
PYTHON ?= python
2+
3+
.PHONY: lint
4+
lint: lint-isort lint-flake8
5+
6+
.PHONY: lint-isort
7+
lint-isort:
8+
isort --check-only --quiet --diff --recursive .
9+
10+
.PHONY: lint-flake8
11+
lint-flake8:
12+
flake8 .
13+
14+
.PHONY: format
15+
format: format-isort
16+
17+
.PHONY: format-isort
18+
format-isort:
19+
isort --recursive .
20+
21+
.PHONY: test
22+
test:
23+
pytest
24+
25+
.PHONY: coverage
26+
coverage:
27+
pytest --cov
28+
29+
.PHONY: docs
30+
docs:
31+
$(MAKE) -C docs html
32+
33+
.PHONY: build
34+
build:
35+
$(PYTHON) setup.py build
36+
37+
.PHONY: dist
38+
dist:
39+
$(PYTHON) setup.py sdist bdist_wheel

desmod/probe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import simpy
44
import six
55

6-
from desmod.queue import Queue
76
from desmod.pool import Pool
7+
from desmod.queue import Queue
88

99

1010
def attach(scope, target, callbacks, **hints):

desmod/progress.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
from __future__ import print_function, division
1+
from __future__ import division, print_function
2+
23
from collections import OrderedDict
34
from contextlib import contextmanager
45
from datetime import datetime, timedelta
56
import sys
67
import timeit
78

9+
from desmod.timescale import parse_time, scale_time
10+
811
try:
912
import progressbar
1013
except ImportError:
@@ -14,8 +17,6 @@
1417
except ImportError:
1518
colorama = None
1619

17-
from desmod.timescale import parse_time, scale_time
18-
1920

2021
@contextmanager
2122
def standalone_progress_manager(env):

desmod/simulation.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
"""Simulation model with batteries included."""
22

33
from __future__ import division
4+
45
from contextlib import closing
5-
from multiprocessing import cpu_count, Process, Queue
6+
from multiprocessing import Process, Queue, cpu_count
67
from pprint import pprint
7-
from six.moves import filter
88
from threading import Thread
9-
109
import json
1110
import os
1211
import random
1312
import shutil
1413
import timeit
1514

15+
from six.moves import filter
1616
import simpy
1717
import six
1818
import yaml
1919

2020
from desmod.config import factorial_config
21-
from desmod.progress import (standalone_progress_manager,
22-
get_multi_progress_manager,
23-
consume_multi_progress)
21+
from desmod.progress import (
22+
consume_multi_progress,
23+
get_multi_progress_manager,
24+
standalone_progress_manager,
25+
)
2426
from desmod.timescale import parse_time, scale_time
2527
from desmod.tracer import TraceManager
2628

desmod/timescale.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from __future__ import division
2+
23
import re
34

45
_unit_map = {'s': 1e0,

desmod/tracer.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
from __future__ import print_function
2+
23
import os
34
import re
45
import sqlite3
56
import sys
67
import traceback
78

8-
import simpy
99
from vcd import VCDWriter
10+
import simpy
1011

1112
from . import probe
12-
from .util import partial_format
13-
from .timescale import parse_time, scale_time
14-
from .queue import Queue
1513
from .pool import Pool
14+
from .queue import Queue
15+
from .timescale import parse_time, scale_time
16+
from .util import partial_format
1617

1718

1819
class Tracer(object):

docs/examples/gas_station/gas_station.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@
1818

1919
from itertools import count, cycle
2020

21+
from simpy import Resource
22+
2123
from desmod.component import Component
2224
from desmod.dot import generate_dot
2325
from desmod.pool import Pool
2426
from desmod.queue import Queue
2527
from desmod.simulation import simulate
26-
from simpy import Resource
2728

2829

2930
class Top(Component):

docs/examples/grocery/grocery.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,21 @@
1212
1313
"""
1414
from __future__ import division
15+
1516
from argparse import ArgumentParser
1617
from datetime import timedelta
1718
from functools import partial
1819
from itertools import count
1920

20-
from desmod.config import apply_user_overrides, parse_user_factors
21+
from simpy import Container, Resource
22+
from vcd.gtkw import GTKWSave
23+
2124
from desmod.component import Component
25+
from desmod.config import apply_user_overrides, parse_user_factors
2226
from desmod.dot import generate_dot
2327
from desmod.queue import Queue
2428
from desmod.simulation import simulate, simulate_factors
2529

26-
from simpy import Container, Resource
27-
from vcd.gtkw import GTKWSave
28-
2930

3031
class Top(Component):
3132
"""The top-level component of the model."""

requirements-dev.txt

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

0 commit comments

Comments
 (0)