Skip to content

Commit

Permalink
Merge pull request #163 from vintasoftware/pipenv
Browse files Browse the repository at this point in the history
Use Pipenv instead of requirements.txt to manage dependencies
  • Loading branch information
devkeith7 committed Dec 18, 2017
2 parents b4df5a1 + 1a7db12 commit 1bc8c06
Show file tree
Hide file tree
Showing 8 changed files with 85 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
pass_filenames: true
- id: missing-migrations
name: missing-migrations-local
entry: python manage.py has_missing_migrations
entry: pipenv run python manage.py has_missing_migrations
language: system
always_run: true
pass_filenames: false
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ clean:
@find . -name "__pycache__" -delete

test:
python manage.py test $(ARG) --parallel --keepdb
pipenv run python manage.py test $(ARG) --parallel --keepdb

testreset:
python manage.py test $(ARG) --parallel
pipenv run python manage.py test $(ARG) --parallel
46 changes: 46 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[[source]]

url = "https://pypi.python.org/simple"
verify_ssl = true
name = "pypi"


[dev-packages]
django-debug-toolbar = "*"
django-debug-toolbar-request-history = "*"
django-naomi = "*"
fixmydjango = "*"
model-mommy = "*"
pre_commit = "*"



[packages]

Django = ">=1,<2"
celery = {extras = ["redis"]}
django-model-utils = "*"
django-webpack-loader = "*"
django-js-reverse = "*"
django-import-export = "*"
python-decouple = "*"
"psycopg2" = "*"
brotlipy = "*"
django-log-request-id = "*"
dj-database-url = "*"
gunicorn = "*"
opbeat = "*"
whitenoise = "*"
bandit = "*"
coverage = "*"
astroid = "<1.6"
pylint = "<1.8"
prospector = {extras = ["with-vulture"]}
isort = "*"
safety = "*"
ipython = "*"


[requires]

