-
Notifications
You must be signed in to change notification settings - Fork 6
Python Package (pip conda)
A subset of Compadre Toolkit functionality is available as a Python module, hosted on pypi.
Calling pip install packagename
can result in one of two things. If a wheel exists (pre-built binary) and if it matches your platform and version of Python, it will be used. Otherwise, a wheel will be built (from source) and installed. We generally only create wheels for mac, especially since linux_x86 wheels are not currently supported by pypi.
If a wheel already exists, calling
>> pip install pycompadre
will use the pre-built wheel. Otherwise it will get the source code from pypi, build a wheel, and then install it.
If for some reason you really need to change some CMake setting that would be used in compiling compadre, you will need to follow the instructions in the section Non-standard CMake Arguments.
Because there are no pre-built wheels for linux, calling
>> pip install pycompadre
will get the source code from pypi, build a wheel, and then install it.
Again, if for some reason you really need to change some CMake setting that would be used in compiling compadre, you will need to follow the instructions in the section Non-standard CMake Arguments.
For non-traditional LAPACK, BLAS, MKL, CUDA, CUBLAS, etc... locations, the user will need to specify certain CMake variables to help aid in their location. Additionally, enabling OPENMP, PTHREAD, CUDA, certain architectures, etc, uses the same CMake variables as are used for the C++ project.
The only difference is that the file can be stored anywhere, with CMake variables defined one-per-line.
As an example, consider example_cmake.txt
located at /some/absolute/path/to/example_cmake.txt
.
/some/absolute/path/to/example_cmake.txt
Kokkos_ENABLE_OPENMP:BOOL=ON
Kokkos_ENABLE_CUDA:BOOL=ON
Kokkos_ARCH_POWER8:BOOL=ON
Kokkos_ARCH_PASCAL60:BOOL=ON
CUDA_ROOT=/some/path/to/cuda
For most scenarios, the need for custom CMake will be in Linux, which is why it's instructions are first.
The preferred way to build/install using pip and this example_cmake.txt is the following:
>> CMAKE_CONFIG_FILE=/some/absolute/path/to/example_cmake.txt pip install pycompadre -v
It is a good idea to specify the python that you are hoping for pip to install the package to, i.e.:
>> CMAKE_CONFIG_FILE=/some/absolute/path/to/example_cmake.txt python3 -m pip install pycompadre -v
Because there are pre-built wheels for mac, calling
>> CMAKE_CONFIG_FILE=example_cmake.txt pip install pycompadre
will not work as expected. You will be served the wheel, and your CMAKE_CONFIG_FILE will be ignored. That is why it is necessary to add the --no-binary pycompadre
flag. However, using --no-binary
comes with some caveats. First, your project will not be built with bdist_wheel, but rather from sdist. In either case you will be able to open python and type import pycompadre
and it will work, but the sdist installation produces a installed-files.txt files that will not track all libraries generated by the module, meaning that they will not be removed if you should choose to run
>> pip uninstall pycompadre
With that said, the preferred way to build/install using pip and this example_cmake.txt on mac is the following:
>> CMAKE_CONFIG_FILE=example_cmake.txt pip wheel --no-binary pycompadre pycompadre -v
>> pip install pycompadre-[version]-[python-version]-[arch].whl
This forces the construction of a wheel and ensures that a pip uninstall pycompadre
will be clean.
It is a good idea to specify the python that you are hoping for pip to install the package to, i.e.:
>> CMAKE_CONFIG_FILE=cmake_opts.txt python3 -m pip wheel --no-binary pycompadre pycompadre -v
>> python3 -mpip install pycompadre-[version]-[python-version]-[arch].whl
Alternatively, if you do not care about clean uninstalls (why would you ever need to uninstall pycompadre?), this file can be used to configure the python package via:
>> CMAKE_CONFIG_FILE=example_cmake.txt pip install pycompadre --no-binary pycompadre -v
or similary:
>> CMAKE_CONFIG_FILE=example_cmake.txt python3 -m pip install pycompadre --no-binary pycompadre -v
Most functions that exist in pycompadre are wrapped C++ functions from Compadre. So the C++ documentation is a good place to check. Also, you can type:
python
>> import pycompadre
>> help(pycompadre)
to see the Python module documentation.