Skip to content

Commit

Permalink
Merge for 2.11.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
benmwebb committed Jul 12, 2019
2 parents 5d1844c + 6de9d09 commit 1c50e02
Show file tree
Hide file tree
Showing 18 changed files with 147 additions and 20 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,13 @@ if(WIN32)
set(IMP_SWIG_LIBRARIES ${PYTHON_LIBRARIES})
endif(WIN32)

if("${PYTHON_NUMPY_INCLUDE_DIR}" MATCHES ".*NOTFOUND.*")
file(WRITE "${CMAKE_BINARY_DIR}/build_info/NumPy" "ok=False")
else()
if(${PYTHON_NUMPY_FOUND})
set(NUMPY_INCLUDE_PATH ${PYTHON_NUMPY_INCLUDE_DIR} CACHE INTERNAL "" FORCE)
file(WRITE "${CMAKE_BINARY_DIR}/build_info/NumPy"
"ok=True\n"
"includepath='${NUMPY_INCLUDE_PATH}'")
else()
file(WRITE "${CMAKE_BINARY_DIR}/build_info/NumPy" "ok=False")
endif()

if(NOT DEFINED PATH_SEP)
Expand Down
13 changes: 10 additions & 3 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
ChangeLog {#changelog}
=========

# 2.11.1 - 2019-07-18 # {#changelog_2_11_1}
- Bugfix: fix build system failures with CMake 3.12 and 3.13, and on Windows.
- Bugfix: IMP::atom::create_clone() now always copies mass, even of particles
that are not atoms.
- Bugfix: IMP::rmf::create_hierarchies() should no longer fail with
"The filename cannot be empty".

# 2.11.0 - 2019-06-25 # {#changelog_2_11_0}
- A number of new tutorials are now available covering a variety of topics
from modeling complexes with IMP::pmi to writing new C++ code. See
the [tutorial index](https://integrativemodeling.org/tutorials/) for
more details.
- The build system has been updated to use new CMake functionality
(if available) to detect Python. If you have CMake 3.12 or later, this should
(if available) to detect Python. If you have CMake 3.14 or later, this should
do a much better job of handling multiple Python installations (e.g. Macs
with Homebrew). It will default to using Python 3. To force use of Python 2,
pass `-DUSE_PYTHON2=on` to your CMake invocation.
- CMake files are now provided to make it straightforward to use IMP as
a library in other programs. See
[the tutorial](https://integrativemodeling.org/tutorials/using_cpp/develop/)
[the tutorial](https://integrativemodeling.org/tutorials/using_cpp/)
for more details.
- CMake files are now provided to build new IMP modules outside of the IMP
build tree (i.e. a module can be built against an IMP binary).
- The IMP::OptionParser class has been removed. Use IMP::ArgumentParser instead.
- The IMP::test::TempDir and IMP::test::RunInTempDir utility classes have been
removed. Use the IMP::test::temporary_directory and
IMP::temporary_working_directory context managers instead.
IMP::test::temporary_working_directory context managers instead.

# 2.10.1 - 2019-02-26 # {#changelog_2_10_1}
- Add support for OpenCV 4.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.11.0
2.11.1
4 changes: 2 additions & 2 deletions doc/manual/cmake_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ which control the build. For example:

In order to build %IMP Python extensions, CMake needs to find the Python header
and library files that match the `python3` or `python` binary. If using a
recent version of CMake (3.12 or later) it should have no issues in doing so.
recent version of CMake (3.14 or later) it should have no issues in doing so.
However, old versions of CMake might get confused if you have multiple versions
of Python installed (for example on a Mac with [Homebrew](https://brew.sh/)),
and find the headers for one version and the binary for another. This can
Expand All @@ -82,7 +82,7 @@ variables.

For example, on a Mac with Homebrew, where `python` is Homebrew's
`/usr/local/bin/python`, old versions of CMake will often find Apple's Python
headers. This can be resolved (if you cannot upgrade CMake to 3.12 or later)
headers. This can be resolved (if you cannot upgrade CMake to 3.14 or later)
by telling CMake where the Homebrew Python headers and library
are, by addinng to your CMake invocation something like
`-DPYTHON_LIBRARY=/usr/local/opt/python@2/Frameworks/Python.framework/Versions/Current/lib/libpython2.7.dylib -DPYTHON_INCLUDE_DIR=/usr/local/opt/python@2/Frameworks/Python.framework/Versions/Current/Headers`
Expand Down
2 changes: 1 addition & 1 deletion doc/manual/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ to see if the code is currently stable enough for your purposes.

In order to build %IMP from source, you will need:

- [CMake](https://cmake.org) (2.8 or later; 3.12 or later is recommended)
- [CMake](https://cmake.org) (2.8 or later; 3.14 or later is recommended)
- [Boost](https://www.boost.org) (1.41 or later; Boost.Iostreams must be built
with its [zlib filter enabled](https://www.boost.org/doc/libs/1_67_0/libs/iostreams/doc/installation.html))
- [Eigen](https://eigen.tuxfamily.org/) (3.0 or later)
Expand Down
1 change: 1 addition & 0 deletions doc/manual/mainpage.dox
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ complex might want to skip ahead to
- [Naming and interface conventions](@ref conventions)
- [Parallelization](@ref parallel)
- [Using the library in other projects](@ref uselibrary)
- [Building modules out of tree](@ref outoftree)

- [Frequently asked questions (FAQ)](@ref faq)

Expand Down
65 changes: 65 additions & 0 deletions doc/manual/outoftree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Building modules out of tree {#outoftree}
============================

Normally to build an %IMP module it is placed in the `modules` subdirectory
together with the rest of the %IMP source code and then all of %IMP is
built, as per the [installation instructions](@ref installation_source).
However, this makes builing a module an expensive process (as the build
system needs to check whether any part of %IMP has changed, not just the
module itself) and it is awkward to build a module against multiple
versions of %IMP, for example against both the latest stable release and
a more recent nightly build.

An alternative is to build one or more %IMP modules 'out of tree', treating
them as their own [CMake](https://cmake.org/) projects in their own
directories, and pointing them to existing %IMP installation(s) using
%IMP's [existing CMake configuration](@ref uselibrary).

## Module layout

Out of tree modules can be maintained in one of two ways:

1. A top-level `modules` directory containing a number of subdirectories,
one per module; the name of each subdirectory is the name of the module.
This mimics the way %IMP itself maintains multiple modules.
2. All of a single module's files can be placed in the top-level directory,
as is done for the [PMI](https://github.com/salilab/pmi/) module. This
has the advantage that the module can also be cloned directly into
%IMP's `modules` directory and built 'in tree', as well.

## CMake configuration

Place the [FindIMP.cmake](https://github.com/salilab/pmi/blob/develop/tools/FindIMP.cmake)
file into a suitable directory, say a `tools` subdirectory. This file will help
CMake to find the %IMP installation, as [described earlier](@ref uselibrary).

Make a top-level `CMakeLists.txt` file. This file
- Adds the `tools` directory to the CMake search path, so that CMake can
find %IMP;
- Finds the %IMP package;
- Uses the `imp_build_module` CMake macro, provided in %IMP's CMake
configuration, to build the module;
- For the single module case, detect an 'in tree' build and fall back to
using %IMP's own CMake scripts.

A suitable `CMakeLists.txt` can be found in the
[PMI repository](https://github.com/salilab/pmi/blob/develop/CMakeLists.txt) -
all that needs to be changed is `CMAKE_MODULE_PATH` (if `FindIMP.cmake` was
not put in the `tools` directory) and the second argument to
`imp_build_module`, which is the module name. (If multiple modules are
being built under the `modules` directory, this second argument should
be omitted - the module names will match those of the subdirectories.)

## Building

The module can now be built like any other CMake project - i.e. make a
build directory, and run CMake in that build directory, giving it the
path to the module source code. (You may need to set the `IMP_DIR` variable
to help CMake find %IMP.)

## Testing and running

After a successful build, the build directory will contain a
`setup_environment.sh` script. This can be used just like that in %IMP
itself. It will add both the out of tree module(s) and %IMP to the search
path so that the module can be tested or used.
7 changes: 6 additions & 1 deletion doc/manual/uselibrary.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,10 @@ file is provided to help CMake find this %IMP configuration (using the
command), and can be used in other CMake projects.

See also the tutorial on
[using IMP as a C++ library](https://integrativemodeling.org/tutorials/using_cpp/develop/)
[using IMP as a C++ library](https://integrativemodeling.org/tutorials/using_cpp/)
for a worked example of using %IMP in a CMake project.

This functionality can also be used to build an %IMP module "out of tree",
that is to build the module by itself and link to an existing pre-built
%IMP installation. See the [out of tree](@ref outoftree) page for more
information.
1 change: 0 additions & 1 deletion doc/ref/edit.png

This file was deleted.

4 changes: 2 additions & 2 deletions modules/atom/include/Hierarchy.h
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ IMPATOMEXPORT bool get_is_heterogen(Hierarchy h);

//! Clone the Hierarchy
/** This method copies the Bond, Bonded, Atom,
Residue, Domain, and provenance data and the particle name to the
Residue, Domain, Mass, and provenance data and the particle name to the
new copies in addition to the Hierarchy relationships.
\relates Hierarchy
Expand All @@ -460,7 +460,7 @@ IMPATOMEXPORT Hierarchy create_clone(Hierarchy d);

//! Clone the node in the Hierarchy
/** This method copies the Atom,
Residue, Chain, Domain, and provenance data and the particle name.
Residue, Chain, Domain, Mass, and provenance data and the particle name.
\relates Hierarchy
*/
Expand Down
5 changes: 5 additions & 0 deletions modules/atom/include/Mass.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class IMPATOMEXPORT Mass : public Decorator {
double mass) {
m->add_attribute(get_mass_key(), pi, mass);
}
static void do_setup_particle(Model *m, ParticleIndex pi,
Mass o) {
do_setup_particle(m, pi, o.get_mass());
}

public:
static bool get_is_setup(Model *m, ParticleIndex pi) {
Expand All @@ -42,6 +46,7 @@ class IMPATOMEXPORT Mass : public Decorator {
IMP_DECORATOR_METHODS(Mass, Decorator);
/** Add the specified mass to the particle. */
IMP_DECORATOR_SETUP_1(Mass, Float, mass);
IMP_DECORATOR_SETUP_1(Mass, Mass, other);

/** Get the key used to store the mass. */
static FloatKey get_mass_key();
Expand Down
5 changes: 5 additions & 0 deletions modules/atom/src/Hierarchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,11 @@ Hierarchy clone_internal(Hierarchy d,
if (Representation::get_is_setup(d.get_particle())) {
nd = Representation::setup_particle(p, Representation(d.get_particle()));
}
// If a particle has mass but is not an atom (e.g. a PMI bead), copy the mass
if (Mass::get_is_setup(d.get_particle()) &&
!Mass::get_is_setup(p)) {
Mass::setup_particle(p, Mass(d.get_particle()));
}
if (core::Provenanced::get_is_setup(d.get_particle())) {
core::Provenanced pd(d.get_particle());
core::Provenance prov = core::create_clone(pd.get_provenance());
Expand Down
12 changes: 12 additions & 0 deletions modules/atom/test/test_clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ def test_bonded(self):
mh = None
self.assertEqual(0, len(m.get_particle_indexes()))

def test_clone_mass(self):
"""Test clone of particles that have mass but are not atoms"""
m = IMP.Model()
p1 = IMP.Particle(m)
h1 = IMP.atom.Hierarchy.setup_particle(p1)
m1 = IMP.atom.Mass.setup_particle(p1, 4.0)

h2 = IMP.atom.create_clone(h1)
self.assertTrue(IMP.atom.Mass.get_is_setup(h2))
m2 = IMP.atom.Mass(h2)
self.assertAlmostEqual(m2.get_mass(), 4.0, delta=1e-4)

def test_destroy_child(self):
"""Destroy of a child should update the parent"""
m = IMP.Model()
Expand Down
25 changes: 25 additions & 0 deletions modules/atom/test/test_mass.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from __future__ import print_function
import IMP
import IMP.test
import IMP.atom


class Tests(IMP.test.TestCase):

def test_mass(self):
"""Check Mass decorator"""
m = IMP.Model()
p1 = IMP.Particle(m)
p2 = IMP.Particle(m)
# Set up using mass value
m1 = IMP.atom.Mass.setup_particle(p1, 1.0)
self.assertAlmostEqual(m1.get_mass(), 1.0, delta=1e-4)
m1.set_mass(2.0)
self.assertAlmostEqual(m1.get_mass(), 2.0, delta=1e-4)
# Set up using other particle
m2 = IMP.atom.Mass.setup_particle(p2, m1)
self.assertAlmostEqual(m2.get_mass(), 2.0, delta=1e-4)


if __name__ == '__main__':
IMP.test.main()
4 changes: 2 additions & 2 deletions modules/rmf/dependency/RMF/cmake_modules/IMPFindPython.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Like cmake's FindPython but allows the user to override; should also
# work (to some degree) with older cmake
function(imp_find_python)
if (${CMAKE_VERSION} VERSION_LESS "3.12.0")
message(WARNING "Using old Python detection logic. Recommended to upgrade to cmake 3.12.0 or later")
if (${CMAKE_VERSION} VERSION_LESS "3.14.0")
message(WARNING "Using old Python detection logic. Recommended to upgrade to cmake 3.14.0 or later")
if(NOT DEFINED PYTHON_INCLUDE_DIRS)
execute_process(COMMAND python -c "import sys; print(sys.executable)"
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
Expand Down
2 changes: 1 addition & 1 deletion modules/rmf/dependency/RMF/src/internal/paths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ size_t count_path_components(boost::filesystem::path p) {
// Remove extraneous . and .. entries from the path
boost::filesystem::path normalize(const boost::filesystem::path& p) {
size_t comp = count_path_components(p);
std::vector<bool> keep(true, comp);
std::vector<bool> keep(comp, true);

size_t i = 0;
for (boost::filesystem::path::iterator it(p.begin()), it_end(p.end());
Expand Down
6 changes: 3 additions & 3 deletions tools/build/setup_cmake.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,14 @@ def setup_module(finder, module, tools_dir, extra_include, extra_swig,
tools.to_cmake_path(x) for x in checks]))
contents.append(
"add_subdirectory(${CMAKE_SOURCE_DIR}/%s/compiler)" %
module.path)
tools.to_cmake_path(module.path))
if len(deps) > 0:
g.write(os.path.join(module.path, 'dependency', 'CMakeLists.txt'),
"\n".join(["include(${CMAKE_SOURCE_DIR}/%s)" %
tools.to_cmake_path(x) for x in deps]))
contents.append(
"add_subdirectory(${CMAKE_SOURCE_DIR}/%s/dependency)" %
module.path)
tools.to_cmake_path(module.path))
local = os.path.join(module.path, "Setup.cmake")
if os.path.exists(local):
contents.append("include(${CMAKE_SOURCE_DIR}/%s)"
Expand Down Expand Up @@ -238,7 +238,7 @@ def setup_module(finder, module, tools_dir, extra_include, extra_swig,
benchmark_template.write(benchmark, values)
examples_template.write(examples, values)
values["tests"] = "\n".join(contents)
topdir = '/' + module.path if module.path else ''
topdir = '/' + tools.to_cmake_path(module.path) if module.path else ''
if finder.external_dir:
values["build_dir"] = "--build_dir=%s " % finder.external_dir
else:
Expand Down
3 changes: 3 additions & 0 deletions tools/rpm/IMP.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,9 @@ find ${RPM_BUILD_ROOT}%{_prefix}/share/IMP/tools -name '*.py' -exec perl -pi -e
%endif

%changelog
* Thu Jul 18 2019 Ben Webb <[email protected]> 2.11.1-1
- 2.11.1 release.

* Tue Jun 25 2019 Ben Webb <[email protected]> 2.11.0-1
- 2.11.0 release.

Expand Down

0 comments on commit 1c50e02

Please sign in to comment.