Skip to content

Commit

Permalink
Update packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
jmp1985 committed Apr 26, 2021
1 parent 17915f6 commit 9828b5c
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 34 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "gemmi"]
path = gemmi
url = git@github.com:project-gemmi/gemmi.git
[submodule "pybind11"]
path = pybind11
url = https://github.com/pybind/pybind11
33 changes: 16 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
cmake_minimum_required(VERSION 3.11.0)
##############################################################################
# Build file for amplus project
##############################################################################

cmake_minimum_required(VERSION 3.17.0)

# Set the project name
project(amplus CXX)

# Set the build type to release
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()

# Set the cmake module path
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

Expand All @@ -11,28 +20,18 @@ set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
# clusters which may not allow export of LD_LIBRARY_PATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH True)

# Find Pybind11
find_package(pybind11 REQUIRED)
# Add pybind sub directory
add_subdirectory(pybind11)

# Add a C/C++ extension
pybind11_add_module(freeze_ext
pybind11_add_module(amplus_ext
amplus/freeze/freeze_ext.cc)

# Ensure we are using C++11
target_compile_features(freeze_ext PUBLIC cxx_std_11)
target_compile_features(amplus_ext PUBLIC cxx_std_11)

# Set the include directory
target_include_directories(freeze_ext PUBLIC .)

# Set the coverage compile and link flags for gcc or clang
set(COVERAGE_COMPILE_FLAGS -coverage)
set(COVERAGE_LINK_FLAGS -coverage)

# Set the coverage compile and link flags in the debug build
target_compile_options(freeze_ext
PUBLIC "$<$<CONFIG:DEBUG>:${COVERAGE_COMPILE_FLAGS}>")
target_link_options(freeze_ext
PUBLIC "$<$<CONFIG:DEBUG>:${COVERAGE_LINK_FLAGS}>")
target_include_directories(amplus_ext PUBLIC .)

# Install the python extension
install(TARGETS freeze_ext LIBRARY DESTINATION amplus/freeze)
install(TARGETS amplus_ext LIBRARY DESTINATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
47 changes: 39 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,56 @@
![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)

## Dependencies
## Installation

The packages depends on the python-multem package being installed. To do this,
follow the instructions [here](https://github.com/rosalindfranklininstitute/python-multem).
In order to build this package, the following dependencies are required:

## Installation
- The CUDA toolkit
- FFTW

To install from the github repository do the following

```sh
export CUDACXX=${PATH_TO_CUDA}/bin/nvcc
python -m pip install git+https://github.com/rosalindfranklininstitute/amplus-digital-twin.git@master#egg=amplus-digital-twin
```

To install from source, clone this repository. The repository has a submodule
for pybind11 so after cloning the repository run

```sh
git submodule update --init --recursive
```

Then do the following:

```sh
export CUDACXX=${PATH_TO_CUDA}/bin/nvcc
python -m pip install .
```

If you would like to run the tests then, clone this repository and then do the following:

```sh
export CUDACXX=${PATH_TO_CUDA}/bin/nvcc
python -m pip install .[test]
```

## Installation for developers

To install from source, clone this repository and then do the following:
To install for development, clone this repository and then do the following:

```sh
python setup.py install
export CUDACXX=${PATH_TO_CUDA}/bin/nvcc
python -m pip install -e .
```

## Testing

To run the tests, clone this repository and the do the following:
To run the tests, follow the installation instructions for developers and then do the following:

```sh
python setup.py test
pytest
```

## Usage
Expand Down
1 change: 0 additions & 1 deletion gemmi
Submodule gemmi deleted from 7c3736
1 change: 1 addition & 0 deletions pybind11
Submodule pybind11 added at 544304
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[build-system]
requires = ["setuptools", "wheel", "scikit-build", "cmake", "ninja"]
requires = ["setuptools", "wheel", "cmake", "ninja"]
build-backend = "setuptools.build_meta"
5 changes: 4 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
scikit-build
setuptools
cmake
ninja
wheel
pytest
pytest-cov
mock
49 changes: 46 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,48 @@
#
# This code is distributed under the BSD license.
#
from skbuild import setup
from setuptools import find_packages
import os
import subprocess
import sys
from setuptools import setup, find_packages, Extension
from setuptools.command.build_ext import build_ext


class CMakeBuild(build_ext):
"""
Build the extensions
"""

def build_extensions(self):

# Set the cmake directory
cmake_lists_dir = os.path.abspath(".")

# Ensure the build directory exists
if not os.path.exists(self.build_temp):
os.makedirs(self.build_temp)

# Run Cmake once
ext = self.extensions[0]

# Get the directory
extdir = os.path.abspath(os.path.dirname(self.get_ext_fullpath(ext.name)))

# Arguments to cmake
cmake_args = [
"-DCMAKE_BUILD_TYPE=%s" % "Release",
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=%s" % extdir,
"-DPYTHON_EXECUTABLE=%s" % sys.executable,
]

# Config and the extension
subprocess.check_call(
["cmake", cmake_lists_dir] + cmake_args, cwd=self.build_temp
)

# Build the extension
subprocess.check_call(["cmake", "--build", "."], cwd=self.build_temp)


def main():
Expand All @@ -21,17 +61,20 @@ def main():
"distributed",
"dask_jobqueue",
"gemmi",
"guanaco @ git+https://github.com/rosalindfranklininstitute/guanaco.git@master#egg=guanaco",
"h5py",
"mrcfile",
"numpy",
"pandas",
"pillow",
"python-multem @ https://github.com/rosalindfranklininstitute/python-multem/tarball/master#egg=python-multem",
"python-multem @ git+https://github.com/rosalindfranklininstitute/python-multem.git@master#egg=python-multem",
"scipy",
"pyyaml",
],
tests_require=tests_require,
test_suite="tests",
ext_modules=[Extension("amplus_ext", [])],
cmdclass={"build_ext": CMakeBuild},
entry_points={
"console_scripts": [
"amplus.read_pdb=amplus.command_line:read_pdb",
Expand Down

0 comments on commit 9828b5c

Please sign in to comment.