Skip to content

Commit

Permalink
Merge pull request #26 from lsst-camera-dh/LSSTTD-864
Browse files Browse the repository at this point in the history
code to copy installed versions of packages to install directory
  • Loading branch information
jchiang87 authored Jan 29, 2017
2 parents ebb4711 + 97ac443 commit 380cd77
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
3 changes: 3 additions & 0 deletions bin/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import print_function, absolute_import
import os
import glob
import shutil
import subprocess
import warnings
import ConfigParser
Expand Down Expand Up @@ -35,6 +36,8 @@ def __init__(self, version_file, inst_dir='.',
self.version_file = os.path.abspath(version_file)
if inst_dir is not None:
self.inst_dir = os.path.abspath(inst_dir)
shutil.copy(self.version_file,
os.path.join(self.inst_dir, 'installed_versions.txt'))
self.hj_folders = hj_folders
self.site = site
self._package_dirs = None
Expand Down
17 changes: 11 additions & 6 deletions tests/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,31 @@ class InstallTestCase(unittest.TestCase):
"TestCase class for install.py execution."

def setUp(self):
subprocess.call('rm -rf tmp/', shell=True)
os.mkdir('tmp')
self.inst_dir = 'tmp'
subprocess.call('rm -rf %s/' % self.inst_dir, shell=True)
os.mkdir(self.inst_dir)

def tearDown(self):
os.remove('install.log')
subprocess.call('rm -rf tmp/', shell=True)
subprocess.call('rm -rf %s/' % self.inst_dir, shell=True)

def test_install_py(self):
"Test install.py"
command = '(../bin/install.py --inst_dir tmp test_install_versions.txt) >& install.log'
command = '(../bin/install.py --inst_dir %s test_install_versions.txt) >& install.log' % self.inst_dir
self.assertEqual(subprocess.check_call(command, shell=True,
executable='/bin/bash'), 0)
command = 'source tmp/setup.sh; python -c "import siteUtils; import metUtils; import vendorFitsTranslators; import eotestUtils; import lsst.eotest.sensor"'
command = 'source %s/setup.sh; python -c "import siteUtils; import metUtils; import vendorFitsTranslators; import eotestUtils; import lsst.eotest.sensor"' % self.inst_dir
self.assertEqual(subprocess.check_call(command, shell=True,
executable='/bin/bash'), 0)
args = ('source tmp/setup.sh; python -c "import foobar"',)
args = ('source %s/setup.sh; python -c "import foobar"'
% self.inst_dir,)
kwds = dict(shell=True, executable='/bin/bash',
stderr=subprocess.STDOUT)
self.assertRaises(subprocess.CalledProcessError,
subprocess.check_output, *args, **kwds)

self.assertTrue(os.path.isfile(os.path.join(self.inst_dir,
'installed_versions.txt')))

if __name__ == '__main__':
unittest.main()

0 comments on commit 380cd77

Please sign in to comment.