An installation makes certain files available under certain directories.
For instance:
- Making executable files available under a directory listed in your
PATHenvironment variable. - Making system libraries available under a directory listed in your
LIBRARY_PATHenvironment variable. - Making Python libraries available under a directory listed in your
PYTHON_PATHenvironment variable. - Making Git hooks available under a
.git/hooksdirectory (or.git\hookson Windows). - Making configuration files (e.g.,
.vimrc) available under your home directory.
install.py aims to provide simple, robust, and reusable means to these
ends, and beyond.
In the following, the keyword "SHOULD" is to be interpreted as described in RFC 2119.
install.pySHOULD be easy to use in, or adapt to a small project.install.pySHOULD be cross-platform.install.pySHOULD make it easy to keep installed files up-to-date.
Most file-systems allow for files to be copied from one directory to another. Copying has the down-side that a copy may become out of date with the source. Some file-systems tackle this by allowing "symbolic links": files that seamlessly refer to other files.
Symbolic links are generally available in contemporary file-systems for Unix-like operating systems and on Windows since Windows 6.0 (Vista).
The utility is implemented as a standalone Python file, install.py.
To ensure proper accreditation, manage releases, and reduce code
duplication, install.py is generated from an m4 template. To get the shell script, either:
Type
maketo build it, if you happen to have the m4 macro processor installed.Please note, the last step of building
install.pyis to executegit-ready-to-deploy.sh. This ensures a clean release ofinstall.py, so long as you mind the exit code ofmake.
Copy install_py into the directory containing the files that you would like
to install. Create an INI file, (e.g., called config.ini) having a
install.py section with the properties src_dir, dst_dir, and
files. The values of the properties may be arbitrary Python expressions,
evaluating to the types str, str, and List[str], respectively. This
is to allow you to specify the configuration in a platform-independent way.
For instance, you might have a hooks directory in your Git repository,
having an install.py, and a config.ini that looks like this:
[install.py]
src_dir = os.path.dirname(__file__)
dst_dir = os.path.join(src_dir, '..', '.git', 'hooks')
files = ['pre-commit', 'pre-push']This will take the location of the executing install.py as src_dir, its
sibling directory ../.git/hooks/ (or ..\.git\hooks on Windows) as
dst_dir, and look for the files pre-commit and pre-push to install
from src_dir into dst_dir.