Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Commit fcf2ad7

Browse files
authored
prepare release v3.0.0 (#7)
* update to macos * re-arrange many things * mainly readme; use setuptools_scm more extensively: github actions will see the tag and that package will automatically create a __version__.py:__version__ attribute with the correct, current version * wrong manylinux image referernced * trigger build * trigger build again * import decode_polyline to __init__.py * trigger build * pip not found? * trigger build * we're not in a container * run pre-commit instead of plain commands * trigger build * needed special env var for cibuildwheel * make paths absolute and remove static valhalla.json * upload wheels as artifacts * rename notebook; add some liens to readme * remove the artifact from PRs
1 parent 72e6664 commit fcf2ad7

File tree

17 files changed

+233
-61
lines changed

17 files changed

+233
-61
lines changed

.github/workflows/publish_tags.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ jobs:
1717
include:
1818
- image: ubuntu-latest
1919
platform: linux
20-
cxx: 'g++-9'
2120
- image: windows-latest
2221
platform: windows
23-
cxx: 'Visual Studio'
2422
- image: macos-latest
2523
platform: macos
2624
steps:
2725
- uses: actions/checkout@v2
26+
with:
27+
fetch-depth: 0
2828

2929
- name: Configure Python
3030
uses: actions/setup-python@v2
@@ -56,7 +56,7 @@ jobs:
5656
conan install --install-folder conan_build --remote conancenter .
5757
5858
- name: Install Conan (MacOS)
59-
if: matrix.platform != 'windows' && steps.cache-conan.outputs.cache-hit != 'true'
59+
if: matrix.platform == 'macos' && steps.cache-conan.outputs.cache-hit != 'true'
6060
run: |
6161
pip install pip --upgrade
6262
pip install conan

.github/workflows/pull_request.yml

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,39 +15,19 @@ on:
1515
jobs:
1616
build_wheels:
1717
name: PR - cp*, ubuntu-latest
18-
container: ghcr.io/gis-ops/manylinux:valhalla_py
19-
18+
runs-on: ubuntu-latest
2019
steps:
2120
- uses: actions/checkout@v2
2221

23-
- name: Lint & Style Check
24-
run: |
25-
pip install black flake8
26-
black --check valhalla
27-
flake8 valhalla
28-
29-
# keep in-sync with the other yaml
30-
# only macos makes sense, windows didn't work, linux installs conan inside the docker image
31-
- name: Cache Conan
32-
id: cache-conan
33-
uses: actions/cache@v2
22+
- name: Configure Python
23+
uses: actions/setup-python@v2
3424
with:
35-
path: |
36-
${{ github.workspace }}/conan_data
37-
${{ github.workspace }}/conan_build
38-
key: conan-${{ matrix.platform }}-${{ hashFiles('conanfile.txt') }}
39-
restore-keys: |
40-
conan-${{ matrix.platform }}-
25+
python-version: '3.7'
4126

42-
- name: Install Conan
43-
if: steps.cache-conan.outputs.cache-hit != 'true'
27+
- name: Lint & Style Check
4428
run: |
45-
pip install pip --upgrade
46-
pip install conan
47-
conan profile new default --detect
48-
conan config set "storage.path=${{ github.workspace }}/conan_data"
49-
conan install --install-folder ${{ github.workspace }}/conan_build --remote conancenter .
29+
pip install black flake8 pre-commit
30+
pre-commit run --all-files --show-diff-on-failure
5031
51-
- name: Test
52-
run: |
53-
for py_version in cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310; do /opt/python/$py_version/bin/pip install -e . && /opt/python/$py_version/bin/python -c "from valhalla import Actor"; done
32+
# only build the earliest supported python version
33+
- uses: pypa/[email protected]

.github/workflows/push_master.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313

1414
jobs:
1515
build_wheels:
16-
name: Push - cp37*, ${{ matrix.image }}
16+
name: Push - cp37*, ${{ matrix.platform }}
1717
runs-on: ${{ matrix.image }}
1818
strategy:
1919
fail-fast: true
@@ -44,7 +44,7 @@ jobs:
4444
- name: Cache Conan (MacOS)
4545
id: cache-conan
4646
uses: actions/cache@v2
47-
if: matrix.platform != 'windows'
47+
if: matrix.platform == 'macos'
4848
with:
4949
path: |
5050
${{ github.workspace }}/conan_data
@@ -77,4 +77,4 @@ jobs:
7777
- uses: pypa/[email protected]
7878
env:
7979
MACOSX_DEPLOYMENT_TARGET: 10.9
80-
CIBW_BUILD: 'cp37*'
80+
CIBW_BUILD: cp37*

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ __pycache__/
33
*.py[cod]
44
*$py.class
55

6+
# will be updated by setuptools_scm on github actions before releasing to pypi
7+
__version__.py
8+
69
# C extensions
710
*.so
811

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Valhalla for Python
2-
[![Master Push](https://github.com/gis-ops/valhalla-py/actions/workflows/push_master.yml/badge.svg)](https://github.com/gis-ops/valhalla-py/actions/workflows/push_master.yml)
2+
[![Master Push](https://github.com/gis-ops/pyvalhalla/actions/workflows/push_master.yml/badge.svg)](https://github.com/gis-ops/pyvalhalla/actions/workflows/push_master.yml)
33

44
This spin-off project simply offers packaged Python bindings to the fantastic [Valhalla project](https://github.com/valhalla/valhalla).
55

@@ -11,9 +11,25 @@ We distribute all 4 currently supported CPython versions as binary **wheels** fo
1111

1212
`pip install pyvalhalla`
1313

14+
**Note**, to install from PyPI as a **Linux** user you must have `pip` version 20.3 or greater installed.
15+
1416
## Usage
1517

16-
TODO
18+
Find a more extended notebook in `./examples`, e.g. how to [use the actor](./examples/actor_examples.ipynb).
19+
20+
Before using the Python bindings you need to have access to a routable Valhalla graph. Either install Valhalla from source and built the graph from OSM compatible data or use our [Valhalla docker image](https://github.com/gis-ops/docker-valhalla) for a painless experience.
21+
22+
Once you have created a graph locally, you can use it like this:
23+
```python
24+
from valhalla import Actor, get_config
25+
26+
# generate configuration
27+
config = get_config(tile_extract='path/to/extract.tar', verbose=True)
28+
29+
# instantiate Actor to load graph and call actions
30+
actor = Actor(config)
31+
route = actor.route({"locations": [...]})
32+
```
1733

1834
## License
1935

docs/releasing.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## `valhalla-py` release patterns
1+
## `pyvalhalla` release patterns
22

33
We release independently from Valhalla core. One can retrieve both by:
44

@@ -65,10 +65,10 @@ Proto headers have to be compiled on each platform separately.
6565

6666
#### Linux
6767

68-
Fire up the `ghcr.io/gis-ops/manylinux:valhalla_py` image which has all dependencies installed and build valhalla:
68+
Fire up the `ghcr.io/gis-ops/manylinux:valhalla_python` image which has all dependencies installed and build valhalla:
6969

7070
```
71-
docker run -dt -v $PWD:/valhalla-py --name valhalla-py ghcr.io/gis-ops/manylinux:valhalla_py
71+
docker run -dt -v $PWD:/valhalla-py --name valhalla-py ghcr.io/gis-ops/manylinux:valhalla_python
7272
./scripts/build_linux.sh
7373
sudo chown -R nilsnolde:nilsnolde .
7474
```
@@ -84,6 +84,14 @@ Pretty identical to Linux, just we don't need a docker container of course:
8484
./scripts/build_mac.sh
8585
```
8686

87+
To test it worked:
88+
89+
```
90+
pip uninstall pyvalhalla
91+
pip install wheelhouse/pyvalhalla-xxx.whl
92+
python -c "from valhalla import Actor; a = Actor('valhalla.json')"
93+
```
94+
8795
#### Windows
8896

8997
First build Valhalla:

pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ requires = [
88
]
99
build-backend = "setuptools.build_meta"
1010

11+
[tool.setuptools_scm]
12+
write_to = "valhalla/__version__.py"
13+
write_to_template = "__version__ = '{version}'\n"
14+
version_scheme = "post-release"
15+
1116
[tool.black]
1217
line-length = 105
1318
exclude = '''
@@ -22,7 +27,7 @@ exclude = '''
2227
'''
2328

2429
[tool.cibuildwheel]
25-
test-command = "python -c \"from valhalla import Actor\""
30+
test-command = "python -m unittest discover -s {project}/test"
2631
# find out current defaults: cibuildwheel --print-build-identifiers --platform linux
2732
build = "cp*"
2833
skip = "*musllinux*"

setup.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
with conanfiles[0].open() as f:
3838
# it's just header-only boost so far..
3939
include_dirs.extend(json.load(f)["dependencies"][0]["include_paths"])
40-
4140
else:
4241
logging.warning(
4342
"Conan not installed and/or no conan build detected. Assuming dependencies are installed."
@@ -70,11 +69,10 @@
7069
author_email="[email protected]",
7170
packages=find_packages(exclude=["tests", "*.tests", "*.tests.*", "tests.*"]),
7271
python_requires=">=3.7.0",
73-
url="https://github.com/gis-ops/valhalla-py",
72+
url="https://github.com/gis-ops/pyvalhalla",
7473
ext_package="valhalla",
7574
ext_modules=ext_modules,
7675
zip_safe=False,
77-
use_scm_version=True,
7876
classifiers=[
7977
"License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)",
8078
"Programming Language :: Python :: 3",
285 KB
Binary file not shown.

0 commit comments

Comments
 (0)