Skip to content

Commit

Permalink
Add windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrilWaechter committed Jul 27, 2021
1 parent dffe2cc commit 9c2fb13
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 31 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ jobs:
runs-on: ${{matrix.platform}}
strategy:
matrix:
platform: [ubuntu-latest, macos-latest] # [ubuntu-latest, macos-latest, windows-latest]
python: [39]
platform: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v2
- name: Build wheels
Expand Down
101 changes: 101 additions & 0 deletions build_dependencies/install_windows.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
<#
Originally based on script written by Pebaz (https://github.com/Pebaz/python-fcl/blob/master/requirements/build_win32.ps1)
but with many modification in order to use fcl 0.6.1 and install dependencies without admin rights.
This script builds fcl and it's dependencies for python-fcl on Windows.
It downloads, builds, installs, and then deletes:
* fcl
* libccd
* eigen
* octomap
#>

$base_dir = Get-Location

# Create a directory that encapsulates all dependencies
mkdir -p deps; Set-Location deps

# All compiled depencies will be install in following folder
$install_dir = "$base_dir\deps\install"


#------------------------------------------------------------------------------
# Eigen
Write-Host "Building Eigen"
$eigen_ver = "3.3.9"
Invoke-WebRequest -Uri https://gitlab.com/libeigen/eigen/-/archive/$eigen_ver/eigen-$eigen_ver.tar.gz -Outfile eigen-$eigen_ver.tar.gz
tar -zxf "eigen-$eigen_ver.tar.gz"
Set-Location "eigen-$eigen_ver"

cmake -B build `
-D CMAKE_BUILD_TYPE=Release `
-G "Visual Studio 16 2019" `
-D BUILD_SHARED_LIBS=ON `
-D CMAKE_INSTALL_PREFIX=$install_dir
cmake --install build

Set-Location ..


# ------------------------------------------------------------------------------
# LibCCD
Write-Host "Building LibCCD"
git clone --depth 1 --branch v2.1 https://github.com/danfis/libccd
Set-Location libccd

cmake -B build `
-D CMAKE_BUILD_TYPE=Release `
-G "Visual Studio 16 2019" `
-D BUILD_SHARED_LIBS=ON `
-D CMAKE_INSTALL_PREFIX=$install_dir
cmake --build build --config Release --target install

Set-Location ..


# ------------------------------------------------------------------------------
# Octomap
Write-Host "Building Octomap"
git clone --depth 1 --branch v1.8.0 https://github.com/OctoMap/octomap
Set-Location octomap

cmake -B build `
-D CMAKE_PREFIX_PATH=$install_dir `
-D CMAKE_BUILD_TYPE=Release `
-G "Visual Studio 16 2019" `
-D BUILD_SHARED_LIBS=ON `
-D CMAKE_INSTALL_PREFIX=$install_dir `
-D BUILD_OCTOVIS_SUBPROJECT=OFF `
-D BUILD_DYNAMICETD3D_SUBPROJECT=OFF
cmake --build build --config Release
cmake --build build --config Release --target install

Set-Location ..

# ------------------------------------------------------------------------------
# FCL
Write-Host "Building FCL"
git clone --depth 1 --branch v0.6.1 https://github.com/flexible-collision-library/fcl
Set-Location fcl

cmake -B build `
-D CMAKE_PREFIX_PATH=$install_dir `
-D CMAKE_BUILD_TYPE=Release `
-G "Visual Studio 16 2019" `
-D CMAKE_INSTALL_PREFIX=$install_dir

cmake --build build --config Release --target install
Write-Host "Done"
Set-Location ..

# ------------------------------------------------------------------------------
# Python-FCL

Write-Host "Copying dependent DLLs"
Copy-Item $install_dir\bin\octomap.dll $base_dir\src\fcl
Copy-Item $install_dir\bin\octomath.dll $base_dir\src\fcl
Copy-Item $install_dir\bin\ccd.dll $base_dir\src\fcl

Set-Location $base_dir
Write-Host "All done!"
9 changes: 6 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ build-backend = "setuptools.build_meta"
skip = "pp*"
before-build = "pip install numpy Cython"
manylinux-x86_64-image = "manylinux_2_24"
# test-requires = "pytest"
# test-command = "pytest {package}/test"

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

[tool.cibuildwheel.macos]
before-all = "bash build_dependencies/install_macos.sh"
test-requires = "pytest"
test-command = "pytest {package}/test"

[tool.cibuildwheel.windows]
archs = ["AMD64"]
before-all = "powershell build_dependencies\\install_windows.ps1"
archs = ["AMD64"]
test-requires = "pytest"
test-command = "pytest {package}\\test"
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ install_requires =
Cython

[options.package_data]
* = *.pyx, *.pxd
* = *.pyx, *.pxd, *.dll

[options.packages.find]
where = src
66 changes: 41 additions & 25 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,34 @@
from setuptools import Extension, setup
from Cython.Build import cythonize

INSTALL_PREFIX_WIN = "deps\\install"

def get_include_dirs():
platform_supported = False

def is_nix_platform(platform):
for prefix in ["darwin", "linux", "bsd"]:
if prefix in sys.platform:
platform_supported = True
include_dirs = [
"/usr/include",
"/usr/local/include",
"/usr/include/eigen3",
"/usr/local/include/eigen3",
]

if "CPATH" in os.environ:
include_dirs += os.environ["CPATH"].split(":")

break
if sys.platform == "win32":
platform_supported = False
if not platform_supported:
return True
return False


def get_include_dirs():
if is_nix_platform(sys.platform):
include_dirs = [
"/usr/include",
"/usr/local/include",
"/usr/include/eigen3",
"/usr/local/include/eigen3",
]

if "CPATH" in os.environ:
include_dirs += os.environ["CPATH"].split(":")

elif sys.platform == "win32":
include_dirs = [
f"{INSTALL_PREFIX_WIN}\\include",
f"{INSTALL_PREFIX_WIN}\\include\\eigen3",
]
else:
raise NotImplementedError(sys.platform)

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


def get_libraries_dir():
for prefix in ["darwin", "linux", "bsd"]:
if prefix in sys.platform:
platform_supported = True
lib_dirs = ["/usr/lib", "/usr/local/lib"]
if is_nix_platform(sys.platform):
lib_dirs = ["/usr/lib", "/usr/local/lib"]

if "LD_LIBRARY_PATH" in os.environ:
lib_dirs += os.environ["LD_LIBRARY_PATH"].split(":")
return lib_dirs
if sys.platform == "win32":
return [f"{INSTALL_PREFIX_WIN}\\lib"]

if "LD_LIBRARY_PATH" in os.environ:
lib_dirs += os.environ["LD_LIBRARY_PATH"].split(":")
return lib_dirs
raise NotImplementedError(sys.platform)


def get_libraries():
libraries = ["fcl", "octomap"]
if sys.platform == "win32":
libraries.extend(["octomath", "ccd", "vcruntime"])
return libraries


setup(
ext_modules=cythonize(
[
Expand All @@ -53,7 +69,7 @@ def get_libraries_dir():
["src/fcl/fcl.pyx"],
include_dirs=get_include_dirs(),
library_dirs=get_libraries_dir(),
libraries=["fcl", "octomap"],
libraries=get_libraries(),
language="c++",
extra_compile_args=["-std=c++11"],
)
Expand Down

0 comments on commit 9c2fb13

Please sign in to comment.