2 # This file is part of the GROMACS molecular simulation package.
4 # Copyright (c) 2019,2020, by the GROMACS development team, led by
5 # Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 # and including many others, as listed in the AUTHORS file in the
7 # top-level source directory and at http://www.gromacs.org.
9 # GROMACS is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public License
11 # as published by the Free Software Foundation; either version 2.1
12 # of the License, or (at your option) any later version.
14 # GROMACS is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # Lesser General Public License for more details.
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with GROMACS; if not, see
21 # http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 # If you want to redistribute modifications to GROMACS, please
25 # consider that scientific software is very special. Version
26 # control is crucial - bugs must be traceable. We will be happy to
27 # consider code for inclusion in the official distribution, but
28 # derived work must not be called official GROMACS. Details are found
29 # in the README & COPYING files - if they are missing, get the
30 # official version at http://www.gromacs.org.
32 # To help us fund GROMACS development, we humbly ask that you cite
33 # the research papers on the package. Check out http://www.gromacs.org.
35 # Stub file for future higher-level CMake management. Ultimately, we want to
36 # drive building and testing from the repository-level CMake configuration, but
37 # in the initial packaging, tests are somewhat manual and Python package
38 # installation is driven through the setup.py file in src.
41 # * A "Python package" is a directory that can be imported as a Python module
42 # by the Python interpreter using the `import packagename` syntax.
43 # * A "distribution archive" is a file in any of several distribution
44 # formats (including archive files of specified directory structures)
45 # that a Python package management tool or framework
46 # (e.g. pypi.org, ``pip``, the ``setuptools`` module)
47 # knows how to download, upload, or install
48 # (building, if necessary, in the case of a source distribution).
49 # * Here, the verb "to package" means to produce a package distribitution archive.
50 # This terminology is used because
51 # * The verb "to produce a package distribution archive" is awkward to conjugate.
52 # * "To build a package" is otherwise ambiguous.
53 # * Here, the meaning of "install" varies with context. In the context of CMake
54 # or a build system like ``make``, "install" refers to the build system target
55 # or command. In the context of a Python package or Python tool, "install"
56 # refers to the managed installation of a Python package from a distribution
57 # archive to a "site-packages" directory for the Python environment.
58 # Note: a (valid and complete) Python does not need to be "installed" to be
59 # usable, such as if the ``import`` and dependencies can be resolved with the
60 # current ``PYTHONPATH`` environment variable or after ``sys.path.append()``.
61 # * "To build a package" means to create a package from sources that may need
62 # to be configured or compiled before the package can be imported. Reference
63 # the ``distutils`` ``build`` and ``build_ext`` commands. For example, when
64 # scikit-build is directed to build a package through the ``setuptools`` interface,
65 # it invokes CMake to build **and install** a CMake library target for the C++
66 # extension module in the Python package.
68 # For basic building and testing of the Python package, we don't necessarily
69 # need to create a distribution archive or install the Python package outside
70 # of the build tree. We can use a CMake ExternalProject to build and install the
71 # ``_gmxapi`` binary extension module from `python_packaging/src` into the main
72 # project build tree (note ``ExternalProject_add()`` option ``INSTALL_DIR``).
73 # If avoiding Python packaging tools in this way, the Python source files (``.py`` files)
74 # will have to be copied explicitly in additional CMake ``install(FILES)`` directives,
75 # and the ExternalProject installation directory will have to be added to the
76 # PYTHONPATH environment variable where the package needs to be available.
78 # Such an ExternalProject could be used as part of the process of packaging a
79 # distribution archive through arguments to the Python side of ``skbuild``,
80 # but coupling that machinery is not necessary. The packaging infrastructure may
81 # be simplest and most maintainable by using scikit-build with its default
82 # behavior (letting it maintain its own environment and artifacts).
84 # Note that a binary distribution needs to be built for a specific major and minor
85 # Python release, and is often sensitive to a particular Python distribution or
86 # packaging system. Instead, we can build `gmxapi` source distributions during
87 # the CMake build phase at the GROMACS project level. These source distributions
88 # can be installed into the GROMACS installation path or uploaded to, .e.g,
89 # PyPI.org so that the binary extension is built in the context of a specific
90 # (system or user) GROMACS installation and (user) Python environment. For a
91 # system-wide Python environment, the package needs to be built and installed
92 # (to the ``site-packages`` directory) for each supported Python interpreter.
93 # ``setup.py`` can just be invoked with different Python interpreters.
95 # To drive the packaging of a Python package distribution archive
96 # by a higher-level CMake configuration, a CMakeLists.txt file at this level would
97 # 1. configure: copy the contents of `src` to the build directory, potentially
98 # configuring version info and CMakeToolchain for GROMACS
99 # 2. build: run (cd $CMAKE_CURRENT_BINARY_DIR/src && python setup.py sdist),
100 # producing $CMAKE_CURRENT_BINARY_DIR/src/dist/gmxapi-0.1.0.dev0+fr7.tar.gz or similar
101 # (add_custom_command(OUTPUT $sdist_name ...) where sdist_name is determined with
102 # `python setup.py --full-name` and a choice of argument for `python setup.py sdist --formats`
103 # 3. install: copy the source distribution to $GROMACS_INSTALL_DIR/sdist/ or something
106 # 1. require GROMACS library target to be present or importable
107 # 2. create and activate a Python venv in the build dir
108 # 3. `pip install <the_sdist_archive_file>` into the venv
109 # 4. run `pytest copy_of_src/test`
111 set(PYBIND11_PYTHON_VERSION "3")
112 add_subdirectory(src)
113 add_subdirectory(sample_restraint)