Skip to content

Commit 10e7de6

Browse files
committed
allow standard and cmake python install
1 parent 6c49d20 commit 10e7de6

File tree

8 files changed

+54
-5
lines changed

8 files changed

+54
-5
lines changed

README.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,21 @@ sudo make install
3333

3434
The libmsym module requires python 3.
3535

36+
If you have installed the libmsym library in a location that can be found by your loader (e.g. ldconfig):
37+
```shell
38+
cd ../bindings/python
39+
# install libmsym module in user site
40+
python setup.py install --user
41+
# run example
42+
python ./examples/msympy_example.py <input xyz-file> <output xyz-file>
43+
```
44+
45+
If you want to install libmsym in a custom directory, the easies way it to use cmake:
3646
```shell
3747
# install libmsym shared library in $HOME/lib and the python module in the user site
38-
cmake -DMSYM_BUILD_PYTHON:BOOL=ON -DBUILD_SHARED_LIBS:BOOL=ON -DCMAKE_INSTALL_PREFIX=$HOME/lib -DMSYM_PYTHON_INSTALL_OPTS=--user ../.
48+
cmake -DMSYM_BUILD_PYTHON:BOOL=ON -DBUILD_SHARED_LIBS:BOOL=ON -DCMAKE_INSTALL_PREFIX=$HOME/lib -DMSYM_PYTHON_INSTALL_OPTS=--user ../.
3949
# run example
40-
python3 ../bindings/python/examples/msympy_example.py <input xyz-file> <output xyz-file>
50+
python ../bindings/python/examples/msympy_example.py <input xyz-file> <output xyz-file>
4151
```
4252

4353
methods dealing with SALCs etc. require numpy to be installed

bindings/python/.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/build
2-
/__pycache__
32

43
*.swp
54
.DS_Store

bindings/python/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ cmake_minimum_required (VERSION 2.8.11)
33
find_program(PYTHON "python")
44
if (PYTHON)
55
set(MSYM_PYTHON_PACKAGE_DIR "${CMAKE_CURRENT_BINARY_DIR}/libmsym")
6-
set(MSYM_PYTHON_SETUP_IN "${CMAKE_CURRENT_SOURCE_DIR}/setup.py.in")
7-
set(MSYM_PYTHON_INIT_C_IN "${CMAKE_CURRENT_SOURCE_DIR}/libmsym/__init__.py.in")
6+
set(MSYM_PYTHON_SETUP_IN "${CMAKE_CURRENT_SOURCE_DIR}/cmake/setup.py.in")
7+
set(MSYM_PYTHON_INIT_C_IN "${CMAKE_CURRENT_SOURCE_DIR}/cmake/__init__.py.in")
88
set(MSYM_PYTHON_CODE_IN "${CMAKE_CURRENT_SOURCE_DIR}/libmsym/libmsym.py")
99
set(MSYM_PYTHON_SETUP "${CMAKE_CURRENT_BINARY_DIR}/setup.py")
1010
set(MSYM_PYTHON_INIT_G_IN "${CMAKE_CURRENT_BINARY_DIR}/__init__.py.in")
File renamed without changes.

bindings/python/libmsym/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/__pycache__
2+
3+
*.swp
4+
.DS_Store

bindings/python/libmsym/__init__.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
__all__ = []
2+
3+
_libmsym_install_location = None
4+
5+
def export(defn):
6+
globals()[defn.__name__] = defn
7+
__all__.append(defn.__name__)
8+
return defn
9+
10+
from . import libmsym
11+

bindings/python/setup.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#
2+
# setup.py
3+
# libmsym
4+
#
5+
# Created by Marcus Johansson on 07/10/15.
6+
# Copyright (c) 2015 Marcus Johansson.
7+
#
8+
# Distributed under the MIT License ( See LICENSE file or copy at http://opensource.org/licenses/MIT )
9+
#
10+
11+
from distutils.core import setup
12+
import sys
13+
14+
if (not sys.version_info[0] is 3):
15+
sys.exit('libmsym module requires python 3')
16+
17+
setup(name='libmsym',
18+
version='${LIBMSYM_VERSION}',
19+
description = 'libmsym python binding',
20+
license='MIT',
21+
author='Marcus Johansson',
22+
author_email='[email protected]',
23+
url='https://github.com/mcodev31/libmsym',
24+
packages=['libmsym']
25+
)

0 commit comments

Comments
 (0)