2 # This file is part of the GROMACS molecular simulation package.
4 # Copyright (c) 2019,2020,2021, 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.
65 # For basic building and testing of the Python package, we don't necessarily
66 # need to create a distribution archive or install the Python package outside
67 # of the build tree. We can use a CMake ExternalProject to build and install the
68 # ``_gmxapi`` binary extension module from `python_packaging/src` into the main
69 # project build tree (note ``ExternalProject_add()`` option ``INSTALL_DIR``).
70 # If avoiding Python packaging tools in this way, the Python source files (``.py`` files)
71 # will have to be copied explicitly in additional CMake ``install(FILES)`` directives,
72 # and the ExternalProject installation directory will have to be added to the
73 # PYTHONPATH environment variable where the package needs to be available.
75 # Note that a binary distribution needs to be built for a specific major and minor
76 # Python release, and is often sensitive to a particular Python distribution or
77 # packaging system. Instead, we can build `gmxapi` source distributions during
78 # the CMake build phase at the GROMACS project level. These source distributions
79 # can be installed into the GROMACS installation path or uploaded to, .e.g,
80 # PyPI.org so that the binary extension is built in the context of a specific
81 # (system or user) GROMACS installation and (user) Python environment. For a
82 # system-wide Python environment, the package needs to be built and installed
83 # (to the ``site-packages`` directory) for each supported Python interpreter.
84 # ``setup.py`` can just be invoked with different Python interpreters.
86 # To drive the packaging of a Python package distribution archive
87 # by a higher-level CMake configuration, a CMakeLists.txt file at this level would
88 # 1. configure: copy the contents of `src` to the build directory, potentially
89 # configuring version info and CMakeToolchain for GROMACS
90 # 2. build: run (cd $CMAKE_CURRENT_BINARY_DIR/src && python setup.py sdist),
91 # producing $CMAKE_CURRENT_BINARY_DIR/src/dist/gmxapi-0.1.0.dev0+fr7.tar.gz or similar
92 # (add_custom_command(OUTPUT $sdist_name ...) where sdist_name is determined with
93 # `python setup.py --full-name` and a choice of argument for `python setup.py sdist --formats`
94 # 3. install: copy the source distribution to $GROMACS_INSTALL_DIR/sdist/ or something
97 # 1. require GROMACS library target to be present or importable
98 # 2. create and activate a Python venv in the build dir
99 # 3. `pip install <the_sdist_archive_file>` into the venv
100 # 4. run `pytest copy_of_src/test`
102 set(PYBIND11_PYTHON_VERSION "3")
103 add_subdirectory(src)
104 add_subdirectory(sample_restraint)