python_version = "3.6"
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ This is a good starting point for modern Python/JavaScript web projects.
django-admin startproject theprojectname --extension py,yml,json --name Procfile,README.md,.env.example --template=https://github.com/vintasoftware/django-react-boilerplate/archive/boilerplate-release.zip
```
- [ ] Above: don't forget the `--extension` and `--name` params!
- [ ] `pip install -r requirements-to-freeze.txt`
- [ ] `pip freeze > requirements.txt`
- [ ] Install pipenv if not installed yet: `pip install pipenv` (maybe you have to run this command as an OS superuser)
- [ ] Make sure you have Python 3.6 installed
- [ ] `pipenv install --dev`
- [ ] Activate the newly created virtualenv with `pipenv shell`
- [ ] `npm update --save`
- [ ] `npm update --save-dev`
- [ ] Check for outdated npm dependencies with `npm outdated` and update them
Expand All @@ -56,9 +58,10 @@ After completing ALL of the above, remove this `Project bootstrap` section from
- Setup [editorconfig](http://editorconfig.org/), [prospector](https://prospector.landscape.io/en/master/) and [ESLint](http://eslint.org/) in the text editor you will use to develop.

### Running the project
- `pip install -r requirements.txt`
- `pipenv install --dev`
- `npm install`
- `npm run start`
- `pipenv shell`
- `python manage.py runserver`

### Testing
Expand All @@ -69,7 +72,7 @@ Will run django tests using `--keepdb` and `--parallel`. You may pass a path to
`make test someapp.tests.test_views`

### Adding new pypi libs
Add high level dependecies to `requirements-to-freeze.txt` and `pip freeze > requirements.txt`. This is [A Better Pip Workflow](http://www.kennethreitz.org/essays/a-better-pip-workflow).
Just run `pipenv install LIB_NAME_ON_PYPI` and then `pipenv lock` to lock the version in Pipfile.lock file

## Linting
- Manually with `prospector` and `npm run lint` on project root.
Expand Down
2 changes: 1 addition & 1 deletion bin/run_collectstatic
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ MANAGE_FILE=${MANAGE_FILE:2}
echo "-----> Collecting static files"
python $MANAGE_FILE collectstatic --noinput 2>&1 | sed '/^Copying/d;/^$/d;/^ /d' | indent

echo
echo
22 changes: 12 additions & 10 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,19 @@ machine:
version: 3.6.0
node:
version: 6.1.0
environment:
PIPENV_IGNORE_VIRTUALENVS: True
PIPENV_DONT_LOAD_ENV: 0

dependencies:
post:
- pip install django
- pip install virtualenv
- django-admin startproject testproject --extension py,yml,json --name Procfile,README.md --template=.
- pip install requests pipenv --upgrade

test:
override:
- virtualenv testproject/venv
- source testproject/venv/bin/activate
- pip install -r requirements-to-freeze.txt:
- pipenv install --dev:
pwd: testproject
- npm update --save:
pwd: testproject
Expand All @@ -33,17 +35,17 @@ test:
pwd: testproject
- cp testproject/testproject/settings/local.py.example testproject/testproject/settings/local.py
- echo 'DJANGO_SETTINGS_MODULE="testproject.settings.local"' > testproject/.env
- python manage.py makemigrations:
- pipenv run python manage.py makemigrations:
pwd: testproject
- python manage.py migrate:
- pipenv run python manage.py migrate:
pwd: testproject
- python manage.py test:
- pipenv run python manage.py test:
pwd: testproject
- prospector:
- pipenv run prospector:
pwd: testproject
- python manage.py has_missing_migrations:
- pipenv run python manage.py has_missing_migrations:
pwd: testproject
- SECRET_KEY="$(python -c "import uuid; print(uuid.uuid4().hex + uuid.uuid4().hex)")" SENDGRID_USERNAME='foo' SENDGRID_PASSWORD='password' DJANGO_SETTINGS_MODULE='testproject.settings.production' DATABASE_URL='sqlite:///' ALLOWED_HOSTS='.example.org' REDIS_URL='redis://' python manage.py check --deploy --fail-level WARNING:
- SECRET_KEY="$(python -c "import uuid; print(uuid.uuid4().hex + uuid.uuid4().hex)")" SENDGRID_USERNAME='foo' SENDGRID_PASSWORD='password' DJANGO_SETTINGS_MODULE='testproject.settings.production' DATABASE_URL='sqlite:///' ALLOWED_HOSTS='.example.org' REDIS_URL='redis://' pipenv run python manage.py check --deploy --fail-level WARNING:
pwd: testproject
- npm run test:
pwd: testproject
Expand Down
26 changes: 16 additions & 10 deletions proj_circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,36 @@ machine: # remeber to update those!
version: 3.6.0
node:
version: 6.1.0
environment:
# makes default virtualenv be ignored by pipenv avoiding dependencies conflict
PIPENV_IGNORE_VIRTUALENVS: True

dependencies:
pre:
# this updates git-lfs to make pre-commit large files check hook work properly
# more details in https://github.com/pre-commit/pre-commit-hooks/issues/252
- curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
- sudo apt-get install git-lfs --upgrade
post:
- pip install requests pipenv --upgrade
- pipenv install --dev

test:
override:
- npm run build
- npm run lint
# style check
- prospector
- pipenv run prospector
# security checks
- bandit -r .
- cat requirements.txt | safety check --stdin
- pipenv run bandit -r .
- pipenv run pip freeze | safety check --stdin
# imports check
- isort **/*.py --check-only
- pipenv run isort **/*.py --check-only
# pre-commit additional checks
- SKIP=prospector,isort,eslint,missing-migrations pre-commit run --all-files
- SKIP=prospector,isort,eslint,missing-migrations pipenv run pre-commit run --all-files
- >-
DJANGO_SETTINGS_MODULE={{project_name}}.settings.local_base
python manage.py has_missing_migrations --ignore authtools;
pipenv run python manage.py has_missing_migrations --ignore authtools;
- >-
DJANGO_SETTINGS_MODULE={{project_name}}.settings.production
SECRET_KEY=$(python -c 'import uuid; print(uuid.uuid4().hex + uuid.uuid4().hex)')
Expand All @@ -34,12 +41,11 @@ test:
SENDGRID_USERNAME='test'
SENDGRID_PASSWORD='test'
REDIS_URL='redis://'
python manage.py check --deploy
- coverage run manage.py test
pipenv run python manage.py check --deploy
- pipenv run coverage run manage.py test
- npm run test
- npm run lint
post:
- coverage html -d $CIRCLE_ARTIFACTS
- pipenv run coverage html -d $CIRCLE_ARTIFACTS

# This is necessary for the boilerplate's CI. You can remove these lines
general:
Expand Down
35 changes: 0 additions & 35 deletions requirements-to-freeze.txt

This file was deleted.

0 comments on commit 1bc8c06

Please sign in to comment.