Skip to content

[GSoC 2020] Extending PCL for use with Python: Bindings generation using Pybind11 #4366

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

Open
wants to merge 234 commits into
base: master
Choose a base branch
from

Conversation

diivm
Copy link
Contributor

@diivm diivm commented Aug 29, 2020

PR for the project "Extending PCL for use with Python: Bindings generation using Pybind11" during GSoC 2020.

diivm added 30 commits May 22, 2020 03:35
@diivm diivm added the priority: gsoc Reason for prioritization label Aug 29, 2020
Copy link
Member

@kunaltyagi kunaltyagi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mark as default till other issues are cleared on your fork?

- name: Format with black
run: |
cd bindings/python
black .
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we run black on .dev/scripts too?

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.8"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? Can we have something like "latest" so we don't need to update the version?

@@ -0,0 +1,52 @@
name: Black Formatting

on: [push]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restrict to directories with python files

>
> Here, cloud needs to be a shared_ptr. That can be done in 2 ways
> 1. `cloud = pcl.PointCloud[pcl.PointXYZ]()` and the holder class as shared_ptr
> 2. `cloud = pcl.make_shared[pcl.PointXYZ]()` and holder class as void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cloud = pcl.make_shared[pcl.PointCloud[pcl.PointXYZ]]()

>
> Here, cloud needs to be a shared_ptr. That can be done in 2 ways
> 1. `cloud = pcl.PointCloud[pcl.PointXYZ]()` and the holder class as shared_ptr
> 2. `cloud = pcl.make_shared[pcl.PointXYZ]()` and holder class as void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

void and shared_ptr (back tick the classes)

@@ -0,0 +1,158 @@
## Python bindings
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this file be included in the PR as is or modified?

```

### json/*
- JSON o/p generated by `libclang.py`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

o/p?

- JSON o/p generated by `libclang.py`

### pybind11/*
- pybind11 cpp o/p generated by `generate_bindings.py`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

o/p?

Comment on lines +37 to +38
echo 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main' | sudo tee -a /etc/apt/sources.list
echo 'deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main' | sudo tee -a /etc/apt/sources.list
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kunaltyagi can/should these two bionic references be extrapolated to an outer scope/file now that we're merging with master?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace the name with lsb_release -cs and install lsb-release via apt

Class containing functions for generating bindings from AST info.

How to use:
- to_be_filled_after_updation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean after this merge or even later?



"""
TODO
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use sphinx supported semantics:

https://www.sphinx-doc.org/en/master/usage/extensions/todo.html

Also, add all TODOs as issues on PCL too (1 per area of interest)

assert delete_constructor["kind"] == "CONSTRUCTOR"
assert delete_constructor["name"] == "aClass"
assert delete_constructor["result_type"] == "void"
# no check available for deleted ctor analogous to `is_default_constructor`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO:

Add test for template instantiation parsing since that's bread and butter for PCL bindings

else:
args = None

args = parser.parse_args()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use parse_known_args() in order to compose together several parsers

output_filepath = utils.get_output_path(
source=source,
output_dir=utils.join_path(args.json_output_path, "json"),
split_from="pcl",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

split_from is another user input. This is technically base_path or something similar

- args: Parsed command line arguments
"""

if script == "parse":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use add_subparsers feature of argparse


### pybind11/*
- pybind11 cpp o/p generated by `generate_bindings.py`
- pybind11 C++ outupt generated by `generate_bindings.py`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo?

@Kaju-Bubanja
Copy link
Contributor

Kaju-Bubanja commented Sep 14, 2020

How is the state of this PR? The whole projects sounds amazing and looking at the commits it's looks quite promising. Based on the proposed timeline it should be close to completion? I'm starting a new project and wanted to use PCL. I thought I have to use C++, but looking at this, this looks like it could be the first Python binding that works.

@kunaltyagi
Copy link
Member

Glad you like this :)

Regarding usability: This is a WIP. There are some upstream clang issues (clang doesn't parse = delete;, etc.), some integration issues (no end-to-end cmake) and a few chinks to smoothen. If you tinker with this, you might get common module bound, but beyond that might be a bit difficult (since even we haven't experimented till there)

You're welcome to contribute to this to make it better, faster 😄

PS: This is product of an awesome GSoC project by @divmadan.

@Kaju-Bubanja
Copy link
Contributor

Thank you for the quick answer. Based on this I think I will have to go ahead with C++. Sadly my knowledge in the area of writing and getting bindings to work is non existent and I don't think I will get time to work on that.

@stale
Copy link

stale bot commented Dec 19, 2020

Marking this as stale due to 30 days of inactivity. Commenting or adding a new commit to the pull request will revert this.

@stale stale bot added the status: stale label Dec 19, 2020
@ArkaprabhaChakraborty
Copy link
Contributor

Is this complete? or are there any works left?

@stale stale bot removed the status: stale label Jan 12, 2022
@shelper
Copy link

shelper commented Feb 28, 2022

Is this complete? or are there any works left?

same question here, should this issue be closed by PointCloudLibrary/clang-bind#1 ?
or it is a different one? seems to me they are almost the same

@jiapei-nexera
Copy link

Is this still ongoing? 2 years already?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: gsoc Reason for prioritization
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants