Skip to content

Commit c14c1d5

Browse files
committed
✨ Enhance FastPointQuery module by adding missing Python packages and improving initialization logging.
1 parent f8359ad commit c14c1d5

3 files changed

Lines changed: 39 additions & 14 deletions

File tree

src/FastPointQuery.jl

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
module FastPointQuery
22

3-
using CondaPkg, Downloads, PythonCall
3+
using CondaPkg, Downloads, Logging, PrecompileTools, PythonCall
44

55
# Python packages
6-
const np = PythonCall.pynew()
7-
const shapely = PythonCall.pynew()
8-
const o3d = PythonCall.pynew()
9-
const trimesh = PythonCall.pynew()
10-
const rasterio = PythonCall.pynew()
11-
const pyjson = PythonCall.pynew()
6+
const np = PythonCall.pynew()
7+
const shapely = PythonCall.pynew()
8+
const o3d = PythonCall.pynew()
9+
const trimesh = PythonCall.pynew()
10+
const rasterio = PythonCall.pynew()
11+
const pyjson = PythonCall.pynew()
12+
const splashsurf = PythonCall.pynew()
13+
const meshio = PythonCall.pynew()
1214

1315
# Python subpackages
1416
const rasterize = PythonCall.pynew()
@@ -23,12 +25,14 @@ const res_dir = joinpath(@__DIR__, "../example")
2325
function __init__()
2426
@info "initializing environment..."
2527
try # import Python modules
26-
PythonCall.pycopy!(np , PythonCall.pyimport("numpy" ))
27-
PythonCall.pycopy!(shapely , PythonCall.pyimport("shapely" ))
28-
PythonCall.pycopy!(o3d , PythonCall.pyimport("open3d" ))
29-
PythonCall.pycopy!(trimesh , PythonCall.pyimport("trimesh" ))
30-
PythonCall.pycopy!(rasterio, PythonCall.pyimport("rasterio"))
31-
PythonCall.pycopy!(pyjson , PythonCall.pyimport("json" ))
28+
PythonCall.pycopy!(np , PythonCall.pyimport("numpy" ))
29+
PythonCall.pycopy!(shapely , PythonCall.pyimport("shapely" ))
30+
PythonCall.pycopy!(o3d , PythonCall.pyimport("open3d" ))
31+
PythonCall.pycopy!(trimesh , PythonCall.pyimport("trimesh" ))
32+
PythonCall.pycopy!(rasterio , PythonCall.pyimport("rasterio" ))
33+
PythonCall.pycopy!(pyjson , PythonCall.pyimport("json" ))
34+
PythonCall.pycopy!(splashsurf, PythonCall.pyimport("pysplashsurf"))
35+
PythonCall.pycopy!(meshio , PythonCall.pyimport("meshio" ))
3236
# import submodules
3337
PythonCall.pycopy!(rasterize, pyimport("rasterio.features").rasterize)
3438
catch e
@@ -63,4 +67,14 @@ function get_resource()
6367
return model
6468
end
6569

70+
quiet(f) = redirect_stdout(devnull) do
71+
redirect_stderr(devnull) do
72+
with_logger(NullLogger()) do
73+
f()
74+
end
75+
end
76+
end
77+
78+
#include(joinpath(@__DIR__, "precompile.jl"))
79+
6680
end

src/precompile.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@setup_workload begin
2+
a = rand(3, 3)
3+
@compile_workload begin
4+
quiet() do
5+
#b = np.array(a)
6+
end
7+
end
8+
end

test/runtests.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,7 @@ using Test
88
@test !PythonCall.pyisnull(FastPointQuery.o3d )
99
@test !PythonCall.pyisnull(FastPointQuery.trimesh )
1010
@test !PythonCall.pyisnull(FastPointQuery.rasterio )
11-
@test !PythonCall.pyisnull(FastPointQuery.rasterize)
11+
@test !PythonCall.pyisnull(FastPointQuery.rasterize)
12+
@test !PythonCall.pyisnull(FastPointQuery.pyjson )
13+
@test !PythonCall.pyisnull(FastPointQuery.splashsurf)
14+
@test !PythonCall.pyisnull(FastPointQuery.meshio )

0 commit comments

Comments
 (0)