Skip to content

Commit b06d123

Browse files
authored
switched requirements.txt to pyproject.toml (#93)
1 parent 200dd81 commit b06d123

File tree

14 files changed

+92
-45
lines changed

14 files changed

+92
-45
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"ghcr.io/devcontainers/features/git:1": {}
1515
},
1616
//"onCreateCommand": "apt-get update && apt-get install -y python3-pip pipenv",
17-
"postCreateCommand": "pipenv --python 3 && pipenv run pip install -r requirements.txt",
17+
"postCreateCommand": "pipenv --python 3 && pipenv run pip install -e .",
1818

1919
//"postCreateCommand": "id",
2020
"customizations": {

Dockerfile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@ RUN apt-get update && \
99

1010
WORKDIR /app
1111

12-
COPY requirements.txt .
13-
RUN pipenv --python 3 && pipenv install -r requirements.txt
14-
1512
COPY . .
13+
RUN pipenv --python 3 && pipenv run pip install -e .
1614

17-
RUN chmod +x cbsurge.sh
18-
19-
CMD [ "./cbsurge.sh", "--help"]
15+
CMD [ "pipenv", "run", "rapida", "--help"]

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ test:
2121
@echo "------------------------------------------------------------------"
2222
@echo "Execute test cases"
2323
@echo "------------------------------------------------------------------"
24-
pipenv run python -m pytest cbsurge/stats
24+
pipenv run python -m pytest tests
2525

2626
build:
2727
@echo

README.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,22 @@ A repo to hold python tools that facilitate the assessment of natural hazards ov
33

44
## Usage
55

6-
Install dependencies to virtual environment as below.
6+
Install the project with dependencies to virtual environment as below.
77

88
```shell
9-
pipenv install -r requirements.txt
9+
pipenv run pip install -e .
1010
```
1111

1212
Then, run the below command to show help menu.
1313

1414
```shell
15-
pipenv run python -m cbsurge.cli --help
15+
pipenv run rapida --help
16+
```
17+
18+
To uninstall the project from Python environment, execute the following command.
19+
20+
```shell
21+
pipenv run pip uninstall geo-cb-surge
1622
```
1723

1824
## Admin
@@ -22,13 +28,13 @@ pipenv run python -m cbsurge.cli --help
2228
- OSM
2329

2430
```shell
25-
pipenv run python -m cbsurge.cli admin osm --help
31+
pipenv run rapida admin osm --help
2632
```
2733

2834
- ocha
2935

3036
```shell
31-
pipenv run python -m cbsurge.cli admin ocha --help
37+
pipenv run rapida admin ocha --help
3238
```
3339

3440
## Run test
@@ -59,5 +65,5 @@ make down
5965

6066
```shell
6167
make shell
62-
./cbsurge.sh --help # run CLI in shell on docker container
68+
pipenv run rapida --help # run CLI in shell on docker container
6369
```

cbsurge.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

cbsurge/admin/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def osm(bbox=None,admin_level=None, osm_level=None, clip=False, h3id_precision=7
100100
101101
To save the result as a file, for instance, the following command can be executed to extract admin 0 data for Rwanda and Burundi as GeoJSON file:
102102
103-
python -m cbsurge.cli admin osm -b "27.767944,-5.063586,31.734009,-0.417477" -l 0 > osm.geojson
103+
rapida admin osm -b "27.767944,-5.063586,31.734009,-0.417477" -l 0 > osm.geojson
104104
"""
105105
silence_httpx_az()
106106
logging.basicConfig(level=logging.DEBUG if debug else logging.INFO)
@@ -156,7 +156,7 @@ def ocha(bbox=None,admin_level=None, clip=False, h3id_precision=7, debug=False)
156156
157157
To save the result as a file, for instance, the following command can be executed to extract admin 0 data for Rwanda and Burundi as GeoJSON file:
158158
159-
python -m cbsurge.cli admin ocha -b "27.767944,-5.063586,31.734009,-0.417477" -l 0 > ocha.geojson
159+
rapida admin ocha -b "27.767944,-5.063586,31.734009,-0.417477" -l 0 > ocha.geojson
160160
"""
161161
silence_httpx_az()
162162
logging.basicConfig(level=logging.DEBUG if debug else logging.INFO)

cbsurge/stats/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ def compute(
7373
7474
Usage: \n
7575
The below command provides how to use the command to compute zonal statistics.\n
76-
python -m cbsurge.cli stats compute --help
76+
rapida stats compute --help
7777
7878
Example: \n
79-
python -m cbsurge.cli stats compute ./cbsurge/stats/tests/assets/admin2.geojson ./cbsurge/stats/tests/assets/admin2_stats.fgb -r ./cbsurge/stats/tests/assets/rwa_m_5_2020_constrained_UNadj.tif -r ./cbsurge/stats/tests/assets/rwa_f_5_2020_constrained_UNadj.tif -o sum -c male_5_sum -c female_5_sum
79+
rapida stats compute ./cbsurge/stats/tests/assets/admin2.geojson ./cbsurge/stats/tests/assets/admin2_stats.fgb -r ./cbsurge/stats/tests/assets/rwa_m_5_2020_constrained_UNadj.tif -r ./cbsurge/stats/tests/assets/rwa_f_5_2020_constrained_UNadj.tif -o sum -c male_5_sum -c female_5_sum
8080
"""
8181
logging.basicConfig(level=logging.DEBUG if debug else logging.INFO)
8282
with ZonalStats(input_file, target_srid=54009) as st:

docker-compose.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ services:
88
command: "pipenv run python -m cbsurge.cli --help"
99
volumes:
1010
- ./Makefile:/app/Makefile
11-
- ./cbsurge:/app/cbsurge # mount app folder to container
11+
- ./cbsurge:/app/cbsurge # mount app folder to container
12+
- ./tests:/app/tests

pyproject.toml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
[project]
2+
name = "geo-cb-surge"
3+
version = "0.0.1"
4+
description = "python tools that facilitate the assessment of natural hazards over various domains like population, landuse, infrastructure, etc"
5+
requires-python = ">=3.12"
6+
authors = [
7+
{ name = 'Ioan Ferencik'},
8+
{ name = 'Joseph Thuha'},
9+
{ name = 'Jin Igarashi'},
10+
{ name = "United Nations Development Programme", email = "[email protected]" }
11+
]
12+
readme = "README.md"
13+
dependencies = [
14+
"httpx",
15+
"osm2geojson",
16+
"shapely",
17+
"h3",
18+
"tqdm",
19+
"GDAL==3.10.0",
20+
"azure-storage-blob",
21+
"overturemaps",
22+
"async",
23+
"aiofiles",
24+
"aiohttp",
25+
"azure-storage-blob",
26+
"asyncclick",
27+
"rio-cogeo",
28+
"exactextract",
29+
"pycountry",
30+
"click",
31+
"pyarrow",
32+
"azure-core",
33+
"rasterio",
34+
"geopandas",
35+
"pytest"
36+
]
37+
38+
[project.scripts]
39+
rapida = "cbsurge.cli:cli"
40+
41+
[tool.setuptools]
42+
py-modules = ["cbsurge"]
43+
44+
[project.urls]
45+
Homepage = "https://github.com/UNDP-Data/geo-cb-surge"
46+
Documentation = "https://github.com/UNDP-Data/geo-cb-surge"
47+
Repository = "https://github.com:UNDP-Data/geo-cb-surge.git"
48+
Issues = "https://github.com/UNDP-Data/geo-cb-surge/issues"
49+
#Changelog = "https://github.com/UNDP-Data/geo-cb-surge/blob/master/CHANGELOG.md"
50+
51+
[tool.hatch.build.targets.wheel]
52+
packages = ["cbsurge"]
53+
54+
[tool.hatch.build.targets.sdist]
55+
exclude = [
56+
".devcontainer",
57+
".github",
58+
".dockerignore",
59+
"docker-compose.yml",
60+
"Dockerfile",
61+
".gitignore",
62+
".pre-commit-config.yaml",
63+
"tests",
64+
"Makefile"
65+
]
66+
67+
[build-system]
68+
requires = ["hatchling"]
69+
build-backend = "hatchling.build"

requirements.txt

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)