Distribution File Template (_dist_)
When I develop on a local machine, I usually want to use the code immediately after I make changes and also see what was done since my last svn revision. To publish the code and any programs to the local computer, I write a short shell script for this that I call "_dist_". Here I provide the template for a full featured "_dist_" file for my JTools suite (which is a package, modules, bin files, shared files, etc.) that has, among other contents, the following directory structure:
- JTools/
- _dist_
- share/
- reslib.pkl
- src/
- bin/
- swapit
- fix-cns-chainIDs
- measure-hbonds
- merge-headers
- JTools/
- __init__.py
- distortion.py
- jtoolslib.py
In the "_dist_" file below, if a project does not need to locally publish a particular type of file (e.g. "shrfiles"), then just assign it blank like this:
set shrfiles=""
And here is the template for the distribution file:
#! /bin/csh -f
############################################################
# Change these
############################################################
#
# Specific to the suite
#
# name of the directory that the entire suite resides
set name="JTools"
# name of the python package (i.e. has an __init__.py)
set package="JTools"
# names of the files that are necessary for the package library
set libfiles="__init__.py jtoolslib.py distortion.py"
# names of the executable files in the bin/directory
set binfiles="swapit fix-cns-chainIDs measure-hbonds merge-headers"
# names of any shared resources
set shrfiles="reslib.pkl"
#
# Specific to computer's setup
#
# where the suite resides
set codedir="${HOME}/Code"
# where local or personal python modules go
set libdir="${HOME}/Code/python"
# where executable files go
set bindir="${HOME}/bin"
# where shared resources go
set shrdir="${HOME}/Code/share"
############################################################
############################################################
# Generally, no need to change things below here
############################################################
set shr="share"
set srcbin="src/bin"
set srcpkg="src/${package}"
set pkgdir="${libdir}/${package}"
set distdir="${codedir}/${name}"
cd ${distdir}
echo ' '
svn status
echo ' '
if ( "${%libfiles}" > 0 ) then
rm -rf ${pkgdir}
mkdir ${pkgdir}
cd ${distdir}
cd ${srcpkg}
echo Copying ${libfiles} to ${pkgdir}
cp ${libfiles} ${pkgdir}
endif
if ( "${%binfiles}" > 0 ) then
cd ${distdir}
cd ${srcbin}
echo Copying ${binfiles} to ${bindir}
cp ${binfiles} ${bindir}
endif
if ( "${%shrfiles}" > 0 ) then
cd ${distdir}
cd ${shr}
echo Copying ${shrfiles} to ${shrdir}
cp ${shrfiles} ${shrdir}
endif
echo ' '
echo Success.
echo ' '
