Skip to content

Commit

Permalink
Use pipenv
Browse files Browse the repository at this point in the history
  • Loading branch information
kirkedev committed Mar 9, 2020
1 parent 683257e commit f68394a
Show file tree
Hide file tree
Showing 10 changed files with 511 additions and 49 deletions.
32 changes: 8 additions & 24 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,15 @@
language: minimal
dist: bionic
language: python
python:
- "3.6"
- "3.7"
- "3.8"

env:
global:
- CONDA_HOME=$HOME/miniconda
- CONDA_PKGS_DIRS=$HOME/.conda_pkgs
- PATH=./bin:$CONDA_HOME/bin:$PATH

before_install:
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
- bash miniconda.sh -b -p $CONDA_HOME
- hash -r
- conda config --set always_yes yes --set changeps1 no --set auto_update_conda false
- conda update -q conda
- conda info -a

install: conda env create -f environment.yml
before_script: source activate mpr
script: tox

before_cache: find $CONDA_PKGS_DIRS -mindepth 1 -maxdepth 1 -type d -exec rm -rf {} \;
before_install: pip install pipenv
install: pipenv install --dev
script: bin/check

cache:
- pip
- directories:
- $CONDA_PKGS_DIRS

after_success: coveralls

before_deploy: build
24 changes: 24 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[requires]
python_version = "3.7"

[packages]
aiohttp = "*"
numpy = "*"
pandas = "*"
pytz = "*"
isoweek = "*"

[dev-packages]
behave = "*"
coverage = "*"
coveralls = "*"
flake8 = "*"
pytest = "*"
pytest-asyncio = "*"
setuptools = "*"
tox = "*"
461 changes: 461 additions & 0 deletions Pipfile.lock

Large diffs are not rendered by default.

19 changes: 5 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,17 @@ See examples in the [examples notebook](examples.ipynb)
- Builds a dynamic timeseries filesystem cache of requested data
- Aggregates data into common reports as pandas DataFrames

See examples in the [examples notebook](examples.ipynb)
See example usage in the [examples notebook](examples.ipynb)

### Setup
This project uses [conda](https://conda.io/en/latest/miniconda.html). Install python packages and activate environment:
```bash
conda env create -f environment.yml
conda activate mpr
```

It's a good idea to use something like [direnv](https://direnv.net/) to activate the conda environment and add the scripts in `bin` to your path.

My `.envrc` file looks like this:
This project uses [pipenv](https://pipenv-fork.readthedocs.io/en/latest/install.html#installing-pipenv). Install python packages and activate environment:
```bash
export PATH=$PATH:./bin
source $HOME/miniconda3/etc/profile.d/conda.sh
conda activate mpr
pip install --user pipenv
pipenv install
```

### Commands
These all need to be run from the project root. If using direnv and an envrc like above, you can omit the path and run the script directly, eg: `tests`.
These all need to be run from the project root.

```bash
# View CME Lean Hog Index report for last 20 days
Expand Down
2 changes: 1 addition & 1 deletion bin/cash
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
python3 -m mpr.cash_index "$@"
pipenv run python3 -m mpr.cash_index "$@"
11 changes: 6 additions & 5 deletions bin/check
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
export MPR_SERVER='http://localhost:8080'

set -e
lint
coverage run --parallel-mode --source=mpr -m pytest
coverage run --parallel-mode --source=mpr -m behave -m --tags="-pending"
pipenv run flake8
pipenv run coverage erase
pipenv run coverage run --parallel-mode -m pytest
pipenv run coverage run --parallel-mode -m behave -m --tags="-pending"
echo
coverage combine
coverage report
pipenv run coverage combine
pipenv run coverage report
echo
2 changes: 1 addition & 1 deletion bin/cutout
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
python3 -m mpr.cutout_index "$@"
pipenv run python3 -m mpr.cutout_index "$@"
2 changes: 1 addition & 1 deletion bin/lint
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
flake8
pipenv run flake8
2 changes: 1 addition & 1 deletion bin/purchases
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/usr/bin/env bash
python3 -m mpr.purchase_index "$@"
pipenv run python3 -m mpr.purchase_index "$@"
5 changes: 3 additions & 2 deletions bin/tests
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ export MPR_SERVER='http://localhost:8080'

set -e
lint
coverage run -m pytest
pipenv run coverage erase
pipenv run coverage run -m pytest
echo
coverage report
pipenv run coverage report
echo

0 comments on commit f68394a

Please sign in to comment.