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

Conda package for cpptraj #1125

Open
wants to merge 26 commits into
base: conda
Choose a base branch
from
Open

Conda package for cpptraj #1125

wants to merge 26 commits into from

Conversation

dacase
Copy link

@dacase dacase commented Jan 2, 2025

@drroe This is actually my first attempt at a pull request that is based on a non-master
branch. I'm assuming that accepting the request will create a conda branch at Amber-MD/cpptraj, and not mess with your master branch.

You can also just go to github.com/dacase/cpptraj.git.

dacase and others added 21 commits December 19, 2024 11:55
…dine.a. Need to check if this is OK for Linux"

This reverts commit d81868f.
… be expected; need to check for breaking internal readline
@hainm hainm mentioned this pull request Jan 2, 2025
@dacase dacase changed the base branch from master to conda January 2, 2025 16:37
@hainm
Copy link
Contributor

hainm commented Jan 3, 2025

@dacase Do we want to build libcpptraj and include header files in this PR too? or it should be different recipe?

@dacase
Copy link
Author

dacase commented Jan 3, 2025

We want to make this recipe to the right thing for pytraj. There is a libcpptraj.so file in $CONDA_PREFIX/lib in the conda package. I don't know what headers pytraj needs, or where they should go -- $CONDA_PREFIX/include? Check out the rsync line towards the end of build.sh, and see if that can do what is needed.

@hainm
Copy link
Contributor

hainm commented Jan 3, 2025

