-
Notifications
You must be signed in to change notification settings - Fork 591
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
Support building a pip package using scikit-build #559
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
cmake_minimum_required(VERSION 3.18...3.22) | ||
|
||
project(_nlopt) | ||
|
||
find_package(PythonExtensions REQUIRED) | ||
find_package (NumPy REQUIRED) | ||
find_package (SWIG 3) | ||
include (UseSWIG) | ||
|
||
# Find NLopt C++ package | ||
set (NLopt_ROOT @CMAKE_CURRENT_BINARY_DIR@/../../) | ||
find_package (NLopt CONFIG REQUIRED) | ||
|
||
set (SWIG_MODULE__nlopt_EXTRA_DEPS nlopt-python.i numpy.i) | ||
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. Couldn't this depend on 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. I spent quite some time trying to set up paths correctly, but couldn't figure out how to do it. |
||
set_source_files_properties (nlopt.i PROPERTIES CPLUSPLUS ON) | ||
swig_add_library (_nlopt LANGUAGE python SOURCES nlopt.i) | ||
set_property(TARGET _nlopt PROPERTY SWIG_INCLUDE_DIRECTORIES $<TARGET_PROPERTY:NLopt::nlopt,INTERFACE_INCLUDE_DIRECTORIES>) | ||
target_include_directories(_nlopt PRIVATE ${NumPy_INCLUDE_DIRS}) | ||
target_link_libraries(_nlopt NLopt::nlopt) | ||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/__init__.py "from .nlopt import *") | ||
|
||
python_extension_module(_nlopt) | ||
install(TARGETS _nlopt LIBRARY DESTINATION nlopt) | ||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/nlopt.py DESTINATION nlopt) | ||
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/__init__.py DESTINATION nlopt) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from skbuild import setup | ||
|
||
setup( | ||
name = 'nlopt', | ||
version = '@NLOPT_MAJOR_VERSION@.@NLOPT_MINOR_VERSION@.@NLOPT_BUGFIX_VERSION@', | ||
packages = ['nlopt'], | ||
zip_safe = False | ||
) |
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.
Is there a good reason why these have to be copied? Why can't they be used directly from the source dir?