Skip to content

Commit

Permalink
Create package, support web_app target
Browse files Browse the repository at this point in the history
  • Loading branch information
kordejong committed Jan 17, 2025
1 parent f0ec775 commit a7bfc3d
Show file tree
Hide file tree
Showing 40 changed files with 283 additions and 359 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/analyse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
matrix:
python_version: ["3.12"]
platform:
- { os: "ubuntu-22.04", arch: x64 }
- { os: "ubuntu-24.04", arch: x64 }
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
platform:
- { os: "macos-14", arch: arm64 }
- { os: "macos-13", arch: x64 }
- { os: "ubuntu-22.04", arch: x64 }
- { os: "ubuntu-24.04", arch: x64 }
- { os: "windows-2022", arch: x64 }
steps:
- name: Setup Linux platform
Expand Down
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ project(AdaptationPathways
HOMEPAGE_URL "https://publicwiki.deltares.nl/display/AP/Adaptation+Pathways"
)

set(AP_COPYRIGHT "2025 by TODO")
string(JOIN ", " AP_AUTHORS
# TODO Add everybody, in some order (alphabet?)
"Kor de Jong (Geoneric, NL)"
"Marjolijn Haasnoot (Deltares, NL)"
"Willem van Deursen (Carthago Consultancy, NL)"
)

enable_testing()

list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/environment/cmake)
Expand Down
2 changes: 1 addition & 1 deletion documentation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ add_custom_target(apidoc
--module-first
-d 1
-o ${CMAKE_CURRENT_BINARY_DIR}/api
${PROJECT_SOURCE_DIR}/source/package/adaptation_pathways
${PROJECT_SOURCE_DIR}/source/package
)

# https://www.sphinx-doc.org/en/master/man/sphinx-build.html
Expand Down
11 changes: 2 additions & 9 deletions documentation/conf.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,8 @@ import re
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = "@CMAKE_PROJECT_NAME@"
copyright = "2024, TODO"
author = ", ".join(
[
# TODO Add everybody
"Marjolijn Haasnoot (Deltares, NL)",
"Willem van Deursen (Carthago Consultancy, NL)",
"Kor de Jong (Geoneric, NL)",
]
)
copyright = "@AP_COPYRIGHT@"
author = "@AP_AUTHORS@"
version = "@CMAKE_PROJECT_VERSION_MAJOR@.@CMAKE_PROJECT_VERSION_MINOR@"

# -- General configuration ---------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions environment/configuration/requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
build
cairosvg
cmake
flet>=0.25.1
furo
linkchecker
ninja
Expand Down
1 change: 0 additions & 1 deletion environment/configuration/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ docopt
matplotlib
networkx[default]
pyside6>=6.6
flet==0.22.*
5 changes: 2 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,10 @@ classifiers = [
"Operating System :: OS Independent",
]
dependencies = [
"docopt",
# "docopt", # TODO flet build can't find docopt...
"matplotlib",
"networkx[default]",
"pyside6",
"flet",
# "pyside6",
]

[project.urls]
Expand Down
1 change: 1 addition & 0 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
add_subdirectory(package/adaptation_pathways/desktop)
add_subdirectory(package/pathways_app)
add_subdirectory(test)
160 changes: 0 additions & 160 deletions source/package/pathways_app/.gitignore

This file was deleted.

24 changes: 24 additions & 0 deletions source/package/pathways_app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
find_program(AP_FLET_COMMAND flet REQUIRED)


configure_file(
pyproject.toml.in
pyproject.toml
@ONLY
)

add_custom_target(web_app
COMMAND
${CMAKE_COMMAND} -E copy_directory_if_different
${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}
COMMAND
${CMAKE_COMMAND} -E env "PIP_FIND_LINKS=file://${PROJECT_BINARY_DIR}/dist"
${AP_FLET_COMMAND} build web ${CMAKE_CURRENT_BINARY_DIR}
COMMAND
${CMAKE_COMMAND} -E echo
"Run a command like this to start the web app:"
"${Python3_EXECUTABLE} -m http.server --directory ${CMAKE_CURRENT_BINARY_DIR}/build/web"
DEPENDS
package
VERBATIM
)
14 changes: 12 additions & 2 deletions source/package/pathways_app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@
To run the app from within this directory:

```
flet run .
flet run main.py
```

To run the app as a website:

```
flet run --web .
flet run --web
```

To build the web app:

```
# Assumes you're in the binary directory
cmake --build . --target web_app
# Alternatively, if using Ninja for example
ninja web_app
```
Loading

0 comments on commit a7bfc3d

Please sign in to comment.