-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update CMake and setuptools logic for the Python bindings #233
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
bac5971
Restructure pybind11 to create and install a proper Python package
diegoferigo c462fb8
Update setuptools resources
diegoferigo e0e636e
Move pytest configuration to setup.cfg
diegoferigo fdc337f
Vendor CMake's FindPython3
diegoferigo 2aea66e
Update CMake project to use vendored FindPython3
diegoferigo be2b632
Update CI pipeline to install and test wheels for many Python versions
diegoferigo 1d7a1ef
Upload artifacts with sdist and wheels
diegoferigo 754d09c
Clone a complete git repo in CI
diegoferigo 02579ae
Update Python docs
diegoferigo 593182d
Remove requirements.txt
diegoferigo 280a56b
Update CONTRIBUTING.md
diegoferigo f434b75
rm FindPython module
artivis a12b09a
review python bindings install
artivis 7f56b47
update CI
artivis 9fcebfe
update gitignore
artivis 0d4d576
update python doc
artivis b55a7e6
Merge pull request #1 from artivis/feature/python_install
diegoferigo dc75455
Fix artifact name
diegoferigo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: release | ||
on: | ||
push: | ||
tags: | ||
- '*' | ||
pull_request: | ||
branches: | ||
- devel # master only when ready | ||
- master | ||
workflow_dispatch: | ||
|
||
jobs: | ||
|
||
build-sdist: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- run: git fetch --prune --unshallow | ||
|
||
- name: Install Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.6 | ||
|
||
- name: Setup apt | ||
run: | | ||
sudo apt update | ||
sudo apt install -y libeigen3-dev | ||
|
||
- name: Setup | ||
run: | | ||
python3 -m pip install --upgrade pip | ||
pip3 install build | ||
|
||
- name: Build sdist | ||
run: python3 -m build --sdist -o dist/ | ||
|
||
- name: Build wheel | ||
run: python3 -m build --wheel -o dist/ | ||
|
||
- name: Upload artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: dist | ||
path: dist/* | ||
# path: | | ||
# path/*.whl | ||
# path/*.tar.gz | ||
|
||
upload_pypi: | ||
needs: build-sdist | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- uses: actions/download-artifact@v2 | ||
with: | ||
name: dist | ||
path: dist | ||
|
||
- name: Inspect dist folder | ||
run: ls -lah dist/ | ||
|
||
# @todo: see https://github.com/diegoferigo/manif/pull/1#discussion_r668531581 | ||
# - uses: pypa/gh-action-pypi-publish@master | ||
# if: | | ||
# github.repository == 'artivis/manif' && | ||
# ((github.event_name == 'release' && github.event.action == 'published') || | ||
# (github.event_name == 'push' && github.ref == 'refs/heads/main')) | ||
# with: | ||
# user: __token__ | ||
# password: ${{ secrets.PYPI_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,4 @@ docs/m.css | |
*.so | ||
*__pycache__ | ||
.pytest_cache | ||
dist | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[build-system] | ||
requires = [ | ||
"wheel", | ||
"setuptools>=45", | ||
"setuptools_scm[toml]>=6.0", | ||
"ninja", | ||
"cmake>=3.18.2", | ||
artivis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"cmake-build-extension", | ||
"pybind11", | ||
] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[tool.setuptools_scm] | ||
local_scheme = "dirty-tag" |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
set(PYBIND11_CPP_STANDARD -std=c++11) | ||
pybind11_add_module(manifpy | ||
pybind11_add_module(manifpy MODULE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note to myself, |
||
bindings_rn.cpp | ||
bindings_so2.cpp | ||
bindings_so3.cpp | ||
|
@@ -17,3 +17,51 @@ target_compile_definitions(manifpy PRIVATE EIGEN_DEFAULT_TO_ROW_MAJOR) | |
set_property(TARGET manifpy PROPERTY CXX_STANDARD 11) | ||
set_property(TARGET manifpy PROPERTY CXX_STANDARD_REQUIRED ON) | ||
set_property(TARGET manifpy PROPERTY CXX_EXTENSIONS OFF) | ||
|
||
if (CALL_FROM_SETUP_PY) | ||
# cmake-build-extension sets the full absolute path as CMAKE_INSTALL_PREFIX. | ||
set(MANIFPY_INSTDIR "${CMAKE_INSTALL_PREFIX}") | ||
else() | ||
# 'distutils.sysconfig.get_python_lib' returns the absolute path of Python | ||
# by default a global location managed by the distro e.g. /usr/lib/python. | ||
# | ||
# pybind11 and FindPython3 set respectively PYTHON_SITE_PACKAGES/Python3_SITELIB | ||
# from 'distutils.sysconfig.get_python_lib' | ||
# | ||
# Those are especially annoying on Ubuntu since it has | ||
# some hardcoded paths in python3.x/site.py | ||
# | ||
# `sysconfig.get_path` may return paths that does not even exists. | ||
# | ||
# So below we retrieve the first site-package path from 'site.getsitepackages()'. | ||
|
||
execute_process( | ||
COMMAND | ||
${PYTHON_EXECUTABLE} -c "import site; print(site.getsitepackages()[0])" | ||
OUTPUT_VARIABLE _PYTHON_SITE_PACKAGE OUTPUT_STRIP_TRAILING_WHITESPACE | ||
) | ||
set(MANIFPY_INSTDIR "${_PYTHON_SITE_PACKAGE}/manifpy") | ||
endif() | ||
|
||
message(STATUS "Installing manifpy in ${MANIFPY_INSTDIR}") | ||
|
||
# Setup installation path | ||
install(TARGETS manifpy COMPONENT python DESTINATION "${MANIFPY_INSTDIR}") | ||
|
||
# Create the Python package in the build tree for testing purposes | ||
set(MANIFPY_BUILDDIR "${CMAKE_BINARY_DIR}/manifpy") | ||
set_target_properties( | ||
manifpy PROPERTIES | ||
OUTPUT_NAME _bindings | ||
LIBRARY_OUTPUT_DIRECTORY "${MANIFPY_BUILDDIR}") | ||
|
||
# Create the __init__.py file | ||
file( | ||
GENERATE | ||
OUTPUT "${MANIFPY_BUILDDIR}/__init__.py" | ||
CONTENT "from manifpy._bindings import *\n") | ||
|
||
# Install the __init__.py file | ||
install( | ||
FILES "${MANIFPY_BUILDDIR}/__init__.py" | ||
DESTINATION ${MANIFPY_INSTDIR}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the long term, you can consider using the official gitignore for Python:
https://github.com/github/gitignore/blob/master/Python.gitignore