Skip to content

Commit db801bc

Browse files
committed
Merge branch 'development'
2 parents 7a78f39 + c1684ee commit db801bc

File tree

8 files changed

+136
-25
lines changed

8 files changed

+136
-25
lines changed

.github/workflows/pythonpublish.yml

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ on:
99

1010
jobs:
1111
deploy:
12-
1312
runs-on: ${{ matrix.os }}
1413
strategy:
1514
matrix:
@@ -70,3 +69,34 @@ jobs:
7069
run: |
7170
python3 -m twine upload dist/*
7271
72+
deploySource:
73+
needs: deploy
74+
runs-on: ubuntu-latest
75+
steps:
76+
- uses: actions/checkout@v2
77+
with:
78+
submodules: recursive
79+
- name: Set up Python
80+
uses: actions/setup-python@v1
81+
with:
82+
python-version: 3.8
83+
- name: Display Python version
84+
run: python3 -c "import sys; print(sys.version)"
85+
- name: Install dependencies
86+
run: |
87+
python3 -m pip install --upgrade pip
88+
pip3 install setuptools wheel twine
89+
- name: Install APT On Linux
90+
run: |
91+
sudo apt-get update -qq -y
92+
sudo apt-get install -qq -y libglu1-mesa build-essential libeigen3-dev
93+
- name: Build
94+
run: |
95+
python3 setup.py sdist
96+
97+
- name: Publish (Source)
98+
env:
99+
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
100+
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
101+
run: |
102+
twine upload dist/*

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,18 @@ All notable changes to this project will be documented in this file.
1010

1111
### Changed
1212

13+
## [0.1.7] - 2024-01-11
1314

14-
## [0.1.6] - 2023-16-12
15+
### Added
16+
- Updated build script to prepare source distribution (Linux)
17+
- Script automatically pulls the specified submodule versions in setup.py
18+
19+
### Fixed
20+
- Fixed old references to original build-scripts
21+
- Fixed the external submodules (clipper2, pybind, eigen) to fixed version for reference
22+
- Fixed a build issue with latest ClipperLib (PreserveCollinear property has become a protected member)
23+
24+
## [0.1.6] - 2023-12-16
1525

1626
### Added
1727

CMakeLists.txt

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ link_directories(
106106
)
107107

108108
if(BUILD_PYTHON)
109-
message(STATUS "Building PyCork Python Module")
109+
message(STATUS "Building PyClipr Python Module")
110110

111111
add_subdirectory(external/pybind11)
112112

@@ -202,40 +202,35 @@ else(BUILD_PYTHON)
202202
endif(BUILD_PYTHON)
203203

204204
set(App_SRCS
205-
cork/main.cpp
205+
main.cpp
206206
)
207207

208208
SOURCE_GROUP("App" FILES ${App_SRCS})
209209

210210
if(BUILD_PYTHON)
211211

212-
set(PYCORK_SRCS
212+
set(PYCLIPR_SRCS
213213
python/pyclipr/module.cpp
214214
)
215215

216-
SOURCE_GROUP("Python" FILES ${PYCORK_SRCS})
216+
SOURCE_GROUP("Python" FILES ${PYCLIPR_SRCS})
217217

218-
pybind11_add_module(pyclipr ${PYCORK_SRCS})
218+
pybind11_add_module(pyclipr ${PYCLIPR_SRCS})
219219

220220
#add_library(example MODULE main.cpp)
221221

222-
target_link_libraries(pyclipr PRIVATE pybind11::module clipr_static ${PYCORK_LIBS})
222+
target_link_libraries(pyclipr PRIVATE pybind11::module clipr_static ${PYCLIPR_LIBS})
223223

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

227-
228-
#add_executable(main ${App_SRCS})
229-
230-
#target_link_libraries(main clipr_static ${PYCLIPR_LIBS})
231-
232227
install(TARGETS pyclipr DESTINATION lib/pyclipr)
233228

234229

235230
else(BUILD_PYTHON)
236231

237232
add_executable(main ${App_SRCS})
238-
target_link_libraries(main clipr ${PYCORK_LIBS})
233+
target_link_libraries(main clipr ${PYCLIPR_LIBS})
239234

240235
#install(TARGETS mpir DESTINATION )
241236

MANIFEST.in

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ include LICENSE
22
include README.rst
33
include CHANGELOG.md
44
include CMakeLists.txt
5-
graft external/*
6-
graft CMake/*
75

8-
include python/pyclipr
6+
recursive-include external *
7+
include python/pyclipr/*
8+

external/clipper2

Submodule clipper2 updated 75 files

python/pyclipr/module.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,12 +576,12 @@ PYBIND11_MODULE(pyclipr, m) {
576576
.def_readwrite("scaleFactor", &pyclipr::Clipper::scaleFactor, R"(
577577
Scale factor to be for transforming the input and output vectors. The default is 1000 )"
578578
)
579-
.def_readwrite("preserveCollinear", &pyclipr::Clipper::PreserveCollinear, R"(
579+
.def_property("preserveCollinear", [](const pyclipr::Clipper &s ) { return s.PreserveCollinear();}
580+
, [](pyclipr::Clipper &s, bool val ) { return s.PreserveCollinear(val);}, R"(
580581
By default, when three or more vertices are collinear in input polygons (subject or clip),
581582
the Clipper object removes the 'inner' vertices before clipping. When enabled the PreserveCollinear property
582583
prevents this default behavior to allow these inner vertices to appear in the solution.
583584
)" )
584-
//.def("addPath", &pyclipr::Clipper::addPath)
585585
.def("addPath", &pyclipr::Clipper::addPath, py::arg("path"), py::arg("pathType"), py::arg("isOpen") = false, R"(
586586
The addPath method adds one or more closed subject paths (polygons) to the Clipper object.
587587

setup.py

Lines changed: 80 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,23 @@
88
from setuptools.command.build_ext import build_ext
99
from distutils.version import LooseVersion
1010

11+
from setuptools.command.develop import develop
12+
from setuptools.command.install import install
13+
from setuptools.command.sdist import sdist
14+
from setuptools.command.build_py import build_py
15+
from setuptools import setup, find_packages
16+
from subprocess import check_call, check_output
1117

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

21+
""" Specific versions of submodules to use. """
22+
23+
submoduleVersions = {
24+
'clipper2': 'Clipper2_1.3.0',
25+
'pybind11': 'v2.11',
26+
'eigen': '3.4'
27+
}
1528

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

2437

38+
def gitcmd_update_submodules():
39+
"""
40+
Check if the package is being deployed as a git repository. If so, recursively update all dependencies.
41+
"""
42+
43+
if os.path.exists('.git'):
44+
45+
check_call(['git', 'submodule', 'update', '--init', '--recursive'])
46+
47+
# set all versions as required
48+
curPath = os.path.abspath('.')
49+
50+
for k, v in submoduleVersions.items():
51+
modPath = os.path.abspath('{:s}/external/{:s}'.format(curPath, k))
52+
check_call(['git', 'checkout', v], cwd=modPath)
53+
54+
55+
check_call(['git', 'submodule', 'status'])
56+
57+
return True
58+
59+
return False
60+
61+
62+
class gitcmd_develop(develop):
63+
"""
64+
Specialized packaging class that runs `git submodule update --init --recursive`
65+
as part of the update/install procedure.
66+
"""
67+
def run(self):
68+
gitcmd_update_submodules()
69+
develop.run(self)
70+
71+
72+
class gitcmd_install(install):
73+
"""
74+
Specialized packaging class that runs `git submodule update --init --recursive`
75+
as part of the update/install procedure.
76+
"""
77+
def run(self):
78+
gitcmd_update_submodules()
79+
install.run(self)
80+
81+
class gitcmd_sdist(sdist):
82+
"""
83+
Specialized packaging class that runs git submodule update --init --recursive
84+
as part of the update/install procedure;.
85+
"""
86+
def run(self):
87+
gitcmd_update_submodules()
88+
sdist.run(self)
89+
2590
class CMakeBuild(build_ext):
2691
def run(self):
92+
93+
# Update the submodules to the correct version
94+
gitcmd_update_submodules()
95+
2796
try:
2897
out = subprocess.check_output(['cmake', '--version'])
2998
except OSError:
@@ -39,6 +108,11 @@ def run(self):
39108
self.build_extension(ext)
40109

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

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

77149
setup(
78150
name='pyclipr',
79-
version='0.1.6',
151+
version='0.1.7',
80152
author='Luke Parry',
81153
author_email='dev@lukeparry.uk',
82154
url='https://github.com/drlukeparry/pyclipr',
83155
long_description=readme,
84156
long_description_content_type = 'text/x-rst',
85157
description='Python library for polygon clipping and offsetting based on Clipper2.',
86158
ext_modules=[CMakeExtension('pyclipr.pyclipr', 'pyclipr')],
87-
cmdclass=dict(build_ext=CMakeBuild),
159+
cmdclass= {
160+
'build_ext': CMakeBuild,
161+
'develop': gitcmd_develop,
162+
'sdist': gitcmd_sdist,
163+
},
88164
packages = ['pyclipr'],
89165
package_dir={'': 'python'},
90166
keywords=['polygon clipping', 'polygon offsetting', 'libClipper', 'Clipper2', 'polygon boolean', 'polygon', 'line clipping', 'clipper'],

0 commit comments

Comments
 (0)