Skip to content

Latest commit

 

History

History
202 lines (128 loc) · 6.42 KB

BUILDING.rst

File metadata and controls

202 lines (128 loc) · 6.42 KB

Building NCPA

Building on Windows

Note: The current Windows pre-build script is written in batch and must be executed by cmd.exe. For this reason, any Windows commands listed in this document will be written with cmd.exe compatibility in mind.

Prerequisites

Python Packages

There are more Python packages that need to be installed too but they are installed later on with a setup script that you can run. A full list of required packages is available in ncpa/build/resources/requires.txt.

Configure the Build Environment

Install Prerequisites

  • Python

    1. Download and install Python 2.7.13. (see prerequisites)
    2. Execute the installer as usual. It's important that the installation path is not changed from the default of C:\python27 as cx_Freeze can have difficulty finding Python resources if it's installed at a custom path.
  • OpenSSL

    1. Download and install the OpenSSL package. (see prerequisites)
    2. Be sure to make a not of the installation directory while installing.
  • Microsoft Visual C++ Compiler for Python 2.7

    1. Download and run the installer. (see prerequisites)

    Running the installer without administrator privileges will cause the files to be installed to:

    %LOCALAPPDATA%\Programs\Common\Microsoft\Visual C++ for Python\9.0
    
  • Microsoft Visual C++ 2010 runtime (32-bit)

    1. Download and run the installer. (see prerequisites)
  • NSIS

    1. Download and run the installer. (see prerequisites)
  • pip

    • Pip is installed by default in Python 2.7.13 but should be updated before continuing:

      "%pydir%" -m pip install --upgrade pip
      

Set Environment Variables

Two variables must be set for the win_build_setup.bat script to run properly:

  • pydir: The root directory of your Python installation.

    This should be:

    C:\Python27
    
  • openssldir: The root directory of your OpenSSL installation.

    This should be:

    C:\OpenSSL-Win32
    

Set these variables by running:

set pydir=C:\Python27
set openssldir=C:\OpenSSL-Win32

Install the Last Modules

  • Install the full list of python modules

    "%pydir%" -m pip install pypiwin32 psutil requests Jinja2 flask werkzeug docutils pyOpenSSL gevent cffi appdirs packaging

  • cx_Logging (http://cx-logging.sourceforge.net/)

    • Install the python 2.7 version of cx_Logging for Windows via the .msi
  • cx_Freeze (patched)

    • Install cx_Freeze via the included patched version:

      ncpa\build\resources\cx_Freeze-4.3.4-patched.tar.gz
      "%pydir%\python" cx_Freeze-4.3.4\setup.py install
      
  • gevent-websocket (patched)

    • Install gevent-websocket via the included patched version:

      ncpa\build\resources\gevent-websocket-0.9.5-patched.tar.gz
      "%pydir%\python" gevent-websocket-0.9.5\setup.py install
      

Build NCPA

Run the build script:

"%pydir%\python" build\build_windows.py

Building on Linux

Building from most Linux distros is much less complicated than Windows. We have a couple helpful scripts that make it much easier. We will assume you have wget and git installed

To start, clone the repository in your directory:

cd ~
git clone https://github.com/NagiosEnterprises/ncpa

Note: Running the following scripts on CentOS 7 will make yum not work due to the Python version that yum uses. You can build the CentOS 7 version with the Python version that comes with it, but you will have to install things manually.

Now run the setup scripts to install the requirements:

cd ncpa/build/scripts
./linux_build_prereqs.sh
./linux_build_setup.sh

Once these have completed you can do an actual build. You can run make differently depending on which type of Linux you have.

Warning: Be careful when making changes to NCPA while building, you should commit your changes since `make all` will do a `git reset --hard` before building.

On RPM-based systems:

cd build
make build_rpm

On DEB-based systems:

cd build
make build_deb

Building on Mac OS X

Working on this section. It's basically the same as Linux, however you may need to install the libraries and python differently. You'll also have to use the following command to build the dmg:

cd build
make build_dmg

Building Tips

There are plenty of derivative operating systems that will not work by following just the instructions given in this document. NCPA is capable of being built on any system that supports Python, so not to worry - it is possible!

The common problem is going to be getting the libraries for all the python modules to be compiled and behave correctly with Python. We recommend compiling them from source if you must, and compiling Python from source too - with any changes you need to give the Python build process for library locations. Once that's done, you can continue by installing the required pip modules and trying the build process.

Making NCPA is pretty easy once the requirements are done, just run make:

Warning: Be careful when making changes to NCPA while building, you should commit your changes since `make all` will do a `git reset --hard` before building.

On RPM-based systems:

cd build
make build_rpm

On DEB-based systems:

cd build
make build_deb