-
Notifications
You must be signed in to change notification settings - Fork 159
Add options to conditionally include Python #196
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
Conversation
|
I think the error to install pytorch is unrelated to this change. But we still might need to modify: Line 37 in fe8c3ce
to add the |
rusty1s
left a comment
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.
Thank you. This looks good. Left a few comments.
As you pointed out, we also need to set WITH_PYTHON by default in setup.py.
| @@ -0,0 +1,9 @@ | |||
|
|
|||
| #include <torch/torch.h> | |||
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.
Why do we now include torch.h rather than extension.h?
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.
extension.h includes Python.h so at least in the non-python builds we can't have it.
However the library doesn't seem to use any <torch/python.h> features as operators seem to be exported via RegisterOperators.
We could still keep including extensions.h in the Python builds and only remove them in the non-python builds if you think it's safer. What do you think?
| #include <torch/torch.h> | ||
|
|
||
| // for getpid() | ||
| #ifdef _WIN32 |
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.
Why do we need those?
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.
For some reason, including torch/python.h leaks the getpid() headers. Those headers are not included in torch/torch.h so we had to manually add them as getpid() is used for random seed initialization in a few operators.
Since getpid() is OS specific we have to include different headers on Unix and Windows.
Codecov Report
@@ Coverage Diff @@
## master #196 +/- ##
=======================================
Coverage 72.32% 72.32%
=======================================
Files 28 28
Lines 1120 1120
=======================================
Hits 810 810
Misses 310 310 Continue to review full report at Codecov.
|
rusty1s
left a comment
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.
Thank you!
Hi everyone!
Thanks for this amazing package!
I'm working on a port of pytorch_sparse for the R language so users can benefit of the sparse operators together with torch. The current version lives in this repo.
It would be nice though if one could use the C++ library without linking to Python.
This PR adds a CMake option
WITH_PYTHONthat when set toOFFallows the package to be built entirely without linking to Python. By default, we tried to keep the same behavior, link to Python and includePython.hheaders.