Skip to content

Commit c305331

Browse files
committed
Python interop WIP
1 parent 463576a commit c305331

File tree

16 files changed

+12283
-1362
lines changed

16 files changed

+12283
-1362
lines changed

.cargo/config.toml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
[target.x86_64-pc-windows-msvc]
2+
rustflags = ["-C", "target-feature=+crt-static,+avx2"]
3+
4+
[target.x86_64-unknown-linux-gnu]
5+
rustflags = ["-Ctarget-feature=+avx2"]
6+
7+
[target.x86_64-apple-darwin]
8+
rustflags = [
9+
"-Ctarget-feature=+avx2",
10+
"-Clink-arg=-mmacosx-version-min=15.0",
11+
"-Clink-arg=-Wl,-rpath,@WORKSPACE_ROOT@/.pixi/envs/default/lib/"
12+
]
13+
14+
[target.aarch64-apple-darwin]
15+
rustflags = [
16+
"-Clink-arg=-mmacosx-version-min=15.0",
17+
"-Clink-arg=-Wl,-rpath,@WORKSPACE_ROOT@/.pixi/envs/default/lib/"
18+
]
19+
20+
[target.'cfg(all())']
21+
rustflags = [
22+
"-Wclippy::all",
23+
"-Wclippy::await_holding_lock",
24+
"-Wclippy::char_lit_as_u8",
25+
"-Wclippy::checked_conversions",
26+
"-Wclippy::dbg_macro",
27+
"-Wclippy::debug_assert_with_mut_call",
28+
"-Wclippy::doc_markdown",
29+
"-Wclippy::empty_enum",
30+
"-Wclippy::enum_glob_use",
31+
"-Wclippy::expl_impl_clone_on_copy",
32+
"-Wclippy::explicit_deref_methods",
33+
"-Wclippy::explicit_into_iter_loop",
34+
"-Wclippy::fallible_impl_from",
35+
"-Wclippy::filter_map_next",
36+
"-Wclippy::flat_map_option",
37+
"-Wclippy::float_cmp_const",
38+
"-Wclippy::fn_params_excessive_bools",
39+
"-Wclippy::from_iter_instead_of_collect",
40+
"-Wclippy::if_let_mutex",
41+
"-Wclippy::implicit_clone",
42+
"-Wclippy::imprecise_flops",
43+
"-Wclippy::inefficient_to_string",
44+
"-Wclippy::invalid_upcast_comparisons",
45+
"-Wclippy::large_digit_groups",
46+
"-Wclippy::large_stack_arrays",
47+
"-Wclippy::large_types_passed_by_value",
48+
"-Wclippy::let_unit_value",
49+
"-Wclippy::linkedlist",
50+
"-Wclippy::lossy_float_literal",
51+
"-Wclippy::macro_use_imports",
52+
"-Wclippy::manual_ok_or",
53+
"-Wclippy::map_flatten",
54+
"-Wclippy::map_unwrap_or",
55+
"-Wclippy::match_on_vec_items",
56+
"-Wclippy::match_same_arms",
57+
"-Wclippy::match_wild_err_arm",
58+
"-Wclippy::match_wildcard_for_single_variants",
59+
"-Wclippy::mismatched_target_os",
60+
"-Wclippy::missing_enforced_import_renames",
61+
"-Wclippy::mut_mut",
62+
"-Wclippy::mutex_integer",
63+
"-Wclippy::needless_borrow",
64+
"-Wclippy::needless_continue",
65+
"-Wclippy::needless_for_each",
66+
"-Wclippy::option_option",
67+
"-Wclippy::path_buf_push_overwrite",
68+
"-Wclippy::ptr_as_ptr",
69+
"-Wclippy::rc_mutex",
70+
"-Wclippy::ref_option_ref",
71+
"-Wclippy::rest_pat_in_fully_bound_structs",
72+
"-Wclippy::same_functions_in_if_condition",
73+
"-Wclippy::semicolon_if_nothing_returned",
74+
"-Wclippy::single_match_else",
75+
"-Wclippy::string_add_assign",
76+
"-Wclippy::string_add",
77+
"-Wclippy::string_lit_as_bytes",
78+
"-Wclippy::string_to_string",
79+
"-Wclippy::todo",
80+
"-Wclippy::trait_duplication_in_bounds",
81+
"-Wclippy::unimplemented",
82+
"-Wclippy::unnested_or_patterns",
83+
"-Wclippy::unused_self",
84+
"-Wclippy::useless_transmute",
85+
"-Wclippy::verbose_file_reads",
86+
"-Wclippy::zero_sized_map_values",
87+
"-Wfuture_incompatible",
88+
"-Wnonstandard_style",
89+
]
90+
91+
[profile.profiling]
92+
inherits = "release"
93+
debug = true

.cargo/config.vcpkg.toml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
[env]
2+
GDAL_STATIC = "1"
3+
GDAL_HOME = { value = "target/vcpkg/installed/arm64-osx-release", relative = true }
4+
PKG_CONFIG = { value = "target/vcpkg/installed/arm64-osx-release/tools/pkgconf/pkgconf", relative = true }
5+
PKG_CONFIG_PATH = { value = "target/vcpkg/installed/arm64-osx-release/lib/pkgconfig", relative = true }
6+
PYO3_PYTHON = { value = ".pixi/envs/default/bin/python3", relative = true }
7+
8+
[target.x86_64-pc-windows-msvc]
9+
rustflags = ["-C", "target-feature=+crt-static,+avx2"]
10+
11+
[target.x86_64-unknown-linux-gnu]
12+
rustflags = ["-Ctarget-feature=+avx2"]
13+
14+
[target.x86_64-apple-darwin]
15+
rustflags = [
16+
"-Ctarget-feature=+avx2",
17+
"-Clink-arg=-mmacosx-version-min=15.0",
18+
"-Clink-arg=-Wl,-rpath,/Users/dirk/Projects/geodynamix/.pixi/envs/default/lib/"
19+
]
20+
21+
[target.aarch64-apple-darwin]
22+
rustflags = [
23+
"-Clink-arg=-mmacosx-version-min=15.0",
24+
"-Clink-arg=-Wl,-rpath,/Users/dirk/Projects/geodynamix/.pixi/envs/default/lib/"
25+
]
26+
27+
[target.'cfg(all())']
28+
rustflags = [
29+
"-Wclippy::all",
30+
"-Wclippy::await_holding_lock",
31+
"-Wclippy::char_lit_as_u8",
32+
"-Wclippy::checked_conversions",
33+
"-Wclippy::dbg_macro",
34+
"-Wclippy::debug_assert_with_mut_call",
35+
"-Wclippy::doc_markdown",
36+
"-Wclippy::empty_enum",
37+
"-Wclippy::enum_glob_use",
38+
"-Wclippy::expl_impl_clone_on_copy",
39+
"-Wclippy::explicit_deref_methods",
40+
"-Wclippy::explicit_into_iter_loop",
41+
"-Wclippy::fallible_impl_from",
42+
"-Wclippy::filter_map_next",
43+
"-Wclippy::flat_map_option",
44+
"-Wclippy::float_cmp_const",
45+
"-Wclippy::fn_params_excessive_bools",
46+
"-Wclippy::from_iter_instead_of_collect",
47+
"-Wclippy::if_let_mutex",
48+
"-Wclippy::implicit_clone",
49+
"-Wclippy::imprecise_flops",
50+
"-Wclippy::inefficient_to_string",
51+
"-Wclippy::invalid_upcast_comparisons",
52+
"-Wclippy::large_digit_groups",
53+
"-Wclippy::large_stack_arrays",
54+
"-Wclippy::large_types_passed_by_value",
55+
"-Wclippy::let_unit_value",
56+
"-Wclippy::linkedlist",
57+
"-Wclippy::lossy_float_literal",
58+
"-Wclippy::macro_use_imports",
59+
"-Wclippy::manual_ok_or",
60+
"-Wclippy::map_flatten",
61+
"-Wclippy::map_unwrap_or",
62+
"-Wclippy::match_on_vec_items",
63+
"-Wclippy::match_same_arms",
64+
"-Wclippy::match_wild_err_arm",
65+
"-Wclippy::match_wildcard_for_single_variants",
66+
"-Wclippy::mismatched_target_os",
67+
"-Wclippy::missing_enforced_import_renames",
68+
"-Wclippy::mut_mut",
69+
"-Wclippy::mutex_integer",
70+
"-Wclippy::needless_borrow",
71+
"-Wclippy::needless_continue",
72+
"-Wclippy::needless_for_each",
73+
"-Wclippy::option_option",
74+
"-Wclippy::path_buf_push_overwrite",
75+
"-Wclippy::ptr_as_ptr",
76+
"-Wclippy::rc_mutex",
77+
"-Wclippy::ref_option_ref",
78+
"-Wclippy::rest_pat_in_fully_bound_structs",
79+
"-Wclippy::same_functions_in_if_condition",
80+
"-Wclippy::semicolon_if_nothing_returned",
81+
"-Wclippy::single_match_else",
82+
"-Wclippy::string_add_assign",
83+
"-Wclippy::string_add",
84+
"-Wclippy::string_lit_as_bytes",
85+
"-Wclippy::string_to_string",
86+
"-Wclippy::todo",
87+
"-Wclippy::trait_duplication_in_bounds",
88+
"-Wclippy::unimplemented",
89+
"-Wclippy::unnested_or_patterns",
90+
"-Wclippy::unused_self",
91+
"-Wclippy::useless_transmute",
92+
"-Wclippy::verbose_file_reads",
93+
"-Wclippy::zero_sized_map_values",
94+
"-Wfuture_incompatible",
95+
"-Wnonstandard_style",
96+
]
97+
98+
[profile.profiling]
99+
inherits = "release"
100+
debug = true

