IMP logo
IMP Manual  for IMP version 2.16.0
cross_platform.md
1 Cross platform compatibility {#cross_platform}
2 ============================
3 
4 %IMP is designed to run on a wide variety of platforms. To detect problems on
5 other platforms we provide [nightly test runs](https://integrativemodeling.org/nightly/results/)
6 on the supported platforms for code that is part of the %IMP repository.
7 
8 In order to make it more likely that your code works on all the supported platforms:
9 - avoid the use of `and` and `or` in C++ code; use `&&` and `||` instead.
10 - avoid `friend` declarations involving templates; use the preprocessor,
11  conditionally on the symbols `SWIG` and `IMP_DOXYGEN` to hide code as
12  needed instead.
13 - don't use Python modules or functions that aren't available in Python 2.7
14  (the oldest version of Python supported by %IMP). For example, don't use
15  [f strings](https://www.python.org/dev/peps/pep-0498/).
16 - try to write Python code that also works in Python 3 (%IMP supports both
17  Python 2 and Python 3 in one codebase). Most
18  obviously, in Python 3, `print` is a function, not a statement. So write
19  `print("foo")` rather than `print "foo"` - the former works in Python 2 too.
20  To catch a lot of Python 3-incompatible code quickly, add
21  `from __future__ import print_function, division, absolute_import` at the
22  very top of your Python submodules (top-level modules have this already).
23 - if you must use an external C++ library, it needs to have a very permissive
24  open source license (such as BSD or LGPL - not GPL) and note that this
25  will reduce the number of potential users of your code (since it's another
26  dependency to find).
27 - try to avoid Linux- or Mac-centric coding that won't work on Windows.
28  For example, use `os.path.join` to join paths in Python, rather than
29  adding the '/' character. Write utility scripts in Python (which is
30  available on Windows, since the rest of %IMP requires it) not as shell
31  scripts, Perl scripts, etc.