Skip to content

Commit 80e96f9

Browse files
committed
streamline local dev
1 parent a1c3683 commit 80e96f9

File tree

7 files changed

+63
-41
lines changed

7 files changed

+63
-41
lines changed

.gitignore

+2
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/

HISTORY.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
History
33
=======
44

5-
0.1.0 (2017-05-27)
5+
0.1.0 (2017-06-04)
66
------------------
77

88
* First release on PyPI.

MANIFEST.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ recursive-exclude * *.py[co]
1313
recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif
1414

1515
# we only want "release" artifacts, not "debug" artifacts
16-
recursive-include trust_pypi_example/rust/target/release *.so *.dylib *.dll *.lib
16+
recursive-include trust_pypi_example/rust/target/release *.so *.dylib *.dll *.lib
1717
recursive-include trust_pypi_example *.h *.c
1818

1919
# inclusing the .rs and .toml files isn't necessary so feel free to remove them.

Makefile

+35-33
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 trust_pypi_example/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,52 +51,53 @@ clean-test: ## remove test and coverage artifacts
5051
rm -f .coverage
5152
rm -fr htmlcov/
5253

53-
lint: ## check style with flake8
54-
flake8 trust_pypi_example tests
55-
56-
test: ## run tests quickly with the default Python
57-
py.test
58-
54+
clean-venv:
55+
rm -rf venv
5956

57+
lint: venv ## check style with flake8
58+
venv/bin/flake8 trust_pypi_example tests
6059

61-
cargo-test: ## build rust lib for local testing. DO NOT USE ON TRAVIS. Cross needs to build for the target
62-
cargo test --manifest-path trust_pypi_example/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
6363

64-
cargo-build: ## build rust lib for local testing. DO NOT USE ON TRAVIS. Cross needs to build for the target
65-
cargo build --manifest-path trust_pypi_example/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
6667

67-
cross-build: clean
68-
cross build --manifest-path trust_pypi_example/rust/Cargo.toml --target $$TARGET --release
6968

70-
test-all: ## run tests on every Python version with tox
71-
tox
69+
test-all: venv ## run tests on every Python version with tox
70+
venv/bin/tox
7271

73-
coverage: ## check code coverage quickly with the default Python
74-
coverage run --source trust_pypi_example -m pytest
72+
coverage: venv ## check code coverage quickly with the default Python
73+
venv/bin/coverage run --source trust_pypi_example -m pytest
7574

76-
coverage report -m
77-
coverage html
75+
venv/bin/coverage report -m
76+
venv/bin/coverage html
7877
$(BROWSER) htmlcov/index.html
7978

80-
docs: ## generate Sphinx HTML documentation, including API docs
79+
docs: venv ## generate Sphinx HTML documentation, including API docs
8180
rm -f docs/trust_pypi_example.rst
8281
rm -f docs/modules.rst
83-
sphinx-apidoc -o docs/ trust_pypi_example
82+
venv/bin/sphinx-apidoc -o docs/ trust_pypi_example
8483
$(MAKE) -C docs clean
8584
$(MAKE) -C docs html
8685
$(BROWSER) docs/_build/html/index.html
8786

88-
servedocs: docs ## compile the docs watching for changes
89-
watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .
87+
servedocs: venv docs ## compile the docs watching for changes
88+
venv/bin/watchmedo shell-command -p '*.rst' -c '$(MAKE) -C docs html' -R -D .
9089

91-
release: clean ## package and upload a release
92-
python setup.py sdist upload
93-
python setup.py bdist_wheel upload
90+
release: venv clean ## package and upload a release
91+
venv/bin/python setup.py sdist upload
92+
venv/bin/python setup.py bdist_wheel upload
9493

95-
dist: clean ## builds source and wheel package
96-
python setup.py sdist
97-
python setup.py bdist_wheel
94+
dist: venv clean ## builds source and wheel package
95+
venv/bin/python setup.py sdist
96+
venv/bin/python setup.py bdist_wheel
9897
ls -l dist
9998

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

README.rst

+16-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,22 @@ trust_pypi_example
1818
:alt: Updates
1919

2020

21-
This package was created with Cookiecutter_ and the `mckaymatt/cookiecutter-pypackage-rust-cross-platform-publish`_ project template. It is meant to show how `mckaymatt/cookiecutter-pypackage-rust-cross-platform-publish`_ can be used to produce a Python Wheel with an embedded Rust module.
21+
Python Boilerplate contains all the boilerplate you need to create a Python wheel with Rust.
22+
23+
24+
* Free software: Apache Software License 2.0
25+
* Documentation: https://trust-pypi-example.readthedocs.io.
26+
27+
28+
Features
29+
--------
30+
31+
* TODO
32+
33+
Credits
34+
---------
35+
36+
This package was created with Cookiecutter_ and the `mckaymatt/cookiecutter-pypackage-rust-cross-platform-publish`_ project template.
2237

2338
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
2439
.. _`mckaymatt/cookiecutter-pypackage-rust-cross-platform-publish`: https://github.com/mckaymatt/cookiecutter-pypackage-rust-cross-platform-publish

appveyor.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ build_script:
6464

6565
test_script:
6666
- "%PYTHON_DIR%\\python -m ci test"
67-
- ps: >-
67+
- ps: >-
6868
Get-ChildItem .\dist\
69-
- ps: >-
69+
- ps: >-
7070
Get-ChildItem -R trust_pypi_example\
7171
7272

trust_pypi_example/trust_pypi_example.py

+6-3
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)