diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index fa427d6..7858377 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -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 diff --git a/build_dependencies/install_windows.ps1 b/build_dependencies/install_windows.ps1 new file mode 100644 index 0000000..c0dbdc0 --- /dev/null +++ b/build_dependencies/install_windows.ps1 @@ -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!" diff --git a/pyproject.toml b/pyproject.toml index ac99b93..aba56a1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,8 +6,6 @@ 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" @@ -15,6 +13,11 @@ 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"] \ No newline at end of file +before-all = "powershell build_dependencies\\install_windows.ps1" +archs = ["AMD64"] +test-requires = "pytest" +test-command = "pytest {package}\\test" \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 58e63b5..aad6d41 100644 --- a/setup.cfg +++ b/setup.cfg @@ -40,7 +40,7 @@ install_requires = Cython [options.package_data] -* = *.pyx, *.pxd +* = *.pyx, *.pxd, *.dll [options.packages.find] where = src \ No newline at end of file diff --git a/setup.py b/setup.py index ab96748..a7fb666 100644 --- a/setup.py +++ b/setup.py @@ -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 @@ -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( [ @@ -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"], )