.config/mise.toml

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# Devenv configuration for building using vcpkg for native dependencies
2+
[tools]
3+
"cargo:cargo-vcpkg" = "latest"
4+
pixi = "latest"
5+
sd = "latest"
6+
fd = { version = "latest", os = ["windows"] }
7+
8+
[tools.rust]
9+
version = "1.89.0"
10+
profile = "minimal"
11+
targets = "wasm32-unknown-unknown{% if os() == 'macos' %},x86_64-apple-darwin{% endif %}"
12+
13+
[vars]
14+
build_target = """
15+
{%- if os() == "macos" and arch() == "arm64" -%}aarch64-apple-darwin
16+
{%- elif os() == "macos" and arch() == "x64" -%}x86_64-apple-darwin
17+
{%- elif os() == "linux" and arch() == "x64" -%}x86_64-unknown-linux-gnu
18+
{%- elif os() == "windows" and arch() == "x64" -%}x86_64-pc-windows-msvc
19+
{%- else -%}unsupported
20+
{%- endif -%}
21+
"""
22+
default_triplet = """
23+
{%- if os() == "macos" and arch() == "arm64" -%}arm64-osx-release
24+
{%- elif os() == "macos" and arch() == "x64" -%}x64-osx-release
25+
{%- elif os() == "linux" and arch() == "x64" -%}x64-linux-release
26+
{%- elif os() == "windows" and arch() == "x64" -%}x64-windows-static-release
27+
{%- else -%}unsupported
28+
{%- endif -%}
29+
"""
30+
python_exe = """
31+
{%- if os() == "windows"-%}python.exe
32+
{%- else -%}bin/python3
33+
{%- endif -%}
34+
"""
35+
36+
[env]
37+
CONDA_ENV = false
38+
VCPKG_ROOT = '{{config_root}}/target/vcpkg'
39+
VCPKG_OVERLAY_PORTS = '{{config_root}}/infra-rs/vcpkg-overlay/ports'
40+
VCPKG_FORCE_DOWNLOADED_BINARIES = '1'
41+
VCPKG_DEFAULT_HOST_TRIPLET = '{{vars.default_triplet}}'
42+
43+
# gdal-sys uses pkg-config to find the gdal library
44+
# the gdal.pc file contains shlwapi as link flag for the shlwapi library but this gets ignored
45+
# by the pkg-config crate implementation, so we need to replace it with a format (post_bootstrap) that is picked up by the crate
46+
# Warning: gdal fails to build when zstd is enabled and the CONDA_ENV enrironment variable is set
47+
[tasks.bootstrap]
48+
description = 'Vcpkg build'
49+
depends_post = ["post_bootstrap"]
50+
run = [
51+
"echo Setting up cargo vcpkg config...",
52+
"""
53+
{% set triplet_opt = option(name="triplet") | default(value="") %}
54+
{% set triplet = vars.default_triplet %}
55+
{% if triplet_opt != "" %}
56+
{% set triplet = triplet_opt %}
57+
{% endif %}
58+
echo Bootstrapping vcpkg:{{triplet}} on {{os()}} {{arch()}}... && \
59+
cp infra-rs/.cargo/config.toml.in .cargo/config.vcpkg.toml && \
60+
mise exec -E vcpkg -- sd @CARGO_VCPKG_TRIPLET@ {{triplet}} .cargo/config.vcpkg.toml && \
61+
mise exec -E vcpkg -- sd @CARGO_VCPKG_HOST_TRIPLET@ {{env.VCPKG_DEFAULT_HOST_TRIPLET}} .cargo/config.vcpkg.toml && \
62+
mise exec -E vcpkg -- sd @PYTHON_EXE@ {{vars.python_exe}} .cargo/config.vcpkg.toml
63+
""",
64+
'mise exec -E vcpkg -- sd @WORKSPACE_ROOT@ {{config_root | replace(from="\", to="/")}} .cargo/config.vcpkg.toml',
65+
"""
66+
{% set tgt = option(name="target") | default(value="") %}
67+
echo Vcpkg build for target {{tgt}}... && \
68+
cargo vcpkg -v build \
69+
{% if tgt != "" %}--target {{ tgt }}{% endif %}
70+
""",
71+
]
72+
73+
[tasks.post_bootstrap]
74+
description = 'Bootstrap the vcpkg dependencies'
75+
hide = true
76+
# in a seperate bat file because mise messess up the quoting of the fd arguments
77+
run_windows = [
78+
'cmd /c {{config_root}}/.config/vcpkg_win_tweaks.bat'
79+
]
80+
81+
[tasks.build]
82+
description = 'Build the workspace in the pixi environment'
83+
run = [
84+
"""
85+
{% set tgt = option(name="target") | default(value="") %}
86+
pixi run build
87+
"""
88+
]
89+
90+
[tasks.build_ci]
91+
description = 'Build the workspace with vcpkg dependencies'
92+
run = [
93+
'echo Building the workspace with vcpkg...',
94+
"""
95+
{% set tgt = option(name="target") | default(value="") %}
96+
cargo build --workspace \
97+
--config .cargo/config.vcpkg.toml \
98+
{% if tgt != "" %}--target {{ tgt }}{% endif %} \
99+
{% if flag(name='release') == "true" %}--release{% endif %} \
100+
--no-default-features \
101+
--features gdal-static,serde,derive,raster-io-geotiff,vector-io,rayon
102+
"""
103+
]
104+
105+
[tasks.test]
106+
description = 'Run the unit tests with vcpkg dependencies'
107+
run = [
108+
"""
109+
{% set tgt = option(name="target") | default(value="") %}
110+
cargo nextest run --config .cargo/config.vcpkg.toml \
111+
{% if flag(name='release') == "true" %}--release{% endif %} \
112+
{% if tgt != "" %}--target {{ tgt }}{% endif %} \
113+
--no-default-features --features=gdal-static,serde,derive,raster-io-geotiff,vector-io,polars,rayon
114+
"""
115+
]
116+
117+
[tasks.test_ci]
118+
description = 'Run the unit tests in the ci environment'
119+
run = [
120+
"""
121+
{% set tgt = option(name="target") | default(value="") %}
122+
cargo nextest run --profile ci --config .cargo/config.vcpkg.toml \
123+
{% if tgt != "" %}--target {{ tgt }}{% endif %} \
124+
{% if flag(name='release') == "true" %}--release{% endif %} \
125+
--no-default-features --features=gdal-static,serde,derive,raster-io-geotiff,vector-io,polars,rayon
126+
"""
127+
]
128+
129+
[tasks.test_integration]
130+
description = 'Run the unit tests in the ci environment'
131+
run = [
132+
"""
133+
{% set tgt = option(name="target") | default(value="") %}
134+
cargo nextest run --profile integration --config .cargo/config.vcpkg.toml \
135+
{% if tgt != "" %}--target {{ tgt }}{% endif %} \
136+
{% if flag(name='release') == "true" %}--release{% endif %} \
137+
--no-capture \
138+
--no-default-features --features=serde,gdal,gdal-static,derive,vector-processing,vector-io-xlsx,vector-io-csv,polars,rayon,proj4rs
139+
"""
140+
]
141+
142+
[tasks.test_py]
143+
description = 'Run the unit tests with vcpkg dependencies and python interop'
144+
depends = ['bootstrap_py']
145+
run = [
146+
"pixi run test_release"
147+
]
148+
149+
[tasks.doc]
150+
description = 'Generate the documentation'
151+
env.RUSTDOCFLAGS = '-D warnings --cfg docsrs'
152+
run = [
153+
'cargo +nightly doc --workspace --config .cargo/config.vcpkg.toml --exclude=infra-rs --exclude=vector_derive --no-deps --all-features',
154+
]

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,5 @@ standalone
2525
target
2626
*.so
2727
python/geodynamix.data/data/share/geodynamix/proj.db
28-
.cargo/config.toml
2928
*.pyd
3029
doc/_build

.zed/settings.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// For a full list of overridable settings, and general information on folder-specific settings,
2+
// see the documentation: https://zed.dev/docs/configuring-zed#settings-files
3+
{
4+
"file_scan_exclusions": [
5+
"**/.git",
6+
"**/.pixi",
7+
"**/.gitmodules",
8+
"**/.DS_Store",
9+
"**/Thumbs.db",
10+
"**/.settings",
11+
"**/.vscode"
12+
],
13+
"lsp": {
14+
"rust-analyzer": {
15+
"initialization_options": {
16+
"rust": {
17+
"analyzerTargetDir": true
18+
},
19+
"check": {
20+
"command": "clippy" // rust-analyzer.checkOnSave.command
21+
}
22+
}
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)