I don't know what headers pytraj needs, or where they should go -- $CONDA_PREFIX/include?

  • For now, we could copy all the src/*.h to ${CONDA_PREFIX}/include/cpptraj/ folder
  • export CPPTRAJ_HEADERDIR=${CONDA_PREFIX}/include/cpptraj

@hainm
Copy link
Contributor

hainm commented Jan 3, 2025

There is a libcpptraj.so file in $CONDA_PREFIX/lib in the conda package.

It seems this comes from AmberTools conda since I don't see where libcpptraj.so is built in your recipe. I will make further comment in the code.

@hainm
Copy link
Contributor

hainm commented Jan 3, 2025

There is a libcpptraj.so file in $CONDA_PREFIX/lib in the conda package.

It seems this comes from AmberTools conda since I don't see where libcpptraj.so is built in your recipe. I will make further comment in the code.

never mind, you do use "-shared" in your build.sh so libcpptraj.so is already done.



rsync -a README.md config.h LICENSE dat bin lib test $PREFIX

Copy link
Contributor

Choose a reason for hiding this comment

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

mkdir -p $PREFIX/include/cpptraj 
rsync src/*.h $PREFIX/include/cpptraj/  # Not sure if this is correct syntax :D 

#!/bin/bash

export CPPTRAJHOME=${CONDA_PREFIX}

Copy link
Contributor

Choose a reason for hiding this comment

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

Also add export CPPTRAJ_HEADERDIR=${CONDA_PREFIX}/include/cpptraj so pytraj can find the header files. Ideally, we should use CPPTRAJHOME/include but the header files might overwrite other library's headers, so we make "cpptraj" folder.

Copy link
Author

Choose a reason for hiding this comment

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

@hainm do a conda install dacase::cpptraj (only for linux-64 right now), and see if libraries and headers seem to be in the proper places with the proper information.

Copy link
Contributor

Choose a reason for hiding this comment

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

@hainm do a conda install dacase::cpptraj (only for linux-64 right now), and see if libraries and headers seem to be in the proper places with the proper information.

@dacase I confirm that I do see $PREFIX/lib/libcpptraj.so and $PREFIX/include/cpptraj/*.h
Thanks.

Copy link
Contributor

Choose a reason for hiding this comment

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

@dacase It seems we need to recursively include the .h files too. pytraj only uses a subset of them but one header refers another/other header file(s), so think we need to include all.

image

Copy link
Contributor

Choose a reason for hiding this comment

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

image

@drroe
Copy link
Contributor

drroe commented Jan 3, 2025

I've made some progress on fixing external readline support in cpptraj. It will be in a separate branch that can then eventually be merged into this PR, which should fix the test errors.

@dacase
Copy link
Author

dacase commented Jan 3, 2025

I've made some progress on fixing external readline support in cpptraj. It will be in a separate branch that can then eventually be merged into this PR, which should fix the test errors.

I'm a bit lost here: did the test errors arise from the conda package, or from trying to compile (and if so, from which branch?) Can you say which tests are throwing errors? I've never quite understood how to test for readline problems.

@drroe
Copy link
Contributor

drroe commented Jan 4, 2025

I've made some progress on fixing external readline support in cpptraj. It will be in a separate branch that can then eventually be merged into this PR, which should fix the test errors.

I'm a bit lost here: did the test errors arise from the conda package, or from trying to compile (and if so, from which branch?) Can you say which tests are throwing errors? I've never quite understood how to test for readline problems.

See here: https://jenkins.jasonswails.com/blue/organizations/jenkins/amber-github%2Fcpptraj/detail/PR-1125/2/pipeline/33/

This is because there is no system readline so cpptraj tries to build the internal one, but the current build setup can't handle the readline includes being in a readline directory. This branch will handle both system readline and internal readline consistently once I get it merged: https://github.com/drroe/cpptraj/tree/readline.include

@drroe
Copy link
Contributor

drroe commented Jan 8, 2025

Sorry for the delay on this. I've fixed (I think) cpptraj's use of system readline libraries (#1126), but I'm running into an issue with CMAKE that I'm having trouble solving. I switched the include in ReadLine.cpp to be the proper #include <readline/readline.h> (as documented here) which works fine for the configure-based install because I switched the compiler include flag to be -I., but fails for the CMAKE-based install because I can't figure out how to change the include flag. I though that maybe modifying the following in SetupThirdParty.cmake would do it:

--- a/cmake-cpptraj/SetupThirdParty.cmake
+++ b/cmake-cpptraj/SetupThirdParty.cmake
@@ -449,8 +449,8 @@ if(readline_EXTERNAL)
                LIBRARIES readline::readline
                INCLUDES ${READLINE_INCLUDE_DIR}/readline)
 elseif(readline_INTERNAL)
-
-       list(APPEND 3RDPARTY_SUBDIRS cpptraj/src/readline)
+        message(STATUS "Readline will be internal")
+       list(APPEND 3RDPARTY_SUBDIRS cpptraj/src)

 endif()

But it's still trying to include src/readline instead of just src so I guess there is somewhere else that needs to be changed:

)$ make ReadLine.o
cd /home/droe/Cpptraj/rl.include/build && make  -f src/CMakeFiles/cpptraj.dir/build.make src/CMakeFiles/cpptraj.dir/ReadLine.cpp.o
make[1]: Entering directory '/home/droe/Cpptraj/rl.include/build'
Building CXX object src/CMakeFiles/cpptraj.dir/ReadLine.cpp.o
cd /home/droe/Cpptraj/rl.include/build/src && /usr/bin/g++ -DBINTRAJ -DBUILDTYPE=\"GitHub\" -DC11_SUPPORT -DFFTW_FFT -DHASBZ2 -DHASGZ -DHAS_TNGFILE -DHAVE_FFTWD=1 -DLIBPME -DUSE_MKSTEMP -D_GNU_SOURCE -I/home/droe/Cpptraj/rl.include/src/tng/. -I/home/droe/Cpptraj/rl.include/src/arpack/. -I/home/droe/Cpptraj/rl.include/src/xdrfile/. -I/home/droe/Cpptraj/rl.include/src/readline/. -Wall -Wno-unused-function -Wno-unknown-pragmas -Wno-unused-local-typedefs -Wno-unused-variable -Wno-unused-but-set-variable -std=gnu++11 -O3 -mtune=native  -MD -MT src/CMakeFiles/cpptraj.dir/ReadLine.cpp.o -MF CMakeFiles/cpptraj.dir/ReadLine.cpp.o.d -o CMakeFiles/cpptraj.dir/ReadLine.cpp.o -c /home/droe/Cpptraj/rl.include/src/ReadLine.cpp
/home/droe/Cpptraj/rl.include/src/ReadLine.cpp:11:13: fatal error: readline/readline.h: No such file or directory
   11 | #   include <readline/readline.h>
      |             ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.

It's not clear from the documentation what needs to be modified to ensure the includes are properly handled. @dacase @swails @hainm do any of you have any ideas?

@drroe
Copy link
Contributor

drroe commented Jan 8, 2025

I may have figured it out: looks like I had to modify a target_include_directories command in the readline subdirectory itself. Stay tuned...

…#1126)

* Fixes for using system readline

* Go back to bundled readline if no system readline present

* Add checks for testing whether -ltermcap or -lncurses are needed for linking to system readline

* Change readline include path for CMAKE

* Add the '.' include back for the bundled readline library itself.

* Try to fix the clang compile. I thought this was based on the gcc
version but maybe not?

* Try to upgrade to python 3.11 for pytraj to get CI working again.

* Try conda 24.11.0.

* Forgot to revert python. I do not like python.
@drroe
Copy link
Contributor

drroe commented Jan 8, 2025

The readline issues should be resolved with #1126. Next will be the header files installation.

* Use the install binary

* Script to get all headers that should be installed for libcpptraj

* Contains all headers that should be installed for libcpptraj

* Add target for installing headers

* Make header install less verbose. Have libcpptraj install depend on
install_headers

* Cmake install headers for inside/outside amber

* Convert back down to lyx 2.3 for Amber

* Update the PDF
@drroe
Copy link
Contributor

drroe commented Jan 14, 2025

@dacase Cpptraj header install should be working now for both configure/cmake via #1129. You can try merging the current Amber-MD/Cpptraj master into this branch and see if it works for you.

Alternatively, let me know if you want me to reproduce this PR on my fork if that will be easier.

@dacase
Copy link
Author

dacase commented Jan 14, 2025

Let me work on this, to make sure the conda package is still OK at my end (i.e. before you do more on this PR at your end. See also coming comments on issue #1120 .

@dacase
Copy link
Author

dacase commented Jan 15, 2025

@drroe As I mentioned above, I don't think it's worth your while to do anything with this PR per se.

If you find some time (absolutely no rush!), what would be most helpful would be to install the existing conda package, and try out the tests, look at the contents of the include folder, etc.
Only try this on Linux for starters, because the osx builds are a bit behind.

conda create --name cpptraj
conda activate cpptraj
conda install dacase::cpptraj
cd $CONDA_PREFIX
cd test
make test   #  etc.
conda deactivate

(Right now, I've only put the test folder into the conda package; let me know if I should add the unitTests folder as well.)

FYI: the changes in the PR are pretty minimal. Here are the diffs between the conda branch and master on my local machine; (not all of these have been placed yet into the PR):

(cpptraj) bethe% git diff --stat master
 Makefile                       |  4 +-
 configure                      | 17 ++++-----
 mkrelease                      | 14 +++++++
 recipe/activate.sh             |  5 +++
 recipe/build.sh                | 46 ++++++++++++++++++++++
 recipe/conda_build_config.yaml |  8 ++++
 recipe/deactivate.sh           |  5 +++
 recipe/meta.yaml               | 86 ++++++++++++++++++++++++++++++++++++++++++
 src/Matrix.h                   |  1 +
 9 files changed, 175 insertions(+), 11 deletions(-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants