Skip to content

Commit

Permalink
Run make dev in tox
Browse files Browse the repository at this point in the history
Change `make dev` to run h in a tox-managed virtualenv, rather than
running it inside a virtualenv that the developer has to create,
activate, and install the necessary dependencies into.

Developers can now just install make and tox (these just have to be
installed once system-wide, not per project) and then run `make dev`,
without having created or activated a virtualenv, and tox will do
everything for them.

Also reduces differences between different dev environments and between
dev and prod.
  • Loading branch information
seanh committed Sep 28, 2018
1 parent d52b5cf commit 272824c
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 63 deletions.
1 change: 0 additions & 1 deletion .gitignore
Expand Up @@ -17,7 +17,6 @@ mail/
.eggs/
*.egg
*.egg-info
.pydeps
.pytest_cache

# development TLS cert/key
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -50,6 +50,7 @@ matrix:
- env: ACTION=backend-lint
language: python
python: '3.6'
install: pip install tox
script:
make lint

Expand Down
25 changes: 3 additions & 22 deletions Makefile
Expand Up @@ -2,13 +2,6 @@ DOCKER_TAG = dev

GULP := node_modules/.bin/gulp

# Unless the user has specified otherwise in their environment, it's probably a
# good idea to refuse to install unless we're in an activated virtualenv.
ifndef PIP_REQUIRE_VIRTUALENV
PIP_REQUIRE_VIRTUALENV = 1
endif
export PIP_REQUIRE_VIRTUALENV

.PHONY: default
default: test

Expand All @@ -20,14 +13,13 @@ build/manifest.json: node_modules/.uptodate
clean:
find . -type f -name "*.py[co]" -delete
find . -type d -name "__pycache__" -delete
rm -f node_modules/.uptodate .pydeps
rm -f node_modules/.uptodate
rm -rf build

## Run the development H server locally
.PHONY: dev
dev: build/manifest.json .pydeps
@bin/hypothesis --dev init
@bin/hypothesis devserver
dev: build/manifest.json
tox -e dev

## Build hypothesis/hypothesis docker image
.PHONY: docker
Expand Down Expand Up @@ -57,7 +49,6 @@ run-docker:
## Run test suite
.PHONY: test
test: node_modules/.uptodate
@pip install -q tox
tox
$(GULP) test

Expand All @@ -71,32 +62,22 @@ lint:

.PHONY: docs
docs:
@pip install -q tox
tox -e docs

.PHONY: checkdocs
checkdocs:
@pip install -q tox
tox -e checkdocs

.PHONY: docstrings
docstrings:
@pip install -q tox
tox -e docstrings

.PHONY: checkdocstrings
checkdocstrings:
@pip install -q tox
tox -e checkdocstrings

################################################################################

# Fake targets to aid with deps installation
.pydeps: requirements.txt requirements-dev.in
@echo installing python dependencies
@pip install -r requirements-dev.in tox
@touch $@

node_modules/.uptodate: package.json
@echo installing javascript dependencies
@node_modules/.bin/check-dependencies 2>/dev/null || npm install
Expand Down
48 changes: 8 additions & 40 deletions docs/developing/install.rst
Expand Up @@ -33,25 +33,25 @@ Install the following packages:
sudo apt-get install -y --no-install-recommends \
build-essential \
git \
tox \
libevent-dev \
libffi-dev \
libfontconfig \
libpq-dev \
libssl-dev \
python-dev \
python-pip \
python-virtualenv
python-pip
Install node by following the
`instructions on nodejs.org <https://nodejs.org/en/download/package-manager/>`_
(the version of the nodejs package in the standard Ubuntu repositories is too
old).

Upgrade pip, virtualenv and npm:
Upgrade pip and npm:

.. code-block:: bash
sudo pip install -U pip virtualenv
sudo pip install -U pip
sudo npm install -g npm
Expand All @@ -73,16 +73,17 @@ Install the following packages:
libffi \
node \
postgresql \
python
python \
tox
.. note:: Unfortunately you need to install the ``postgresql`` package, because
Homebrew does not currently provide a standalone ``libpq`` package.

Upgrade pip and virtualenv:
Upgrade pip:

.. code-block:: bash
pip install -U pip virtualenv
pip install -U pip
Getting the h source code from GitHub
-------------------------------------
Expand Down Expand Up @@ -186,39 +187,6 @@ Install ``gulp-cli`` to get the ``gulp`` command:
sudo npm install -g gulp-cli
Creating a Python virtual environment
-------------------------------------

Create a Python virtual environment to install and run the h Python code and
Python dependencies in:

.. code-block:: bash
virtualenv .venv
.. _activating_your_virtual_environment:

Activating your virtual environment
-----------------------------------

Activate the virtual environment that you've created:

.. code-block:: bash
source .venv/bin/activate
.. tip::

You'll need to re-activate this virtualenv with the
``source .venv/bin/activate`` command each time you open a new terminal,
before running h.
See the `Virtual Environments`_ section in the Hitchhiker's guide to
Python for an introduction to Python virtual environments.

.. _Virtual Environments: http://docs.python-guide.org/en/latest/dev/virtualenvs/


Running h
---------

Expand Down
19 changes: 19 additions & 0 deletions tox.ini
Expand Up @@ -25,6 +25,25 @@ passenv =
commands =
coverage run --parallel --source h,tests/h -m pytest -Werror {posargs:tests/h/}

[testenv:dev]
deps = -rrequirements-dev.in
passenv =
ALLOWED_ORIGINS
AUTHORITY
BOUNCER_URL
CLIENT_OAUTH_ID
CLIENT_RPC_ALLOWED_ORIGINS
CLIENT_URL
CONFIG_URI
MODEL_CREATE_ALL
SEARCH_AUTOCONFIG
USE_HTTPS
WEBSOCKET_URL
whitelist_externals = sh
commands =
sh bin/hypothesis --dev init
sh bin/hypothesis devserver

[functional]
deps =
pytest
Expand Down

0 comments on commit 272824c

Please sign in to comment.