Skip to content

Commit 92a0993

Browse files
committed
Add windows build
1 parent 5036f4c commit 92a0993

5 files changed

Lines changed: 150 additions & 31 deletions

File tree

.github/workflows/wheels.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ jobs:
88
runs-on: ${{matrix.platform}}
99
strategy:
1010
matrix:
11-
platform: [ubuntu-latest, macos-latest] # [ubuntu-latest, macos-latest, windows-latest]
12-
python: [39]
11+
platform: [ubuntu-latest, macos-latest, windows-latest]
1312
steps:
1413
- uses: actions/checkout@v2
1514
- name: Build wheels
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<#
2+
Originally based on script written by Pebaz (https://github.com/Pebaz/python-fcl/blob/master/requirements/build_win32.ps1)
3+
but with many modification in order to use fcl 0.6.1 and install dependencies without admin rights.
4+
5+
This script builds fcl and it's dependencies for python-fcl on Windows.
6+
7+
It downloads, builds, installs, and then deletes:
8+
* fcl
9+
* libccd
10+
* eigen
11+
* octomap
12+
#>
13+
14+
$base_dir = Get-Location
15+
16+
# Create a directory that encapsulates all dependencies
17+
mkdir -p deps; Set-Location deps
18+
19+
# All compiled depencies will be install in following folder
20+
$install_dir = "$base_dir\deps\install"
21+
22+
23+
#------------------------------------------------------------------------------
24+
# Eigen
25+
Write-Host "Building Eigen"
26+
$eigen_ver = "3.3.9"
27+
Invoke-WebRequest -Uri https://gitlab.com/libeigen/eigen/-/archive/$eigen_ver/eigen-$eigen_ver.tar.gz -Outfile eigen-$eigen_ver.tar.gz
28+
tar -zxf "eigen-$eigen_ver.tar.gz"
29+
Set-Location "eigen-$eigen_ver"
30+
31+
cmake -B build `
32+
-D CMAKE_BUILD_TYPE=Release `
33+
-G "Visual Studio 16 2019" `
34+
-D BUILD_SHARED_LIBS=ON `
35+
-D CMAKE_INSTALL_PREFIX=$install_dir
36+
cmake --install build
37+
38+
Set-Location ..
39+
40+
41+
# ------------------------------------------------------------------------------
42+
# LibCCD
43+
Write-Host "Building LibCCD"
44+
git clone --depth 1 --branch v2.1 https://github.com/danfis/libccd
45+
Set-Location libccd
46+
47+
cmake -B build `
48+
-D CMAKE_BUILD_TYPE=Release `
49+
-G "Visual Studio 16 2019" `
50+
-D BUILD_SHARED_LIBS=ON `
51+
-D CMAKE_INSTALL_PREFIX=$install_dir
52+
cmake --build build --config Release --target install
53+
54+
Set-Location ..
55+
56+
57+
# ------------------------------------------------------------------------------
58+
# Octomap
59+
Write-Host "Building Octomap"
60+
git clone --depth 1 --branch v1.8.0 https://github.com/OctoMap/octomap
61+
Set-Location octomap
62+
63+
cmake -B build `
64+
-D CMAKE_PREFIX_PATH=$install_dir `
65+
-D CMAKE_BUILD_TYPE=Release `
66+
-G "Visual Studio 16 2019" `
67+
-D BUILD_SHARED_LIBS=ON `
68+
-D CMAKE_INSTALL_PREFIX=$install_dir `
69+
-D BUILD_OCTOVIS_SUBPROJECT=OFF `
70+
-D BUILD_DYNAMICETD3D_SUBPROJECT=OFF
71+
cmake --build build --config Release
72+
cmake --build build --config Release --target install
73+
74+
Set-Location ..
75+
76+
# ------------------------------------------------------------------------------
77+
# FCL
78+
Write-Host "Building FCL"
79+
git clone --depth 1 --branch v0.6.1 https://github.com/flexible-collision-library/fcl
80+
Set-Location fcl
81+
82+
cmake -B build `
83+
-D CMAKE_PREFIX_PATH=$install_dir `
84+
-D CMAKE_BUILD_TYPE=Release `
85+
-G "Visual Studio 16 2019" `
86+
-D CMAKE_INSTALL_PREFIX=$install_dir
87+
88+
cmake --build build --config Release --target install
89+
Write-Host "Done"
90+
Set-Location ..
91+
92+
# ------------------------------------------------------------------------------
93+
# Python-FCL
94+
95+
Write-Host "Copying dependent DLLs"
96+
Copy-Item $install_dir\bin\octomap.dll $base_dir\src\fcl
97+
Copy-Item $install_dir\bin\octomath.dll $base_dir\src\fcl
98+
Copy-Item $install_dir\bin\ccd.dll $base_dir\src\fcl
99+
100+
Set-Location $base_dir
101+
Write-Host "All done!"

pyproject.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@ build-backend = "setuptools.build_meta"
66
skip = "pp*"
77
before-build = "pip install numpy Cython"
88
manylinux-x86_64-image = "manylinux_2_24"
9-
# test-requires = "pytest"
10-
# test-command = "pytest {package}/test"
119

1210
[tool.cibuildwheel.linux]
1311
before-all = "bash build_dependencies/install_linux.sh"
1412
archs = ["x86_64"]
1513

1614
[tool.cibuildwheel.macos]
1715
before-all = "bash build_dependencies/install_macos.sh"
16+
test-requires = "pytest"
17+
test-command = "pytest {package}/test"
1818

1919
[tool.cibuildwheel.windows]
20-
archs = ["AMD64"]
20+
before-all = "powershell build_dependencies\\install_windows.ps1"
21+
archs = ["AMD64"]
22+
test-requires = "pytest"
23+
test-command = "pytest {package}\\test"

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ install_requires =
4040
Cython
4141

4242
[options.package_data]
43-
* = *.pyx, *.pxd
43+
* = *.pyx, *.pxd, *.dll
4444

4545
[options.packages.find]
4646
where = src

setup.py

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,34 @@
44
from setuptools import Extension, setup
55
from Cython.Build import cythonize
66

7+
INSTALL_PREFIX_WIN = "deps\\install"
78

8-
def get_include_dirs():
9-
platform_supported = False
9+
10+
def is_nix_platform(platform):
1011
for prefix in ["darwin", "linux", "bsd"]:
1112
if prefix in sys.platform:
12-
platform_supported = True
13-
include_dirs = [
14-
"/usr/include",
15-
"/usr/local/include",
16-
"/usr/include/eigen3",
17-
"/usr/local/include/eigen3",
18-
]
19-
20-
if "CPATH" in os.environ:
21-
include_dirs += os.environ["CPATH"].split(":")
22-
23-
break
24-
if sys.platform == "win32":
25-
platform_supported = False
26-
if not platform_supported:
13+
return True
14+
return False
15+
16+
17+
def get_include_dirs():
18+
if is_nix_platform(sys.platform):
19+
include_dirs = [
20+
"/usr/include",
21+
"/usr/local/include",
22+
"/usr/include/eigen3",
23+
"/usr/local/include/eigen3",
24+
]
25+
26+
if "CPATH" in os.environ:
27+
include_dirs += os.environ["CPATH"].split(":")
28+
29+
elif sys.platform == "win32":
30+
include_dirs = [
31+
f"{INSTALL_PREFIX_WIN}\\include",
32+
f"{INSTALL_PREFIX_WIN}\\include\\eigen3",
33+
]
34+
else:
2735
raise NotImplementedError(sys.platform)
2836

2937
# get the numpy include path from numpy
@@ -34,17 +42,25 @@ def get_include_dirs():
3442

3543

3644
def get_libraries_dir():
37-
for prefix in ["darwin", "linux", "bsd"]:
38-
if prefix in sys.platform:
39-
platform_supported = True
40-
lib_dirs = ["/usr/lib", "/usr/local/lib"]
45+
if is_nix_platform(sys.platform):
46+
lib_dirs = ["/usr/lib", "/usr/local/lib"]
47+
48+
if "LD_LIBRARY_PATH" in os.environ:
49+
lib_dirs += os.environ["LD_LIBRARY_PATH"].split(":")
50+
return lib_dirs
51+
if sys.platform == "win32":
52+
return [f"{INSTALL_PREFIX_WIN}\\lib"]
4153

42-
if "LD_LIBRARY_PATH" in os.environ:
43-
lib_dirs += os.environ["LD_LIBRARY_PATH"].split(":")
44-
return lib_dirs
4554
raise NotImplementedError(sys.platform)
4655

4756

57+
def get_libraries():
58+
libraries = ["fcl", "octomap"]
59+
if sys.platform == "win32":
60+
libraries.extend(["octomath", "ccd", "vcruntime"])
61+
return libraries
62+
63+
4864
setup(
4965
ext_modules=cythonize(
5066
[
@@ -53,7 +69,7 @@ def get_libraries_dir():
5369
["src/fcl/fcl.pyx"],
5470
include_dirs=get_include_dirs(),
5571
library_dirs=get_libraries_dir(),
56-
libraries=["fcl", "octomap"],
72+
libraries=get_libraries(),
5773
language="c++",
5874
extra_compile_args=["-std=c++11"],
5975
)

0 commit comments

Comments
 (0)