Skip to content

Commit 6b2b094

Browse files
committed
improve local dev
1 parent 15e8967 commit 6b2b094

File tree

4 files changed

+50
-40
lines changed

4 files changed

+50
-40
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,9 @@ python_boilerplate/
9797

9898
# SSHFS
9999
.Trash-1000/
100+
101+
# virtualenv
102+
.venv
103+
104+
# rust demo project
105+
trust_pypi_example

{{cookiecutter.project_slug}}/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ target/
6363

6464
# virtualenv
6565
.venv/
66+
venv/
67+
6668

6769
# Wheelhouse
6870
wheelhouse/
Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: clean clean-test clean-pyc clean-build docs help
1+
.PHONY: clean clean-test clean-pyc clean-build clean-venv docs help install dist release test test-all
22
.DEFAULT_GOAL := help
33
define BROWSER_PYSCRIPT
44
import os, webbrowser, sys
@@ -28,16 +28,17 @@ BROWSER := python -c "$$BROWSER_PYSCRIPT"
2828
help:
2929
@python -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
3030

31-
clean: clean-build clean-pyc clean-test ## remove all build, test, coverage and Python artifacts
31+
clean: clean-build clean-pyc clean-test clean-venv ## remove all build, test, coverage, Python artifacts and virtualenv
3232

3333

3434
clean-build: ## remove build artifacts
3535
rm -fr build/
3636
rm -fr dist/
3737
rm -fr {{ cookiecutter.project_slug }}/rust/target
3838
rm -fr .eggs/
39+
rm -f *.so *.dylib *.dll
3940
find . -name '*.egg-info' -exec rm -fr {} +
40-
find . -name '*.egg' -exec rm -f {} +
41+
find . -name '*.egg' -exec rm -fr {} +
4142

4243
clean-pyc: ## remove Python file artifacts
4344
find . -name '*.pyc' -exec rm -f {} +
@@ -50,58 +51,56 @@ clean-test: ## remove test and coverage artifacts
5051
rm -f .coverage
5152
rm -fr htmlcov/
5253

53-
lint: ## check style with flake8
54-
flake8 {{ cookiecutter.project_slug }} tests
55-
56-
test: ## run tests quickly with the default Python
57-
{% if cookiecutter.use_pytest == 'y' -%}
58-
py.test
59-
{% else %}
60-
python setup.py test
61-
{%- endif %}
54+
clean-venv:
55+
rm -rf venv
6256

57+
lint: venv ## check style with flake8
58+
venv/bin/flake8 {{ cookiecutter.project_slug }} tests
6359

64-
cargo-test: ## build rust lib for local testing. DO NOT USE ON TRAVIS. Cross needs to build for the target
65-
cargo test --manifest-path {{ cookiecutter.project_slug }}/rust/Cargo.toml --release
60+
test: venv ## This will use py.test because of pytest-runner
61+
venv/bin/python setup.py check
62+
venv/bin/python setup.py test
6663

67-
cargo-build: ## build rust lib for local testing. DO NOT USE ON TRAVIS. Cross needs to build for the target
68-
cargo build --manifest-path {{ cookiecutter.project_slug }}/rust/Cargo.toml --release
64+
venv: ## set up a virtualenv that will by python and install dependencies
65+
python -m virtualenv venv || python -m venv venv
66+
venv/bin/pip install -r requirements_dev.txt
6967

70-
cross-build: clean
71-
cross build --manifest-path {{ cookiecutter.project_slug }}/rust/Cargo.toml --target $$TARGET --release
7268

73-
test-all: ## run tests on every Python version with tox
74-
tox
69+
test-all: venv ## run tests on every Python version with tox
70+
venv/bin/tox
7571

76-
coverage: ## check code coverage quickly with the default Python
72+
coverage: venv ## check code coverage quickly with the default Python
7773
{% if cookiecutter.use_pytest == 'y' -%}
78-
coverage run --source {{ cookiecutter.project_slug }} -m pytest
74+
venv/bin/coverage run --source {{ cookiecutter.project_slug }} -m pytest
7975
{% else %}
80-
coverage run --source {{ cookiecutter.project_slug }} setup.py test
76+
venv/bin/coverage run --source {{ cookiecutter.project_slug }} setup.py test
8177
{% endif %}
82-
coverage report -m
83-
coverage html
78+
venv/bin/coverage report -m
79+
venv/bin/coverage html
8480
$(BROWSER) htmlcov/index.html
8581

86-
docs: ## generate Sphinx HTML documentation, including API docs
82+
docs: venv ## generate Sphinx HTML documentation, including API docs
8783
rm -f docs/{{ cookiecutter.project_slug }}.rst
8884
rm -f docs/modules.rst
89-
sphinx-apidoc -o docs/ {{ cookiecutter.project_slug }}
85+
venv/bin/sphinx-apidoc -o docs/ {{ cookiecutter.project_slug }}
9086
$(MAKE) -C docs clean
9187
$(MAKE) -C docs html
9288
$(BROWSER) docs/_build/html/index.html
9389

94-
servedocs: docs ## compile the docs watching for changes
95-
watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .
90+
servedocs: venv docs ## compile the docs watching for changes
91+
venv/bin/watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .
9692

97-
release: clean ## package and upload a release
98-
python setup.py sdist upload
99-
python setup.py bdist_wheel upload
93+
release: venv clean ## package and upload a release
94+
venv/bin/python setup.py sdist upload
95+
venv/bin/python setup.py bdist_wheel upload
10096

101-
dist: clean ## builds source and wheel package
102-
python setup.py sdist
103-
python setup.py bdist_wheel
97+
dist: venv clean ## builds source and wheel package
98+
venv/bin/python setup.py sdist
99+
venv/bin/python setup.py bdist_wheel
104100
ls -l dist
105101

106-
install: clean ## install the package to the active Python's site-packages
107-
python setup.py install
102+
install: venv clean ## install the package to the active Python's site-packages
103+
venv/bin/python setup.py install
104+
105+
106+
local-test: clean test coverage dist install

{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}/{{cookiecutter.project_slug}}.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616
DYNAMIC_LIB_FORMAT = '%s.dll'
1717
elif sys.platform == 'darwin':
1818
DYNAMIC_LIB_FORMAT = 'lib%s.dylib'
19-
# FIXME: Does this need to check for other values of `sys.platform`?
20-
else:
19+
elif "linux" in sys.platform:
2120
DYNAMIC_LIB_FORMAT = 'lib%s.so'
21+
else:
22+
raise NotImplementedError('No implementation for "{}".'
23+
' Supported platforms are '
24+
'"win32", "darwin", and "linux"'
25+
''.format(sys.platform))
2226

2327
DLPATH = os.path.join(
24-
# FIXME: path is hard-coded
2528
# If the crate is built without the "--release" flag
2629
# the path will be 'rust/target/debug' and this will
2730
# cause OSError

0 commit comments

Comments
 (0)