Skip to content
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

Commit C source [ctypes] #11

Open
maedoc opened this issue Feb 28, 2017 · 3 comments · May be fixed by #40
Open

Commit C source [ctypes] #11

maedoc opened this issue Feb 28, 2017 · 3 comments · May be fixed by #40
Assignees
Milestone

Comments

@maedoc
Copy link
Member

maedoc commented Feb 28, 2017

Cython is a largish, dev-time dependency in many cases. It would be an added convenience to commit the C sources to Git repo, also pushing them to PyPI.

@ayan-b
Copy link
Member

ayan-b commented Mar 21, 2020

Hi @maedoc,

Can you please explain a little what you mean by Commit C source?

Thanks!

@maedoc
Copy link
Member Author

maedoc commented Mar 23, 2020

hi @ayan-b this was a while ago, but I meant creating simpler bindings, in particular from a build perspective. A small C++ library with a C API for using the geodesic functions, which can be used by Python via ctypes module:

#include <geodesic_xyz.hpp>
extern "C" {
  int geodesic_compute_distances(int n_vtx, int n_tri, float *vtx, int *tri, float *gdist_mat);
}

Compiling this,

g++ -o gdist_c_api.o gdist_c_api.cpp
g++ -shared gdist_c_api.o -o gdist_c_api.so

then use from Python

import ctypes
lib = ctypes.DLL('./gdist_c_api.so')
# build numpy arrays etc
lib.geodesic_compute_distances(vtx.shape[0], tri.shape[0], vtx, tri, gdist)

On all platforms, building a plain C++ library is easier than a Cython extension, so this should make builds (especially on Windows) easier. The resulting shared library can be built per platform into wheels and put on the PyPI.

@ayan-b
Copy link
Member

ayan-b commented Mar 25, 2020

@maedoc Thanks!

@ayan-b ayan-b linked a pull request Jun 16, 2020 that will close this issue
@liadomide liadomide added this to the GSOC2020 milestone Jun 23, 2020
@liadomide liadomide changed the title Commit C source Commit C source [ctypes] Jul 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants