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

Dev_pycpufit #125

Merged
merged 24 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,13 @@ if( PYTHONINTERP_FOUND )
add_python_launcher( RUN_PYTHON
"${CMAKE_SOURCE_DIR}/Gpufit/python"
"${Python_WORKING_DIRECTORY}"
)
add_custom_target( RUN_PYTHON_CPUFIT )
set_property( TARGET RUN_PYTHON_CPUFIT PROPERTY FOLDER CMakePredefinedTargets )
add_dependencies( RUN_PYTHON_CPUFIT Cpufit )
add_python_launcher( RUN_PYTHON_CPUFIT
"${CMAKE_SOURCE_DIR}/Cpufit/python"
"${Python_WORKING_DIRECTORY}"
)
endif()
endif()
Expand Down
1 change: 1 addition & 0 deletions Cpufit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ set_target_properties( Cpufit
#install( TARGETS Cpufit RUNTIME DESTINATION bin )

add_subdirectory( matlab )
add_subdirectory( python )
4 changes: 4 additions & 0 deletions Cpufit/cpufit.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#define VISIBLE
#endif

#ifdef __APPLE__
#define VISIBLE __attribute__((visibility("default")))
#endif

#include <cstddef>
#include "../Gpufit/constants.h"
#include "../Gpufit/definitions.h"
Expand Down
58 changes: 58 additions & 0 deletions Cpufit/python/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

# Python

# Python package

set( build_directory "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/pyCpufit" )
set( setup_files
"${CMAKE_CURRENT_SOURCE_DIR}/README.txt"
"${CMAKE_CURRENT_SOURCE_DIR}/setup.py"
"${CMAKE_CURRENT_SOURCE_DIR}/setup.cfg"
)
set( module_directory "${build_directory}/pycpufit" )
set( module_files
"${CMAKE_CURRENT_SOURCE_DIR}/pycpufit/__init__.py"
"${CMAKE_CURRENT_SOURCE_DIR}/pycpufit/cpufit.py"
"${CMAKE_CURRENT_SOURCE_DIR}/pycpufit/version.py"
)


set( binary $<TARGET_FILE:Cpufit> )


add_custom_target( PYTHON_PACKAGE_CPUFIT
COMMAND ${CMAKE_COMMAND} -E
remove_directory ${build_directory}
COMMAND ${CMAKE_COMMAND} -E
make_directory ${build_directory}
COMMAND ${CMAKE_COMMAND} -E
copy_if_different ${setup_files} ${build_directory}
COMMAND ${CMAKE_COMMAND} -E
make_directory ${module_directory}
COMMAND ${CMAKE_COMMAND} -E
copy_if_different ${module_files} ${module_directory}
COMMAND ${CMAKE_COMMAND} -E
copy_if_different ${binary} ${module_directory}
)

set_property( TARGET PYTHON_PACKAGE_CPUFIT PROPERTY FOLDER CMakePredefinedTargets )
add_dependencies( PYTHON_PACKAGE_CPUFIT Cpufit )

if( NOT PYTHONINTERP_FOUND )
message( STATUS "Python NOT found - skipping creation of Python wheel!" )
return()
endif()

# Python wheel (output name is incorrect, requires plattform tag, see packaging)

add_custom_target( PYTHON_WHEEL_CPUFIT ALL
COMMAND ${CMAKE_COMMAND} -E
chdir ${build_directory} "${PYTHON_EXECUTABLE}" setup.py clean --all
COMMAND ${CMAKE_COMMAND} -E
chdir ${build_directory} "${PYTHON_EXECUTABLE}" setup.py bdist_wheel
COMMENT "Preparing Python Wheel"
)
set_property( TARGET PYTHON_WHEEL_CPUFIT PROPERTY FOLDER CMakePredefinedTargets )
add_dependencies( PYTHON_WHEEL_CPUFIT PYTHON_PACKAGE_CPUFIT )

# add launcher to Python package
22 changes: 22 additions & 0 deletions Cpufit/python/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Python binding for the [Cpufit library](https://github.com/gpufit/Gpufit) which implements Levenberg Marquardt curve fitting in CUDA

Requirements

- Windows
- Python 2 or 3 with NumPy

Installation

Currently the wheel file has to be installed locally.

If NumPy is not yet installed, install it using pip from the command line

pip install numpy

Then install pyCpufit from the local folder via:

pip install --no-index --find-links=LocalPathToWheelFile pyCpufit

Examples

See project-root/examples/python folder. **Cpufit** examples begin with `cpufit_`.
1 change: 1 addition & 0 deletions Cpufit/python/pycpufit/__init__.py
Copy link
Contributor

Choose a reason for hiding this comment

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

building on linux this needed to be from .cpufit import * for me

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from cpufit import *
Loading