Skip to content

Commit

Permalink
Make python module installable via pip install (issue #73)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoconni committed Oct 28, 2018
1 parent cd15a14 commit cd9ae08
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 16 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ before_install:
- gem install gist
- mkdir build
- cd build
- cmake -DCMAKE_INSTALL_PREFIX=~/ -DINSTALL_PYTHON_MODULE=ON -DCPACK_GENERATOR=DEB -DBUILD_SHARED_LIBS=$USE_SYSTEM_EXPAT -DSYSTEM_EXPAT=$USE_SYSTEM_EXPAT ..
- cmake -DCMAKE_INSTALL_PREFIX=~/ -DCPACK_GENERATOR=DEB -DBUILD_SHARED_LIBS=$USE_SYSTEM_EXPAT -DSYSTEM_EXPAT=$USE_SYSTEM_EXPAT ..
- make -j2
- python python/setup.py bdist_wheel --skip-build
install:
- pip install dist/JSBSim*.whl
- export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/lib
- make install
script:
Expand Down
32 changes: 17 additions & 15 deletions python/setup.py.in
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import os, sys

from distutils.core import setup
from setuptools import setup
from distutils.extension import Extension
from distutils.command.build_ext import build_ext
from distutils.command.install_lib import install_lib
from distutils.command.install_egg_info import install_egg_info
from setuptools.command.build_ext import build_ext
from setuptools.command.install_lib import install_lib
from setuptools.command.install_egg_info import install_egg_info
from distutils import log


Expand Down Expand Up @@ -37,8 +37,10 @@ class InstallJSBSimModule(install_lib):
self.module_name = build_ext.get_ext_filename(build_ext.extensions[0].name)

def install(self):
if not os.path.exists(self.install_dir):
os.makedirs(self.install_dir)
self.copy_file(os.path.join('tests', self.module_name),
self.install_dir+self.module_name)
os.path.join(self.install_dir, self.module_name))

# Dummy class to skip the installation process of the library
class SkipInstallLib(InstallJSBSimModule):
Expand All @@ -64,13 +66,13 @@ setup(
library_dirs=[os.path.join('${CMAKE_BINARY_DIR}',
'src')],
language='c++')])

# Build process for the fpectl module (but don't install !!!)
setup(
cmdclass={'build_ext': QuietBuild, 'install_lib': SkipInstallLib,
'install_egg_info': SkipInstallEgg},
ext_modules=[Extension('fpectl',
sources=[os.path.join('${CMAKE_SOURCE_DIR}',
'python',
'fpectlmodule.cpp')],
language='c++')])
if sys.argv[1] != 'bdist_wheel':
# Build process for the fpectl module (but don't install !!!)
setup(
cmdclass={'build_ext': QuietBuild, 'install_lib': SkipInstallLib,
'install_egg_info': SkipInstallEgg},
ext_modules=[Extension('fpectl',
sources=[os.path.join('${CMAKE_SOURCE_DIR}',
'python',
'fpectlmodule.cpp')],
language='c++')])

0 comments on commit cd9ae08

Please sign in to comment.