Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
drlukeparry committed Jan 10, 2024
2 parents 7a78f39 + c1684ee commit db801bc
Show file tree
Hide file tree
Showing 8 changed files with 136 additions and 25 deletions.
32 changes: 31 additions & 1 deletion .github/workflows/pythonpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ on:

jobs:
deploy:

runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand Down Expand Up @@ -70,3 +69,34 @@ jobs:
run: |
python3 -m twine upload dist/*
deploySource:
needs: deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Display Python version
run: python3 -c "import sys; print(sys.version)"
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
pip3 install setuptools wheel twine
- name: Install APT On Linux
run: |
sudo apt-get update -qq -y
sudo apt-get install -qq -y libglu1-mesa build-essential libeigen3-dev
- name: Build
run: |
python3 setup.py sdist
- name: Publish (Source)
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload dist/*
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,18 @@ All notable changes to this project will be documented in this file.

### Changed

## [0.1.7] - 2024-01-11

## [0.1.6] - 2023-16-12
### Added
- Updated build script to prepare source distribution (Linux)
- Script automatically pulls the specified submodule versions in setup.py

### Fixed
- Fixed old references to original build-scripts
- Fixed the external submodules (clipper2, pybind, eigen) to fixed version for reference
- Fixed a build issue with latest ClipperLib (PreserveCollinear property has become a protected member)

## [0.1.6] - 2023-12-16

### Added

Expand Down
19 changes: 7 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ link_directories(
)

if(BUILD_PYTHON)
message(STATUS "Building PyCork Python Module")
message(STATUS "Building PyClipr Python Module")

add_subdirectory(external/pybind11)

Expand Down Expand Up @@ -202,40 +202,35 @@ else(BUILD_PYTHON)
endif(BUILD_PYTHON)

set(App_SRCS
cork/main.cpp
main.cpp
)

SOURCE_GROUP("App" FILES ${App_SRCS})

if(BUILD_PYTHON)

set(PYCORK_SRCS
set(PYCLIPR_SRCS
python/pyclipr/module.cpp
)

SOURCE_GROUP("Python" FILES ${PYCORK_SRCS})
SOURCE_GROUP("Python" FILES ${PYCLIPR_SRCS})

pybind11_add_module(pyclipr ${PYCORK_SRCS})
pybind11_add_module(pyclipr ${PYCLIPR_SRCS})

#add_library(example MODULE main.cpp)

target_link_libraries(pyclipr PRIVATE pybind11::module clipr_static ${PYCORK_LIBS})
target_link_libraries(pyclipr PRIVATE pybind11::module clipr_static ${PYCLIPR_LIBS})

set_target_properties(pyclipr PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}"
SUFFIX "${PYTHON_MODULE_EXTENSION}")


#add_executable(main ${App_SRCS})

#target_link_libraries(main clipr_static ${PYCLIPR_LIBS})

install(TARGETS pyclipr DESTINATION lib/pyclipr)


else(BUILD_PYTHON)

add_executable(main ${App_SRCS})
target_link_libraries(main clipr ${PYCORK_LIBS})
target_link_libraries(main clipr ${PYCLIPR_LIBS})

#install(TARGETS mpir DESTINATION )

Expand Down
6 changes: 3 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ include LICENSE
include README.rst
include CHANGELOG.md
include CMakeLists.txt
graft external/*
graft CMake/*

include python/pyclipr
recursive-include external *
include python/pyclipr/*

2 changes: 1 addition & 1 deletion external/clipper2
Submodule clipper2 updated 75 files
+13 −4 CPP/BenchMark/CMakeLists.txt
+329 −0 CPP/BenchMark/PointInPolygonBenchmark.cpp
+1 −1 CPP/BenchMark/StripDuplicateBenchmark.cpp
+36 −17 CPP/CMakeLists.txt
+82 −70 CPP/Clipper2Lib/include/clipper2/clipper.core.h
+26 −15 CPP/Clipper2Lib/include/clipper2/clipper.engine.h
+305 −512 CPP/Clipper2Lib/include/clipper2/clipper.export.h
+62 −86 CPP/Clipper2Lib/include/clipper2/clipper.h
+2 −2 CPP/Clipper2Lib/include/clipper2/clipper.minkowski.h
+20 −14 CPP/Clipper2Lib/include/clipper2/clipper.offset.h
+2 −3 CPP/Clipper2Lib/include/clipper2/clipper.rectclip.h
+6 −0 CPP/Clipper2Lib/include/clipper2/clipper.version.h
+235 −182 CPP/Clipper2Lib/src/clipper.engine.cpp
+263 −195 CPP/Clipper2Lib/src/clipper.offset.cpp
+84 −50 CPP/Clipper2Lib/src/clipper.rectclip.cpp
+28 −22 CPP/Examples/Inflate/Inflate.cpp
+35 −9 CPP/Examples/VariableOffset/VariableOffset.cpp
+220 −0 CPP/Tests/TestExportHeaders.cpp
+2 −2 CPP/Tests/TestLines.cpp
+28 −15 CPP/Tests/TestOffsetOrientation.cpp
+582 −103 CPP/Tests/TestOffsets.cpp
+27 −16 CPP/Tests/TestPolygons.cpp
+273 −0 CPP/Tests/TestPolytreeHoles.cpp
+0 −31 CPP/Tests/TestPolytreeHoles1.cpp
+0 −132 CPP/Tests/TestPolytreeHoles2.cpp
+0 −25 CPP/Tests/TestPolytreeHoles3.cpp
+0 −26 CPP/Tests/TestPolytreeHoles4.cpp
+1 −1 CPP/Tests/TestPolytreeUnion.cpp
+2 −1 CPP/Tests/TestRandomPaths.cpp
+24 −0 CPP/Tests/TestRectClip.cpp
+14 −0 CPP/Tests/TestSimplifyPath.cpp
+8 −0 CPP/Tests/TestWindows.cpp
+8 −6 CPP/Utils/ClipFileSave.cpp
+8 −4 CPP/Utils/ClipFileSave.h
+10 −0 CPP/Utils/CommonUtils.h
+38 −45 CPP/Utils/Timer.h
+10 −8 CPP/Utils/clipper.svg.cpp
+6 −0 CPP/clipper.version.in
+54 −25 CSharp/Clipper2Lib.Examples/InflateDemo/Main.cs
+74 −75 CSharp/Clipper2Lib/Clipper.Core.cs
+151 −91 CSharp/Clipper2Lib/Clipper.Engine.cs
+276 −179 CSharp/Clipper2Lib/Clipper.Offset.cs
+102 −61 CSharp/Clipper2Lib/Clipper.RectClip.cs
+42 −52 CSharp/Clipper2Lib/Clipper.cs
+ CSharp/Clipper2Lib/Clipper2.snk
+31 −33 CSharp/Clipper2Lib/Clipper2Lib.csproj
+126 −0 CSharp/Clipper2Lib/HashCode.cs
+79 −0 CSharp/USINGZ.TestApp/Program.cs
+23 −0 CSharp/USINGZ.TestApp/UsingZTestApp.csproj
+31 −0 CSharp/USINGZ.TestApp/UsingZ_TestApp.sln
+8 −3 CSharp/USINGZ/Clipper2LibZ.csproj
+15 −15 CSharp/Utils/ClipFileIO/Clipper.FileIO.csproj
+1 −1 CSharp/Utils/Colors/Clipper.Colors.csproj
+1 −1 CSharp/Utils/SVG/Clipper.SVG.cs
+14 −12 CSharp/Utils/SVG/Clipper2.SVG.csproj
+0 −0 DLL/CSharp_TestApp/COMPILE AND ADD Clipper2_64.dll HERE
+11 −0 DLL/CSharp_TestApp/CSharp_TestApp.csproj
+25 −0 DLL/CSharp_TestApp/CSharp_TestApp.sln
+291 −0 DLL/CSharp_TestApp/Program.cs
+ DLL/CSharp_TestApp/polytree_sample.png
+0 −0 DLL/CSharp_TestApp2/COMPILE AND ADD Clipper2_64.dll HERE
+16 −0 DLL/CSharp_TestApp2/CSharp_TestApp2.csproj
+63 −0 DLL/CSharp_TestApp2/CSharp_TestApp2.sln
+184 −0 DLL/CSharp_TestApp2/Program.cs
+0 −0 DLL/Delphi_TestApp/COMPILE AND ADD Clipper2_64.dll HERE
+307 −554 DLL/Delphi_TestApp/Test_DLL.dpr
+7 −0 DLL/ReadMe.md
+44 −22 Delphi/Clipper2Lib/Clipper.Core.pas
+270 −223 Delphi/Clipper2Lib/Clipper.Engine.pas
+314 −161 Delphi/Clipper2Lib/Clipper.Offset.pas
+127 −76 Delphi/Clipper2Lib/Clipper.RectClip.pas
+9 −9 Delphi/Clipper2Lib/Clipper.inc
+219 −121 Delphi/Clipper2Lib/Clipper.pas
+33 −0 Delphi/Examples/Example1/Example1.dpr
+9 −7 README.md
4 changes: 2 additions & 2 deletions python/pyclipr/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,12 +576,12 @@ PYBIND11_MODULE(pyclipr, m) {
.def_readwrite("scaleFactor", &pyclipr::Clipper::scaleFactor, R"(
Scale factor to be for transforming the input and output vectors. The default is 1000 )"
)
.def_readwrite("preserveCollinear", &pyclipr::Clipper::PreserveCollinear, R"(
.def_property("preserveCollinear", [](const pyclipr::Clipper &s ) { return s.PreserveCollinear();}
, [](pyclipr::Clipper &s, bool val ) { return s.PreserveCollinear(val);}, R"(
By default, when three or more vertices are collinear in input polygons (subject or clip),
the Clipper object removes the 'inner' vertices before clipping. When enabled the PreserveCollinear property
prevents this default behavior to allow these inner vertices to appear in the solution.
)" )
//.def("addPath", &pyclipr::Clipper::addPath)
.def("addPath", &pyclipr::Clipper::addPath, py::arg("path"), py::arg("pathType"), py::arg("isOpen") = false, R"(
The addPath method adds one or more closed subject paths (polygons) to the Clipper object.
Expand Down
84 changes: 80 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,23 @@
from setuptools.command.build_ext import build_ext
from distutils.version import LooseVersion

from setuptools.command.develop import develop
from setuptools.command.install import install
from setuptools.command.sdist import sdist
from setuptools.command.build_py import build_py
from setuptools import setup, find_packages
from subprocess import check_call, check_output

with open('README.rst') as f:
readme = f.read()

""" Specific versions of submodules to use. """

submoduleVersions = {
'clipper2': 'Clipper2_1.3.0',
'pybind11': 'v2.11',
'eigen': '3.4'
}

class CMakeExtension(Extension):
def __init__(self, name, modName, sourcedir=''):
Expand All @@ -22,8 +35,64 @@ def __init__(self, name, modName, sourcedir=''):
self.sourcedir = os.path.abspath(sourcedir)


def gitcmd_update_submodules():
"""
Check if the package is being deployed as a git repository. If so, recursively update all dependencies.
"""

if os.path.exists('.git'):

check_call(['git', 'submodule', 'update', '--init', '--recursive'])

# set all versions as required
curPath = os.path.abspath('.')

for k, v in submoduleVersions.items():
modPath = os.path.abspath('{:s}/external/{:s}'.format(curPath, k))
check_call(['git', 'checkout', v], cwd=modPath)


check_call(['git', 'submodule', 'status'])

return True

return False


class gitcmd_develop(develop):
"""
Specialized packaging class that runs `git submodule update --init --recursive`
as part of the update/install procedure.
"""
def run(self):
gitcmd_update_submodules()
develop.run(self)


class gitcmd_install(install):
"""
Specialized packaging class that runs `git submodule update --init --recursive`
as part of the update/install procedure.
"""
def run(self):
gitcmd_update_submodules()
install.run(self)

class gitcmd_sdist(sdist):
"""
Specialized packaging class that runs git submodule update --init --recursive
as part of the update/install procedure;.
"""
def run(self):
gitcmd_update_submodules()
sdist.run(self)

class CMakeBuild(build_ext):
def run(self):

# Update the submodules to the correct version
gitcmd_update_submodules()

try:
out = subprocess.check_output(['cmake', '--version'])
except OSError:
Expand All @@ -39,6 +108,11 @@ def run(self):
self.build_extension(ext)

def build_extension(self, ext):
"""
Builds the following CMake extension within the project tree
:param ext: CMake Extension to build
"""
print('ext_full_path', self.get_ext_fullpath(ext.name))
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))
# required for auto-detection of auxiliary "native" libs
Expand Down Expand Up @@ -71,20 +145,22 @@ def build_extension(self, ext):
subprocess.check_call(['cmake', ext.sourcedir] + cmake_args, cwd=self.build_temp, env=env)
subprocess.check_call(['cmake', '--build', '.', '--target', ext.modName] + build_args, cwd=self.build_temp)

# subprocess.check_call(['cmake', '--build', '.', '--target', 'install'], cwd=self.build_temp)


setup(
name='pyclipr',
version='0.1.6',
version='0.1.7',
author='Luke Parry',
author_email='[email protected]',
url='https://github.com/drlukeparry/pyclipr',
long_description=readme,
long_description_content_type = 'text/x-rst',
description='Python library for polygon clipping and offsetting based on Clipper2.',
ext_modules=[CMakeExtension('pyclipr.pyclipr', 'pyclipr')],
cmdclass=dict(build_ext=CMakeBuild),
cmdclass= {
'build_ext': CMakeBuild,
'develop': gitcmd_develop,
'sdist': gitcmd_sdist,
},
packages = ['pyclipr'],
package_dir={'': 'python'},
keywords=['polygon clipping', 'polygon offsetting', 'libClipper', 'Clipper2', 'polygon boolean', 'polygon', 'line clipping', 'clipper'],
Expand Down

0 comments on commit db801bc

Please sign in to comment.