Skip to content

Commit

Permalink
boilerplate for new python library product
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanbeal committed Jun 2, 2017
1 parent 3dabd65 commit 55d5639
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Configuration
*.pyc
*~
17 changes: 17 additions & 0 deletions Configuration.default
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

#
# Configuration.default
#

#
# If the MGICONFIG environment variable does not have a local override,
# use the default "live" settings.
#
if [ "${MGICONFIG}" = "" ]
then
MGICONFIG=/usr/local/mgi/live/mgiconfig
export MGICONFIG
fi

. ${MGICONFIG}/master.config.sh
5 changes: 5 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
TAG: none
DATE: 6/1/2017
STAFF: jsb
CHANGES:
1) new product, initial addition
78 changes: 78 additions & 0 deletions Install
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/bin/sh
#
# Install
###########################################################################
#
# Purpose: This script compiles all *.py files and copies both the *.py
# and the *.pyc files to the given directory.
#
# Usage: Install <library_directory>
#
# where
#
# library_directory is the full path of the directory where
# the *.py and *.pyc files are copied.
#
###########################################################################

cd `dirname $0`

#
# Source the configuration file.
#
. ./Configuration

#
# Verify the arguments to the script.
#
if [ $# -ne 1 ]
then
echo "Usage: $0 <library_directory>"
exit 1
fi
LIBRARY_DIRECTORY=$1

#
# If the library directory does not exist, create it.
#
if [ ! -d ${LIBRARY_DIRECTORY} ]
then
mkdir -p ${LIBRARY_DIRECTORY}
if [ $? -ne 0 ]
then
echo "Cannot create directory: ${LIBRARY_DIRECTORY}"
exit 1
fi
fi

#
# Compile all Python scripts.
#
python -c 'import compileall; compileall.compile_dir(".")'
if [ $? -ne 0 ]
then
echo "Error compiling Python source"
exit 1
fi

#
# Set the proper permissions on the Python files.
#
chmod 775 *.py
chmod 664 *.pyc

#
# Copy the Python files to the given library directory.
#
for FILE in `ls *.py *.pyc`
do
rm -f ${LIBRARY_DIRECTORY}/${FILE}
cp -p ${FILE} ${LIBRARY_DIRECTORY}
if [ $? -ne 0 ]
then
echo "Cannot copy ${FILE} to ${LIBRARY_DIRECTORY}"
exit 1
fi
done

exit 0

0 comments on commit 55d5639

Please sign in to comment.