Skip to content

Commit

Permalink
Refs #11482. Packaging fails if a python file is missing.
Browse files Browse the repository at this point in the history
  • Loading branch information
quantumsteve committed Apr 16, 2015
1 parent 2812426 commit eaa7b58
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 27 deletions.
5 changes: 4 additions & 1 deletion Code/Mantid/MantidPlot/FixMavericksBundle.cmake.in
@@ -1,3 +1,6 @@
set ( bundle ${CMAKE_INSTALL_PREFIX}/MantidPlot.app )
execute_process(COMMAND chmod +x make_package.rb WORKING_DIRECTORY ${bundle})
execute_process(COMMAND ./make_package.rb WORKING_DIRECTORY ${bundle})
execute_process(COMMAND ./make_package.rb WORKING_DIRECTORY ${bundle} RESULT_VARIABLE install_name_tool_result)
if(NOT install_name_tool_result EQUAL 0)
message(FATAL_ERROR "Package script failed!!!\n")
endif()
57 changes: 31 additions & 26 deletions Code/Mantid/MantidPlot/make_package.rb
Expand Up @@ -3,6 +3,22 @@

require 'pathname'

def copyFile(file)
p "copying file #{file}"
output = system("cp #{file} Contents/MacOS/")
if output != true
exit 1
end
end

def addPythonLibrary(directory)
p "copying directory #{directory}"
output = system("rsync -a --exclude=.pyc #{directory} Contents/MacOS/")
if output != true
exit 1
end
end

lib_dir = Pathname.new("/usr/local/lib")
openssl_dir = Pathname.new("/usr/local/opt/openssl/lib")

Expand Down Expand Up @@ -51,11 +67,11 @@
#This copies the libraries over, then changes permissions and the id from /usr/local/lib to @rpath
library_filenames.each do |filename|
if filename.include? "libssl.dylib"
`cp #{openssl_dir+filename} Contents/MacOS/`
copyFile(openssl_dir+filename)
elsif filename.include? "libcrypto.dylib"
`cp #{openssl_dir+filename} Contents/MacOS/`
copyFile(openssl_dir+filename)
else
`cp #{lib_dir+filename} Contents/MacOS/`
copyFile(lib_dir+filename)
end
`chmod +w Contents/MacOS/#{filename}`
`install_name_tool -id @rpath/#{filename} Contents/MacOS/#{filename}`
Expand Down Expand Up @@ -151,40 +167,29 @@
`install_name_tool -change /usr/local/lib/QtCore.framework/Versions/4/QtCore @loader_path/../../Frameworks/QtCore.framework/Versions/4/QtCore Contents/MacOS/PyQt4/QtXml.so`

#Copy over python libraries not included with OSX.
`cp -r /Library/Python/2.7/site-packages/sphinx Contents/MacOS/`
`cp -r /Library/Python/2.7/site-packages/sphinx_bootstrap_theme Contents/MacOS/`
`cp -r /Library/Python/2.7/site-packages/IPython Contents/MacOS/`
`cp -r /Library/Python/2.7/site-packages/zmq Contents/MacOS/`
`cp -r /Library/Python/2.7/site-packages/pygments Contents/MacOS/`

#add other dependencies found in current package
#currently missing epics
`cp /Library/Python/2.7/site-packages/gnureadline.so Contents/MacOS/`
`cp /Library/Python/2.7/site-packages/readline.py Contents/MacOS/`
`cp /Library/Python/2.7/site-packages/readline.pyc Contents/MacOS/`
`cp /Library/Python/2.7/site-packages/pyparsing.py Contents/MacOS/`
`cp /Library/Python/2.7/site-packages/pyparsing.pyc Contents/MacOS/`
`cp -r /Library/Python/2.7/site-packages/_markerlib/ Contents/MacOS/`
`cp -r /Library/Python/2.7/site-packages/backports Contents/MacOS/`
`cp -r /Library/Python/2.7/site-packages/certifi Contents/MacOS/`
`cp -r /Library/Python/2.7/site-packages/tornado Contents/MacOS/`
`cp -r /Library/Python/2.7/site-packages/markupsafe Contents/MacOS/`
`cp -r /Library/Python/2.7/site-packages/jinja2 Contents/MacOS/`
`cp -r /usr/local/lib/python2.7/site-packages/nxs Contents/MacOS/`
`cp -r /Library/Python/2.7/site-packages/psutil Contents/MacOS/`
path = "/Library/Python/2.7/site-packages"
directories = ["sphinx","sphinx_bootstrap_theme","IPython","zmq","pygments","backports","certifi","tornado","markupsafe","jinja2","psutil"]
directories.each do |directory|
addPythonLibrary("#{path}/#{directory}")
end

files = ["gnureadline.so","readline.py","pyparsing.py"]
files.each do |file|
copyFile("#{path}/#{file}")
end

`mkdir Contents/MacOS/bin`
`cp /usr/local/bin/ipython Contents/MacOS/bin/`

# current .pyc files have permissions issues. These files are recreated by CPack.
`rm Contents/MacOS/nxs/*.pyc`

#Lastly check for any libraries in the package linking against homebrew libraries.
search_patterns.each do |pattern|
Dir[pattern].each do |library|
dependencies = `otool -L #{library}`
dependencies.split("\n").each do |dependency|
if dependency.include? "/usr/local/"
p "issue with library: #{library} linked against: #{dependency}"
exit 1
end
end
end
Expand Down

0 comments on commit eaa7b58

Please sign in to comment.