qgis-project 0.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- qgis_project-0.0.2/.github/workflows/publish.yml +49 -0
- qgis_project-0.0.2/.github/workflows/test.yml +65 -0
- qgis_project-0.0.2/.gitignore +7 -0
- qgis_project-0.0.2/.readthedocs.yaml +16 -0
- qgis_project-0.0.2/LICENSE.txt +9 -0
- qgis_project-0.0.2/PKG-INFO +145 -0
- qgis_project-0.0.2/README.md +110 -0
- qgis_project-0.0.2/create_project.py +490 -0
- qgis_project-0.0.2/docs/api/layer.md +5 -0
- qgis_project-0.0.2/docs/api/project.md +3 -0
- qgis_project-0.0.2/docs/api/style.md +11 -0
- qgis_project-0.0.2/docs/index.md +84 -0
- qgis_project-0.0.2/draft.md +43 -0
- qgis_project-0.0.2/environment.yml +248 -0
- qgis_project-0.0.2/environment_platform_independent.yml +34 -0
- qgis_project-0.0.2/main.py +8 -0
- qgis_project-0.0.2/mkdocs.yml +50 -0
- qgis_project-0.0.2/notes.md +69 -0
- qgis_project-0.0.2/pyproject.toml +111 -0
- qgis_project-0.0.2/scripts/manual_test.py +172 -0
- qgis_project-0.0.2/src/qgis_project/__about__.py +24 -0
- qgis_project-0.0.2/src/qgis_project/__init__.py +6 -0
- qgis_project-0.0.2/src/qgis_project/layer.py +101 -0
- qgis_project-0.0.2/src/qgis_project/project.py +185 -0
- qgis_project-0.0.2/src/qgis_project/style.py +105 -0
- qgis_project-0.0.2/src/qgis_project/utils.py +142 -0
- qgis_project-0.0.2/test.py +1 -0
- qgis_project-0.0.2/tests/__init__.py +3 -0
- qgis_project-0.0.2/tests/conftest.py +23 -0
- qgis_project-0.0.2/tests/test_integration.py +78 -0
- qgis_project-0.0.2/tests/test_unit.py +97 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- "v*.*.*"
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
name: Build distribution
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- uses: actions/setup-python@v5
|
|
17
|
+
with:
|
|
18
|
+
python-version: "3.12"
|
|
19
|
+
|
|
20
|
+
- name: Install hatch
|
|
21
|
+
run: pip install hatch
|
|
22
|
+
|
|
23
|
+
- name: Build package
|
|
24
|
+
run: |
|
|
25
|
+
rm -rf dist/
|
|
26
|
+
hatch build
|
|
27
|
+
|
|
28
|
+
- uses: actions/upload-artifact@v4
|
|
29
|
+
with:
|
|
30
|
+
name: dist
|
|
31
|
+
path: dist/
|
|
32
|
+
|
|
33
|
+
publish:
|
|
34
|
+
name: Publish to PyPI
|
|
35
|
+
needs: build
|
|
36
|
+
runs-on: ubuntu-latest
|
|
37
|
+
environment:
|
|
38
|
+
name: pypi
|
|
39
|
+
url: https://pypi.org/p/qgis-project
|
|
40
|
+
permissions:
|
|
41
|
+
id-token: write # required for Trusted Publisher (OIDC)
|
|
42
|
+
|
|
43
|
+
steps:
|
|
44
|
+
- uses: actions/download-artifact@v4
|
|
45
|
+
with:
|
|
46
|
+
name: dist
|
|
47
|
+
path: dist/
|
|
48
|
+
|
|
49
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
name: Test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
# Fast job: tests that don't require QGIS (imports, dataclasses, utilities).
|
|
11
|
+
# Runs on standard GitHub runners with plain pip.
|
|
12
|
+
test:
|
|
13
|
+
name: Test (Python ${{ matrix.python-version }})
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
strategy:
|
|
16
|
+
fail-fast: false
|
|
17
|
+
matrix:
|
|
18
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v4
|
|
22
|
+
|
|
23
|
+
- uses: actions/setup-python@v5
|
|
24
|
+
with:
|
|
25
|
+
python-version: ${{ matrix.python-version }}
|
|
26
|
+
|
|
27
|
+
- name: Install package with dev dependencies
|
|
28
|
+
run: pip install -e ".[dev]"
|
|
29
|
+
|
|
30
|
+
- name: Run tests
|
|
31
|
+
# -p no:qgis: don't load pytest-qgis even if somehow installed;
|
|
32
|
+
# it imports qgis at plugin load time and would crash without QGIS.
|
|
33
|
+
run: pytest tests/ -v --tb=short -m "not qgis" -p no:qgis
|
|
34
|
+
|
|
35
|
+
# Slow job: full integration tests using a conda QGIS environment.
|
|
36
|
+
# Triggered manually or on pushes to main; allowed to fail until
|
|
37
|
+
# a stable QGIS test suite is established.
|
|
38
|
+
test-qgis:
|
|
39
|
+
name: Test with QGIS (conda)
|
|
40
|
+
runs-on: ubuntu-latest
|
|
41
|
+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
42
|
+
|
|
43
|
+
steps:
|
|
44
|
+
- uses: actions/checkout@v4
|
|
45
|
+
|
|
46
|
+
- uses: conda-incubator/setup-miniconda@v3
|
|
47
|
+
with:
|
|
48
|
+
environment-file: environment_platform_independent.yml
|
|
49
|
+
activate-environment: qgis-env-pi
|
|
50
|
+
auto-activate-base: false
|
|
51
|
+
|
|
52
|
+
- name: Install package into QGIS environment
|
|
53
|
+
shell: bash -el {0}
|
|
54
|
+
run: pip install -e ".[dev,qgis-dev]"
|
|
55
|
+
|
|
56
|
+
- name: Configure QGIS PYTHONPATH
|
|
57
|
+
shell: bash -el {0}
|
|
58
|
+
run: |
|
|
59
|
+
echo "PYTHONPATH=$CONDA_PREFIX/share/qgis/python:$CONDA_PREFIX/share/qgis/python/plugins:$PYTHONPATH" >> $GITHUB_ENV
|
|
60
|
+
echo "QT_QPA_PLATFORM=offscreen" >> $GITHUB_ENV
|
|
61
|
+
|
|
62
|
+
- name: Run QGIS tests
|
|
63
|
+
shell: bash -el {0}
|
|
64
|
+
run: pytest tests/ -v --tb=short -m "qgis"
|
|
65
|
+
continue-on-error: true
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025-present Colin Moldenhauer <colin.moldenhauer@posteo.de>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: qgis-project
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: Create QGIS projects programmatically using Python
|
|
5
|
+
Project-URL: Documentation, https://github.com/ColinMoldenhauer/qgis-project#readme
|
|
6
|
+
Project-URL: Issues, https://github.com/ColinMoldenhauer/qgis-project/issues
|
|
7
|
+
Project-URL: Source, https://github.com/ColinMoldenhauer/qgis-project
|
|
8
|
+
Author-email: Colin Moldenhauer <colin.moldenhauer@posteo.de>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE.txt
|
|
11
|
+
Keywords: cartography,geospatial,gis,mapping,qgis
|
|
12
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering :: GIS
|
|
23
|
+
Requires-Python: >=3.9
|
|
24
|
+
Requires-Dist: loguru
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: mypy>=1.0.0; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
|
29
|
+
Provides-Extra: docs
|
|
30
|
+
Requires-Dist: mkdocs-material; extra == 'docs'
|
|
31
|
+
Requires-Dist: mkdocstrings[python]; extra == 'docs'
|
|
32
|
+
Provides-Extra: qgis-dev
|
|
33
|
+
Requires-Dist: pytest-qgis; extra == 'qgis-dev'
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# qgis-project
|
|
37
|
+
|
|
38
|
+
Create QGIS projects programmatically using Python.
|
|
39
|
+
|
|
40
|
+
```python
|
|
41
|
+
from qgis_project import Project, RasterLayer, RasterStyleBW
|
|
42
|
+
|
|
43
|
+
proj = Project()
|
|
44
|
+
proj.add_layer("dem.tif") # raster, auto-detected
|
|
45
|
+
proj.add_layer("boundaries.geojson") # vector, auto-detected
|
|
46
|
+
proj.add_layer(RasterLayer("dem.tif", style=RasterStyleBW(vmin=0, vmax=3000)))
|
|
47
|
+
proj.save("output.qgz")
|
|
48
|
+
proj.open() # launch QGIS for visual inspection
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
## Installation
|
|
53
|
+
|
|
54
|
+
Install the package:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install qgis-project
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
QGIS is not on PyPI and must be available separately. The recommended approach is a dedicated conda environment:
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
conda env create -f environment_platform_independent.yml
|
|
64
|
+
conda activate qgis-env-pi
|
|
65
|
+
pip install qgis-project
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Or install QGIS from conda-forge into an existing environment:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
conda install -c conda-forge qgis
|
|
72
|
+
pip install qgis-project
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
> **Note:** All QGIS imports are lazy — `import qgis_project` works without QGIS installed. Errors only surface when a QGIS-backed method is actually called.
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
## Usage
|
|
79
|
+
|
|
80
|
+
### Basic project
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from qgis_project import Project
|
|
84
|
+
|
|
85
|
+
proj = Project()
|
|
86
|
+
proj.add_layer("dem.tif")
|
|
87
|
+
proj.add_layer("roads.geojson")
|
|
88
|
+
proj.save("my_project.qgz")
|
|
89
|
+
proj.exit()
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Layer groups
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
proj.add_layer(RasterLayer("dem.tif", group="terrain"))
|
|
96
|
+
proj.add_layer(RasterLayer("slope.tif", group=["terrain", "derived"]))
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Raster styling
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
from qgis_project import RasterLayer, RasterStyleBW
|
|
103
|
+
|
|
104
|
+
layer = RasterLayer(
|
|
105
|
+
file="dem.tif",
|
|
106
|
+
name="Elevation",
|
|
107
|
+
group="terrain",
|
|
108
|
+
style=RasterStyleBW(vmin=0, vmax=3000),
|
|
109
|
+
)
|
|
110
|
+
proj.add_layer(layer)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Open in QGIS
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
proj.open("output.qgz") # saves and launches QGIS
|
|
117
|
+
proj.print_layer_tree() # inspect the layer tree in the terminal
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
## Development
|
|
122
|
+
|
|
123
|
+
Install with dev dependencies:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
pip install -e ".[dev]"
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Run unit tests (no QGIS required):
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
pytest -m "not qgis"
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Run integration tests (QGIS environment required):
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
pytest -m qgis
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Run the manual visual test:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
python scripts/manual_test.py
|
|
145
|
+
```
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# qgis-project
|
|
2
|
+
|
|
3
|
+
Create QGIS projects programmatically using Python.
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
from qgis_project import Project, RasterLayer, RasterStyleBW
|
|
7
|
+
|
|
8
|
+
proj = Project()
|
|
9
|
+
proj.add_layer("dem.tif") # raster, auto-detected
|
|
10
|
+
proj.add_layer("boundaries.geojson") # vector, auto-detected
|
|
11
|
+
proj.add_layer(RasterLayer("dem.tif", style=RasterStyleBW(vmin=0, vmax=3000)))
|
|
12
|
+
proj.save("output.qgz")
|
|
13
|
+
proj.open() # launch QGIS for visual inspection
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
Install the package:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install qgis-project
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
QGIS is not on PyPI and must be available separately. The recommended approach is a dedicated conda environment:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
conda env create -f environment_platform_independent.yml
|
|
29
|
+
conda activate qgis-env-pi
|
|
30
|
+
pip install qgis-project
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Or install QGIS from conda-forge into an existing environment:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
conda install -c conda-forge qgis
|
|
37
|
+
pip install qgis-project
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
> **Note:** All QGIS imports are lazy — `import qgis_project` works without QGIS installed. Errors only surface when a QGIS-backed method is actually called.
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
### Basic project
|
|
46
|
+
|
|
47
|
+
```python
|
|
48
|
+
from qgis_project import Project
|
|
49
|
+
|
|
50
|
+
proj = Project()
|
|
51
|
+
proj.add_layer("dem.tif")
|
|
52
|
+
proj.add_layer("roads.geojson")
|
|
53
|
+
proj.save("my_project.qgz")
|
|
54
|
+
proj.exit()
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Layer groups
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
proj.add_layer(RasterLayer("dem.tif", group="terrain"))
|
|
61
|
+
proj.add_layer(RasterLayer("slope.tif", group=["terrain", "derived"]))
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Raster styling
|
|
65
|
+
|
|
66
|
+
```python
|
|
67
|
+
from qgis_project import RasterLayer, RasterStyleBW
|
|
68
|
+
|
|
69
|
+
layer = RasterLayer(
|
|
70
|
+
file="dem.tif",
|
|
71
|
+
name="Elevation",
|
|
72
|
+
group="terrain",
|
|
73
|
+
style=RasterStyleBW(vmin=0, vmax=3000),
|
|
74
|
+
)
|
|
75
|
+
proj.add_layer(layer)
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Open in QGIS
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
proj.open("output.qgz") # saves and launches QGIS
|
|
82
|
+
proj.print_layer_tree() # inspect the layer tree in the terminal
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
## Development
|
|
87
|
+
|
|
88
|
+
Install with dev dependencies:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
pip install -e ".[dev]"
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Run unit tests (no QGIS required):
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
pytest -m "not qgis"
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Run integration tests (QGIS environment required):
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
pytest -m qgis
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Run the manual visual test:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
python scripts/manual_test.py
|
|
110
|
+
```
|