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

Changing pycv into a proper python package #1134

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
73304a2
setting up a way for calling pycv wit the python module
Iximiel Oct 11, 2024
3754faf
Now pycv works with pip
Iximiel Oct 11, 2024
d15ab27
now the action is included within the wheel
Iximiel Oct 11, 2024
e99df2f
now pycv looks more like a package
Iximiel Oct 11, 2024
0484d68
Reordering the installation procedure
Iximiel Oct 11, 2024
2fa0fa3
added a sort of "FIND PLUMED" that does not work
Iximiel Oct 11, 2024
f64b088
some cleaning
Iximiel Oct 14, 2024
9112fa1
reorganized the code to try to work
Iximiel Oct 14, 2024
389e11a
bettwen naming
Iximiel Oct 14, 2024
a487595
setting up a second run option, adding an helper
Iximiel Oct 14, 2024
4b81b97
removed the self-import gor getting the path of pycv
Iximiel Oct 14, 2024
938228d
adding an example
Iximiel Oct 14, 2024
f237404
Better CMakefiles
Iximiel Oct 14, 2024
c5062fc
moving to a more "external" include fashion
Iximiel Oct 16, 2024
32041be
Now pycv seems to work again
Iximiel Oct 16, 2024
b9d1e0a
A more "canonical" CMake
Iximiel Oct 16, 2024
9dc5e48
now it shoudl work with plumed from pkg-config or not installed (just…
Iximiel Oct 16, 2024
8eb73c9
Restored the Makefile
Iximiel Oct 17, 2024
1c8737c
restoring the standalone tests
Iximiel Oct 17, 2024
62d8aba
resahping the python test
Iximiel Oct 17, 2024
287ae99
adding some extra tests
Iximiel Oct 17, 2024
557887b
updating the WF
Iximiel Oct 17, 2024
6e405e9
better makefile?
Iximiel Oct 17, 2024
840993e
addressing a problem with master
Iximiel Oct 18, 2024
a22dd66
Now pycv appears to load correcly
Iximiel Oct 18, 2024
b3e9f22
added an extra test
Iximiel Oct 18, 2024
a699ba5
set up aslo a few basic tests for pyfunc
Iximiel Oct 18, 2024
42a8dfc
updated the docker recipes with the new installation method of pycv
Iximiel Oct 18, 2024
e7012f7
using pip3 in the makefile
Iximiel Oct 21, 2024
4ab187d
sourcing the correct bashrc in rocky8
Iximiel Oct 21, 2024
cd5bd13
checking if changing env will make the CI pass
Iximiel Oct 21, 2024
34aeec9
now findplumed uses plumed--no-mpi
Iximiel Oct 21, 2024
ea2e77f
readding a donfiguration file
Iximiel Oct 22, 2024
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
5 changes: 4 additions & 1 deletion plugins/pycv/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/Makefile.conf
*.o
*.so
env
/env*/
/build*/
/dist*/
*.whl
96 changes: 96 additions & 0 deletions plugins/pycv/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
cmake_minimum_required(VERSION 3.15...3.27)
project(
${SKBUILD_PROJECT_NAME}
VERSION ${SKBUILD_PROJECT_VERSION}
LANGUAGES CXX)
set (CMAKE_CXX_STANDARD 17)

find_package(Python REQUIRED COMPONENTS Interpreter Development)
find_package(pybind11 CONFIG REQUIRED)
message(STATUS "pybind11 found: ${pybind11_VERSION}")

exec_program(plumed
ARGS info --include-dir
OUTPUT_VARIABLE PLUMED_INCLUDE_DIR
)

exec_program(plumed
ARGS info --configuration
OUTPUT_VARIABLE PLUMED_CONFIG
)
set(PLUMED_CXX_FLAGS "")
set(PLUMED_CPP_FLAGS "")
set(PLUMED_DYNAMIC_LIBS "")

string(REPLACE "\n" ";" ProcessFile_LINES "${PLUMED_CONFIG}")
foreach(_line ${ProcessFile_LINES})
# message(STATUS "Found PLUMED :${_line}")
if (${_line} MATCHES "CXXFLAGS=.*")
set(PLUMED_CXX_FLAGS ${_line})
string(REGEX REPLACE "CXXFLAGS= *" "" PLUMED_CXX_FLAGS ${PLUMED_CXX_FLAGS})
string(REPLACE " " ";" PLUMED_CXX_FLAGS ${PLUMED_CXX_FLAGS})
# message(STATUS "Found PLUMED CXX_FLAGS: \"${PLUMED_CXX_FLAGS}\"")
message(STATUS "Found PLUMED CXX_FLAGS: ")
foreach (_flag ${PLUMED_CXX_FLAGS})
message(STATUS " \"${_flag}\"")
endforeach()
endif()
if (${_line} MATCHES "CPPFLAGS=.*")
set(PLUMED_CPP_FLAGS ${_line})
string(REGEX REPLACE "CPPFLAGS= *" "" PLUMED_CPP_FLAGS ${PLUMED_CPP_FLAGS})
string(REPLACE "\\" "" PLUMED_CPP_FLAGS ${PLUMED_CPP_FLAGS})
string(REPLACE "-D" ";" PLUMED_CPP_FLAGS ${PLUMED_CPP_FLAGS})
# message(STATUS "Found PLUMED CPP_FLAGS: \"${PLUMED_CPP_FLAGS}\"")
message(STATUS "Found PLUMED CPP_FLAGS:")
foreach(_flag ${PLUMED_CPP_FLAGS})
message(STATUS " \"${_flag}\"")
endforeach()

endif()
if (${_line} MATCHES "DYNAMIC_LIBS=.*")
set(PLUMED_DYNAMIC_LIBS ${_line})
string(REGEX REPLACE "DYNAMIC_LIBS= *" "" PLUMED_DYNAMIC_LIBS ${PLUMED_DYNAMIC_LIBS})
string(REPLACE " " ";" PLUMED_DYNAMIC_LIBS ${PLUMED_DYNAMIC_LIBS})
# message(STATUS "Found PLUMED DYNAMIC_LIBS: \"${PLUMED_DYNAMIC_LIBS}\"")
message(STATUS "Found PLUMED DYNAMIC_LIBS:")
foreach(_flag ${PLUMED_DYNAMIC_LIBS})
message(STATUS " \"${_flag}\"")
endforeach()
endif()

endforeach()

message(STATUS "Plumed include dir: ${PLUMED_INCLUDE_DIR}")
set(CMAke__extra)
################################################################################
################################the pycv library################################
################################################################################
#TODO: remove the "lib" prefix
add_library(PythonCVInterface SHARED src/ActionWithPython.cpp src/PythonCVInterface.cpp src/PythonFunction.cpp)
#public, so they trickle down to the python module
target_compile_definitions(PythonCVInterface PUBLIC ${PLUMED_CPP_FLAGS})
get_target_property(COMPILE_DEFINITIONS PythonCVInterface COMPILE_DEFINITIONS)
message(STATUS "COMPILE_DEFINITIONS ${COMPILE_DEFINITIONS}")
target_compile_options(PythonCVInterface PUBLIC ${PLUMED_CXX_FLAGS})
target_link_libraries(PythonCVInterface PRIVATE pybind11::embed)
target_link_libraries(PythonCVInterface PUBLIC plumedKernel ${PLUMED_DYNAMIC_LIBS})
target_include_directories(PythonCVInterface PUBLIC src ${PLUMED_INCLUDE_DIR}/plumed)
#this removes the "lib" prefix
set_target_properties(PythonCVInterface PROPERTIES PREFIX "")

install(TARGETS PythonCVInterface DESTINATION pycv)

################################################################################
############################The pvCV companion module###########################
################################################################################

pybind11_add_module(plumedCommunications src/PlumedPythonEmbeddedModule.cpp)
#python_add_library(plumedCommunications MODULE PlumedPythonEmbeddedModule.cpp WITH_SOABI)
# target_link_libraries(plumedCommunications PRIVATE pybind11::headers)
#target_compile_definitions(plumedCommunications PUBLIC ${PLUMED_CPP_FLAGS})
target_link_libraries(plumedCommunications PUBLIC plumedKernel ${PLUMED_DYNAMIC_LIBS})
target_link_libraries(plumedCommunications PUBLIC PythonCVInterface)
target_include_directories(plumedCommunications PUBLIC src ${PLUMED_INCLUDE_DIR}/plumed)

# The install directory is the output (wheel) directory
install(TARGETS plumedCommunications DESTINATION .)
53 changes: 0 additions & 53 deletions plugins/pycv/Makefile

This file was deleted.

54 changes: 0 additions & 54 deletions plugins/pycv/compileConfiguration.sh

This file was deleted.

27 changes: 0 additions & 27 deletions plugins/pycv/prepareMakeForDevelop.sh

This file was deleted.

61 changes: 61 additions & 0 deletions plugins/pycv/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
[build-system]
requires = ["scikit-build-core>=0.10", "pybind11>=2.10.3,<=2.11.1", "numpy"]
build-backend = "scikit_build_core.build"


[project]
name = "pycv"
dependencies = [
"numpy",
"pybind11>=2.10.3,<=2.11.1"
]
version = "0.0.1"
description="PyCV support module for plumed"
readme = "README.md"
authors = [
{ name = "Toni Giorgino", email = "[email protected]" },
{ name = "Daniele Rapetti", email = "[email protected]" },
]
requires-python = ">=3.9"
classifiers = [
"Development Status :: 4 - Beta",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
]

[project.optional-dependencies]
test = ["pytest", "plumed"]

[project.scripts]
pycv = "pycv:main"

[tool.scikit-build]
wheel.expand-macos-universal-tags = true
minimum-version = "build-system.requires"


[tool.pytest.ini_options]
minversion = "8.0"
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
xfail_strict = true
log_cli_level = "INFO"
filterwarnings = [
"error",
"ignore::pytest.PytestCacheWarning",
]
testpaths = ["pythontests"]


[tool.cibuildwheel]
build-frontend = "build[uv]"
test-command = "pytest {project}/pythontests"
test-extras = ["test"]

[tool.cibuildwheel.pyodide]
build-frontend = {name = "build", args = ["--exports", "whole_archive"]}

4 changes: 4 additions & 0 deletions plugins/pycv/pythontests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bck*
*.out
logfile
*.log
19 changes: 19 additions & 0 deletions plugins/pycv/pythontests/mypycv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import plumedCommunications as PLMD
import numpy
Fixed Show fixed Hide fixed
from sys import stderr as log
# log = open("pydist.log", "w")

print("Imported my pydist+.", file=log)


def plumedInitio(action: PLMD.PythonCVInterface):
# return {"Value": {"period": [None,0,0]}}
# return {"Value": {"period": None}}
return {"Value": {"period": ["0",0.3]}}
plumedInit={"Value": {"period": None},"NOPBC":False,
"ATOMS":"1,2"}

def plumedCalculate(action: PLMD.PythonCVInterface):
ret = [action.nat]
print ("Hello from plumedCalculate")
return ret
Loading
Loading