diff --git a/.gitignore b/.gitignore
index 5d84dd2..c11f83d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,4 +24,6 @@ pgadmin4.log
 /pgadmin4.egg-info
 /MANIFEST.in
 /build
+/mac-build
+/rpm-build
 /dist
diff --git a/Makefile b/Makefile
index adae41c..5a10678 100644
--- a/Makefile
+++ b/Makefile
@@ -13,9 +13,9 @@ SHELL = /bin/sh
 # High-level targets
 #########################################################################
 
-all: install-pip-requirements pip
+all: docs install-pip-requirements pip appbundle rpm
 
-clean: clean-pip
+clean: clean-pip clean-docs clean-appbundle clean-rpm
 
 #########################################################################
 # Python PIP package
@@ -34,6 +34,8 @@ PIP_CHECK_CMD = which pip &> /dev/null && pip show pip | grep Metadata-Version 2
 PGADMIN_SRC_DIR = pgadmin4
 PGADMIN_EGG = ${PGADMIN_SRC_DIR}.egg-info
 PGADMIN_BUILD = build
+PGADMIN_MACBUILD = mac-build
+PGADMIN_RPMBUILD = rpm-build
 PGADMIN_DIST = dist
 PGADMIN_MANIFEST = MANIFEST.in
 PGADMIN_INSTALL_CMD = pip install --use-wheel --find-links=${PGADMIN_DIST} ${PGADMIN_SRC_DIR}
@@ -83,9 +85,32 @@ endif
 install-pip:
 	${PGADMIN_INSTALL_CMD}
 
+appbundle: docs
+	./pkg/mac/build.sh
+
+docs:
+	LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 $(MAKE) -C docs/en_US -f Makefile.sphinx html
+
+clean-docs:
+	LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 $(MAKE) -C docs/en_US -f Makefile.sphinx clean
+
 clean-pip:
 	rm -rf ${PGADMIN_SRC_DIR}
 	rm -rf ${PGADMIN_EGG}
 	rm -rf ${PGADMIN_BUILD}
 	rm -rf ${PGADMIN_DIST}
 	rm -f ${PGADMIN_MANIFEST}
+
+clean-appbundle:
+	rm -rf ${PGADMIN_MACBUILD}
+	rm -rf ${PGADMIN_DIST}/pgadmin4*.dmg*
+
+rpm:
+	./pkg/rpm/build.sh
+
+clean-rpm:
+	rm -rf ${PGADMIN_RPMBUILD}
+	rm -rf ${PGADMIN_DIST}/noarch
+	rm -rf ${PGADMIN_DIST}/x86_64
+
+.PHONY: docs
diff --git a/docs/en_US/conf.py b/docs/en_US/conf.py
index 93ad4e9..ac7c9fc 100644
--- a/docs/en_US/conf.py
+++ b/docs/en_US/conf.py
@@ -17,6 +17,7 @@ import sys, os
 root = os.path.dirname(os.path.realpath(__file__))
 sys.path.insert(0, root + '/../../web/')
 import config
+import sphinx_rtd_theme
 
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
@@ -104,7 +105,7 @@ html_theme = 'sphinx_rtd_theme'
 #html_theme_options = {}
 
 # Add any paths that contain custom themes here, relative to this directory.
-#html_theme_path = []
+html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
 
 # The name for this set of Sphinx documents.  If None, it defaults to
 # "<project> v<release> documentation".
diff --git a/pkg/rpm/README.txt b/pkg/rpm/README.txt
new file mode 100644
index 0000000..9bbd25e
--- /dev/null
+++ b/pkg/rpm/README.txt
@@ -0,0 +1,30 @@
+Installing pgAdmin
+==================
+
+This document describes how to build pgAdmin on Linux and generate the RPMs.
+
+Supported Versions:
+
+ - RHEL6 or above, Fedora 22 or above
+
+Required Packages:
+
+ - All the required packages are mentioned in the requirements file. They should be
+installed with yum/dnf. On RHEL, some python modules are available only through EPEL.
+
+1. Python devel
+  - Python 2.6 or above
+
+2. Sphinx (to build docs)
+
+3. QT devel
+  - Qt 4.6 or above, QT 5
+
+4. PostgreSQL installation
+  - PostgreSQL 9.1 or above 
+ 
+
+Building:
+
+To build, go to pgAdmin4 source root directory and execute "make rpm". This will
+create the RPMs for runtime, web and doc in $SRC/dist
diff --git a/pkg/rpm/build.sh b/pkg/rpm/build.sh
new file mode 100755
index 0000000..a6ebd81
--- /dev/null
+++ b/pkg/rpm/build.sh
@@ -0,0 +1,88 @@
+#!/bin/sh
+
+#Script to create the pgAdmin4 RPMs.
+
+# Check whether lsb_release exists to find the OS information
+if [ ! -f /usr/bin/lsb_release ]
+then
+        echo
+        echo "ERROR: lsb_release command does not exist. Please install it with"
+        echo
+        echo "yum -y install redhat-lsb-core"
+        echo
+        echo "Exiting..."
+        echo
+        exit 1
+fi
+
+# Check if spectool exists to download the sources
+if [ ! -f /usr/bin/spectool ]
+then
+        echo
+        echo "ERROR: spectool command does not exist. Please install it with"
+        echo
+        echo "yum -y install rpmdevtools"
+        echo
+        echo "Exiting..."
+        echo
+        exit 1
+fi
+
+# Gather some information from the OS: OS name, version and arch:
+LSB_DISTRO_NAME=`lsb_release -i -s`
+LSB_DISTRO_VERSION=`lsb_release -r -s`
+DISTRO_ARCH=`uname -m`
+
+# We need the lowercase version of the distro name:
+LSB_DISTRO_NAME=`echo $LSB_DISTRO_NAME | awk '{print tolower($0)}'`
+
+if [ "$LSB_DISTRO_NAME" = "centos" ]; then
+	LSB_DISTRO_VERSION=`echo $LSB_DISTRO_VERSION | cut -d"." -f1`
+	PKG_DIR="el-$LSB_DISTRO_VERSION"
+else
+	PKG_DIR="f-$LSB_DISTRO_VERSION"
+fi
+
+# Variables
+export TOPDIR=$(cd `dirname $0` && pwd)/../..
+export RPMBUILDROOT=$TOPDIR/rpm-build
+export SOURCEDIR=$RPMBUILDROOT/sources
+export BUILDDIR=$RPMBUILDROOT/build
+export BUILDROOT=$RPMBUILDROOT/buildroot
+export DISTROOT=$TOPDIR/dist
+
+# Create the directories if not exist
+mkdir -p $SOURCEDIR
+mkdir -p $BUILDDIR
+mkdir -p $BUILDROOT
+mkdir -p $DISTROOT
+
+# Find the pgAdmin4 app name and version from config.py
+export APP_RELEASE=`grep "^APP_RELEASE" web/config.py | cut -d"=" -f2 | sed 's/ //g'`
+export APP_REVISION=`grep "^APP_REVISION" web/config.py | cut -d"=" -f2 | sed 's/ //g'`
+export APP_NAME=`grep "^APP_NAME" web/config.py | cut -d"=" -f2 | sed "s/'//g"`
+# We want app name in lower case with no spaces
+export APP_NAME=`echo $APP_NAME | sed 's/ //g' | awk '{print tolower($0)}'`
+export APP_LONG_VERSION=$APP_RELEASE.$APP_REVISION
+export APP_SHORT_VERSION=`echo $APP_LONG_VERSION | cut -d . -f1,2`
+export APP_SUFFIX=`grep "^APP_SUFFIX" web/config.py | cut -d"=" -f2 | sed 's/ //g' | sed "s/'//g"`
+if [ ! -z $APP_SUFFIX ]; then
+    export APP_LONG_VERSION=$APP_LONG_VERSION-$APP_SUFFIX
+    export APP_REVISION="${APP_REVISION}_$APP_SUFFIX" #hyphen not allowed in SPEC for version
+fi
+
+# Generate SPEC
+cd ./pkg/rpm/$PKG_DIR
+
+sed -e "s/APP_REL/$APP_RELEASE/" \
+    -e "s/APP_REV/$APP_REVISION/" \
+    -e "s/APP_NAME/$APP_NAME/" \
+    -e "s/DISTRO_ARCH/$DISTRO_ARCH/" pgadmin4.spec.in > pgadmin4.spec
+
+# Build RPMs
+make rpm || exit 1
+
+# Clean up buildroot after successful build
+echo "Cleaning up..."
+rm -rf $RPMBUILDROOT
+
diff --git a/pkg/rpm/common/Makefile.global b/pkg/rpm/common/Makefile.global
new file mode 100644
index 0000000..31a6c4c
--- /dev/null
+++ b/pkg/rpm/common/Makefile.global
@@ -0,0 +1,22 @@
+
+prep:
+	# Update spec file, patches, etc, before running spectool:
+	git pull
+	# Use spectool to download source files, especially tarballs.
+	spectool -g -S $(SPECFILE) -C $(SOURCEDIR)
+
+allclean:
+	git clean -df
+
+clean:
+	rm -rf i386/ i586/ i686/ x86_64/ noarch/
+	rm -f *.src.rpm
+	rm -f *.tar *.tar.gz *.tar.bz2 *.tgz *.zip .xz
+
+rpm: prep
+	rpmbuild --define "_sourcedir $(SOURCEDIR)" \
+	--define "_specdir $(PWD)" \
+	--define  "_builddir $(BUILDDIR)" \
+	--define "_rpmdir $(DISTROOT)" \
+	--define "_buildrootdir $(BUILDROOT)" \
+	--define "dist $(DIST)" -bb $(SPECFILE)
diff --git a/pkg/rpm/el-6/Makefile b/pkg/rpm/el-6/Makefile
new file mode 100644
index 0000000..8a31664
--- /dev/null
+++ b/pkg/rpm/el-6/Makefile
@@ -0,0 +1,8 @@
+
+ARCH=`rpm --eval "%{_arch}"`
+DIR=`pwd`
+DIST=.rhel6
+SPECFILE="pgadmin4.spec"
+
+# Now, include global Makefile
+include ../common/Makefile.global
diff --git a/pkg/rpm/el-6/pgadmin4.spec.in b/pkg/rpm/el-6/pgadmin4.spec.in
new file mode 100644
index 0000000..3e58b9d
--- /dev/null
+++ b/pkg/rpm/el-6/pgadmin4.spec.in
@@ -0,0 +1,231 @@
+
+%define pgAdmin4_release APP_REL
+%define pgAdmin4_revision APP_REV
+
+%define name APP_NAME
+%define pgadmin4instdir /usr/%{name}-v%{pgAdmin4_release}
+%define pgadmin4_webinstdir %{name}-web-v%{pgAdmin4_release}
+
+Name:           %{name}
+Version:        %{pgAdmin4_release}.%{pgAdmin4_revision}
+Release:        1%{?dist}
+Summary:        pgAdmin 4 is a rewrite of the popular pgAdmin3 management tool for the PostgreSQL (http://www.postgresql.org) database.   
+
+Group:          Applications/Databases   
+License:        PostgreSQL License
+URL:            http://www.pgadmin.org
+Source0:        http://bugatti.pn.in.enterprisedb.com/temp/pgadmin4/pgadmin4-v%{version}.tar.gz
+BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+
+BuildArch:      DISTRO_ARCH
+
+BuildRequires:  mesa-libGL-devel
+BuildRequires:  gcc-c++
+Requires:       pgadmin4-web-v%{pgAdmin4_release}
+%if 0%{?fedora}
+BuildRequires:	qt5-qtbase-devel >= 5.1
+BuildRequires:  qt5-qtwebkit-devel
+%define QMAKE   /usr/bin/qmake-qt5
+%else
+BuildRequires:  qt-devel >= 4.6
+BuildRequires:  qtwebkit-devel
+%define QMAKE   /usr/lib64/qt4/bin/qmake
+%endif
+
+%if 0%{?fedora}
+BuildRequires:  python3-devel
+Requires:       python >= 3.3
+%else
+BuildRequires:  python-devel
+Requires:       python >= 2.6
+%endif
+
+%if 0%{?fedora}
+Requires:       qt >= 5.1
+%else
+Requires:       qt >= 4.6
+%endif
+
+%description
+pgAdmin 4 is a rewrite of the popular pgAdmin3 management tool for the PostgreSQL (http://www.postgresql.org) database.
+pgAdmin 4 is being written as a web application in Python, using jQuery and
+Bootstrap for the client side processing and UI. On the server side, Flask is
+being utilised.
+
+Although developed using web technologies, we intend for pgAdmin 4 to be usable
+either on a web server using a browser, or standalone on a workstation. The
+runtime/ subdirectory contains a QT based runtime application intended to allow
+this - it is essentially a browser and Python interpretor in one package which
+will be capable of hosting the Python application and presenting it to the user
+as a desktop application.
+
+%package docs
+Summary:        Documentation for pgAdmin4
+Group:          Applications/Databases
+# These are required for -docs subpackage:
+%if 0%{?fedora}
+BuildRequires:  python3-sphinx
+BuildRequires:  python3-sphinx_rtd_theme
+%else
+BuildRequires:  python-sphinx
+BuildRequires:  python-sphinx_rtd_theme
+%endif
+
+%description docs
+This package contains documentation for various languages,
+which are in html format.
+
+%package        web
+Summary:        pgAdmin4 web package
+BuildArch:      noarch
+Requires:       pgadmin4-doc-v%{pgAdmin4_release}
+%if 0%{?fedora}
+Requires:  python3-babel
+Requires:  python3-flask
+Requires:  python3-flask-sqlalchemy
+Requires:  python3-flask-wtf
+Requires:  python3-jinja2
+Requires:  python3-markupsafe
+Requires:  python3-sqlalchemy
+Requires:  python3-wtforms
+Requires:  python3-beautifulsoup4
+Requires:  python3-blinker
+Requires:  python3-html5lib
+Requires:  python3-itsdangerous
+Requires:  python3-psycopg2
+Requires:  python3-six
+Requires:  python3-crypto
+Requires:  python3-simplejson
+Requires:  python3-dateutil
+Requires:  python3-werkzeug
+Requires:  python3-sqlparse
+Requires:  python3-sqlparse
+Requires:  python3-docutils
+Requires:  python3-extras
+Requires:  python3-fixtures
+Requires:  python3-linecache2
+Requires:  python3-pbr
+Requires:  python3-pygments
+Requires:  python3-mimeparse
+Requires:  python3-snowballstemmer
+Requires:  python3-testscenarios
+Requires:  python3-testtools
+Requires:  python3-traceback2
+Requires:  python3-unittest2
+Requires:  python3-wheel
+Requires:  python3-sphinx-theme-alabaster
+#Requires:  python3-pyrsistent
+#Requires:  python3-flask-babel
+#Requires:  python3-speaklater
+#Requires:  python3-passlib
+#Requires:  python3-flask-gravatar
+#Requires:  python3-flask-mail
+#Requires:  python3-flask-security
+#Requires:  python3-flask-login
+#Requires:  python3-flask-principal
+#Requires:  python3-django-htmlmin
+%else
+Requires:  python-babel
+Requires:  python-flask
+Requires:  python-flask-sqlalchemy
+Requires:  python-flask-wtf
+Requires:  python-jinja2
+Requires:  python-markupsafe
+Requires:  python-sqlalchemy
+Requires:  python-wtforms
+Requires:  python-beautifulsoup4
+Requires:  python-blinker
+Requires:  python-html5lib
+Requires:  python-itsdangerous
+Requires:  python-psycopg2
+Requires:  python-six
+Requires:  python-crypto
+Requires:  python-simplejson
+Requires:  python-dateutil
+Requires:  python-werkzeug
+Requires:  pytz
+Requires:  python-sqlparse
+Requires:  python-sqlparse
+Requires:  python-docutils
+Requires:  python-extras
+Requires:  python-fixtures
+Requires:  python-linecache2
+Requires:  python-pbr
+Requires:  python-pygments
+Requires:  python-mimeparse
+Requires:  python-snowballstemmer
+Requires:  python-testscenarios
+Requires:  python-testtools
+Requires:  python-traceback2
+Requires:  python-unittest2
+#Requires:  python-pyrsistent
+#Requires:  python-flask-babel
+#Requires:  python-speaklater
+#Requires:  python-passlib
+#Requires:  python-flask-gravatar
+#Requires:  python-flask-mail
+#Requires:  python-flask-security
+#Requires:  python-flask-login
+#Requires:  python-flask-principal
+#Requires:  python-django-htmlmin
+#Requires:  python-importlib
+%endif
+
+%if 0%{?fedora}
+%define PYTHON_SITELIB %{python3_sitelib}
+%else
+%define PYTHON_SITELIB %{python2_sitelib}
+%endif
+
+%description    web
+This package contains the required files to run pgAdmin4 as a web application
+
+%prep
+%setup -n pgadmin4/runtime
+
+%build
+cd ../runtime
+%{QMAKE} -o Makefile pgAdmin4.pro
+make
+cd ..
+LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 make -C docs/en_US -f Makefile.sphinx html
+#chrpath -d pgAdmin4
+
+%install
+rm -rf %{buildroot}
+cd ..
+install -d -m 755 %{buildroot}/%{_docdir}/pgadmin4-docs-v%{pgAdmin4_release}
+cp -r docs/en_US/_build/html %{buildroot}/%{_docdir}/pgadmin4-docs-v%{pgAdmin4_release}
+
+cd runtime
+install -d -m 755 %{buildroot}%{pgadmin4instdir}/runtime
+cp pgAdmin4 %{buildroot}%{pgadmin4instdir}/runtime
+
+install -d -m 755 %{buildroot}%{PYTHON_SITELIB}/%{pgadmin4_webinstdir}
+cp -pR ../web/* %{buildroot}%{PYTHON_SITELIB}/%{pgadmin4_webinstdir}
+cd %{buildroot}%{PYTHON_SITELIB}/%{pgadmin4_webinstdir}
+rm -f pgadmin4.db config_local.* config*.pyc
+echo "SERVER_MODE = False" > config_local.py
+echo "MINIFY_HTML = False" >> config_local.py
+echo "HTML_HELP = '%{_docdir}/pgadmin4-doc-v1/html/'" >> config_local.py
+
+%clean
+rm -rf %{buildroot}
+
+%files
+%defattr(-,root,root,-)
+%{pgadmin4instdir}/runtime/pgAdmin4
+
+%files web
+%defattr(-,root,root,-)
+%{PYTHON_SITELIB}/%{pgadmin4_webinstdir}
+%doc
+
+%files docs
+%defattr(-,root,root)
+%{_docdir}/pgadmin4-docs-v%{pgAdmin4_release}
+
+%changelog
+* Fri Jun 03 2016 Sandeep Thakkar <sandeep.thakkar@enterprisedb.com>
+- Initial RPM for v1.0alpha1
+
diff --git a/pkg/rpm/el-7/Makefile b/pkg/rpm/el-7/Makefile
new file mode 100644
index 0000000..1eb0ea0
--- /dev/null
+++ b/pkg/rpm/el-7/Makefile
@@ -0,0 +1,8 @@
+
+ARCH=`rpm --eval "%{_arch}"`
+DIR=`pwd`
+DIST=.rhel7
+SPECFILE="pgadmin4.spec"
+
+# Now, include global Makefile
+include ../common/Makefile.global
diff --git a/pkg/rpm/el-7/pgadmin4.spec.in b/pkg/rpm/el-7/pgadmin4.spec.in
new file mode 100644
index 0000000..3e58b9d
--- /dev/null
+++ b/pkg/rpm/el-7/pgadmin4.spec.in
@@ -0,0 +1,231 @@
+
+%define pgAdmin4_release APP_REL
+%define pgAdmin4_revision APP_REV
+
+%define name APP_NAME
+%define pgadmin4instdir /usr/%{name}-v%{pgAdmin4_release}
+%define pgadmin4_webinstdir %{name}-web-v%{pgAdmin4_release}
+
+Name:           %{name}
+Version:        %{pgAdmin4_release}.%{pgAdmin4_revision}
+Release:        1%{?dist}
+Summary:        pgAdmin 4 is a rewrite of the popular pgAdmin3 management tool for the PostgreSQL (http://www.postgresql.org) database.   
+
+Group:          Applications/Databases   
+License:        PostgreSQL License
+URL:            http://www.pgadmin.org
+Source0:        http://bugatti.pn.in.enterprisedb.com/temp/pgadmin4/pgadmin4-v%{version}.tar.gz
+BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+
+BuildArch:      DISTRO_ARCH
+
+BuildRequires:  mesa-libGL-devel
+BuildRequires:  gcc-c++
+Requires:       pgadmin4-web-v%{pgAdmin4_release}
+%if 0%{?fedora}
+BuildRequires:	qt5-qtbase-devel >= 5.1
+BuildRequires:  qt5-qtwebkit-devel
+%define QMAKE   /usr/bin/qmake-qt5
+%else
+BuildRequires:  qt-devel >= 4.6
+BuildRequires:  qtwebkit-devel
+%define QMAKE   /usr/lib64/qt4/bin/qmake
+%endif
+
+%if 0%{?fedora}
+BuildRequires:  python3-devel
+Requires:       python >= 3.3
+%else
+BuildRequires:  python-devel
+Requires:       python >= 2.6
+%endif
+
+%if 0%{?fedora}
+Requires:       qt >= 5.1
+%else
+Requires:       qt >= 4.6
+%endif
+
+%description
+pgAdmin 4 is a rewrite of the popular pgAdmin3 management tool for the PostgreSQL (http://www.postgresql.org) database.
+pgAdmin 4 is being written as a web application in Python, using jQuery and
+Bootstrap for the client side processing and UI. On the server side, Flask is
+being utilised.
+
+Although developed using web technologies, we intend for pgAdmin 4 to be usable
+either on a web server using a browser, or standalone on a workstation. The
+runtime/ subdirectory contains a QT based runtime application intended to allow
+this - it is essentially a browser and Python interpretor in one package which
+will be capable of hosting the Python application and presenting it to the user
+as a desktop application.
+
+%package docs
+Summary:        Documentation for pgAdmin4
+Group:          Applications/Databases
+# These are required for -docs subpackage:
+%if 0%{?fedora}
+BuildRequires:  python3-sphinx
+BuildRequires:  python3-sphinx_rtd_theme
+%else
+BuildRequires:  python-sphinx
+BuildRequires:  python-sphinx_rtd_theme
+%endif
+
+%description docs
+This package contains documentation for various languages,
+which are in html format.
+
+%package        web
+Summary:        pgAdmin4 web package
+BuildArch:      noarch
+Requires:       pgadmin4-doc-v%{pgAdmin4_release}
+%if 0%{?fedora}
+Requires:  python3-babel
+Requires:  python3-flask
+Requires:  python3-flask-sqlalchemy
+Requires:  python3-flask-wtf
+Requires:  python3-jinja2
+Requires:  python3-markupsafe
+Requires:  python3-sqlalchemy
+Requires:  python3-wtforms
+Requires:  python3-beautifulsoup4
+Requires:  python3-blinker
+Requires:  python3-html5lib
+Requires:  python3-itsdangerous
+Requires:  python3-psycopg2
+Requires:  python3-six
+Requires:  python3-crypto
+Requires:  python3-simplejson
+Requires:  python3-dateutil
+Requires:  python3-werkzeug
+Requires:  python3-sqlparse
+Requires:  python3-sqlparse
+Requires:  python3-docutils
+Requires:  python3-extras
+Requires:  python3-fixtures
+Requires:  python3-linecache2
+Requires:  python3-pbr
+Requires:  python3-pygments
+Requires:  python3-mimeparse
+Requires:  python3-snowballstemmer
+Requires:  python3-testscenarios
+Requires:  python3-testtools
+Requires:  python3-traceback2
+Requires:  python3-unittest2
+Requires:  python3-wheel
+Requires:  python3-sphinx-theme-alabaster
+#Requires:  python3-pyrsistent
+#Requires:  python3-flask-babel
+#Requires:  python3-speaklater
+#Requires:  python3-passlib
+#Requires:  python3-flask-gravatar
+#Requires:  python3-flask-mail
+#Requires:  python3-flask-security
+#Requires:  python3-flask-login
+#Requires:  python3-flask-principal
+#Requires:  python3-django-htmlmin
+%else
+Requires:  python-babel
+Requires:  python-flask
+Requires:  python-flask-sqlalchemy
+Requires:  python-flask-wtf
+Requires:  python-jinja2
+Requires:  python-markupsafe
+Requires:  python-sqlalchemy
+Requires:  python-wtforms
+Requires:  python-beautifulsoup4
+Requires:  python-blinker
+Requires:  python-html5lib
+Requires:  python-itsdangerous
+Requires:  python-psycopg2
+Requires:  python-six
+Requires:  python-crypto
+Requires:  python-simplejson
+Requires:  python-dateutil
+Requires:  python-werkzeug
+Requires:  pytz
+Requires:  python-sqlparse
+Requires:  python-sqlparse
+Requires:  python-docutils
+Requires:  python-extras
+Requires:  python-fixtures
+Requires:  python-linecache2
+Requires:  python-pbr
+Requires:  python-pygments
+Requires:  python-mimeparse
+Requires:  python-snowballstemmer
+Requires:  python-testscenarios
+Requires:  python-testtools
+Requires:  python-traceback2
+Requires:  python-unittest2
+#Requires:  python-pyrsistent
+#Requires:  python-flask-babel
+#Requires:  python-speaklater
+#Requires:  python-passlib
+#Requires:  python-flask-gravatar
+#Requires:  python-flask-mail
+#Requires:  python-flask-security
+#Requires:  python-flask-login
+#Requires:  python-flask-principal
+#Requires:  python-django-htmlmin
+#Requires:  python-importlib
+%endif
+
+%if 0%{?fedora}
+%define PYTHON_SITELIB %{python3_sitelib}
+%else
+%define PYTHON_SITELIB %{python2_sitelib}
+%endif
+
+%description    web
+This package contains the required files to run pgAdmin4 as a web application
+
+%prep
+%setup -n pgadmin4/runtime
+
+%build
+cd ../runtime
+%{QMAKE} -o Makefile pgAdmin4.pro
+make
+cd ..
+LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 make -C docs/en_US -f Makefile.sphinx html
+#chrpath -d pgAdmin4
+
+%install
+rm -rf %{buildroot}
+cd ..
+install -d -m 755 %{buildroot}/%{_docdir}/pgadmin4-docs-v%{pgAdmin4_release}
+cp -r docs/en_US/_build/html %{buildroot}/%{_docdir}/pgadmin4-docs-v%{pgAdmin4_release}
+
+cd runtime
+install -d -m 755 %{buildroot}%{pgadmin4instdir}/runtime
+cp pgAdmin4 %{buildroot}%{pgadmin4instdir}/runtime
+
+install -d -m 755 %{buildroot}%{PYTHON_SITELIB}/%{pgadmin4_webinstdir}
+cp -pR ../web/* %{buildroot}%{PYTHON_SITELIB}/%{pgadmin4_webinstdir}
+cd %{buildroot}%{PYTHON_SITELIB}/%{pgadmin4_webinstdir}
+rm -f pgadmin4.db config_local.* config*.pyc
+echo "SERVER_MODE = False" > config_local.py
+echo "MINIFY_HTML = False" >> config_local.py
+echo "HTML_HELP = '%{_docdir}/pgadmin4-doc-v1/html/'" >> config_local.py
+
+%clean
+rm -rf %{buildroot}
+
+%files
+%defattr(-,root,root,-)
+%{pgadmin4instdir}/runtime/pgAdmin4
+
+%files web
+%defattr(-,root,root,-)
+%{PYTHON_SITELIB}/%{pgadmin4_webinstdir}
+%doc
+
+%files docs
+%defattr(-,root,root)
+%{_docdir}/pgadmin4-docs-v%{pgAdmin4_release}
+
+%changelog
+* Fri Jun 03 2016 Sandeep Thakkar <sandeep.thakkar@enterprisedb.com>
+- Initial RPM for v1.0alpha1
+
diff --git a/pkg/rpm/f-22/Makefile b/pkg/rpm/f-22/Makefile
new file mode 100644
index 0000000..d6ed841
--- /dev/null
+++ b/pkg/rpm/f-22/Makefile
@@ -0,0 +1,8 @@
+
+ARCH=`rpm --eval "%{_arch}"`
+DIR=`pwd`
+DIST=.f22
+SPECFILE="pgadmin4.spec"
+
+# Now, include global Makefile
+include ../common/Makefile.global
diff --git a/pkg/rpm/f-22/pgadmin4.spec.in b/pkg/rpm/f-22/pgadmin4.spec.in
new file mode 100644
index 0000000..3e58b9d
--- /dev/null
+++ b/pkg/rpm/f-22/pgadmin4.spec.in
@@ -0,0 +1,231 @@
+
+%define pgAdmin4_release APP_REL
+%define pgAdmin4_revision APP_REV
+
+%define name APP_NAME
+%define pgadmin4instdir /usr/%{name}-v%{pgAdmin4_release}
+%define pgadmin4_webinstdir %{name}-web-v%{pgAdmin4_release}
+
+Name:           %{name}
+Version:        %{pgAdmin4_release}.%{pgAdmin4_revision}
+Release:        1%{?dist}
+Summary:        pgAdmin 4 is a rewrite of the popular pgAdmin3 management tool for the PostgreSQL (http://www.postgresql.org) database.   
+
+Group:          Applications/Databases   
+License:        PostgreSQL License
+URL:            http://www.pgadmin.org
+Source0:        http://bugatti.pn.in.enterprisedb.com/temp/pgadmin4/pgadmin4-v%{version}.tar.gz
+BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+
+BuildArch:      DISTRO_ARCH
+
+BuildRequires:  mesa-libGL-devel
+BuildRequires:  gcc-c++
+Requires:       pgadmin4-web-v%{pgAdmin4_release}
+%if 0%{?fedora}
+BuildRequires:	qt5-qtbase-devel >= 5.1
+BuildRequires:  qt5-qtwebkit-devel
+%define QMAKE   /usr/bin/qmake-qt5
+%else
+BuildRequires:  qt-devel >= 4.6
+BuildRequires:  qtwebkit-devel
+%define QMAKE   /usr/lib64/qt4/bin/qmake
+%endif
+
+%if 0%{?fedora}
+BuildRequires:  python3-devel
+Requires:       python >= 3.3
+%else
+BuildRequires:  python-devel
+Requires:       python >= 2.6
+%endif
+
+%if 0%{?fedora}
+Requires:       qt >= 5.1
+%else
+Requires:       qt >= 4.6
+%endif
+
+%description
+pgAdmin 4 is a rewrite of the popular pgAdmin3 management tool for the PostgreSQL (http://www.postgresql.org) database.
+pgAdmin 4 is being written as a web application in Python, using jQuery and
+Bootstrap for the client side processing and UI. On the server side, Flask is
+being utilised.
+
+Although developed using web technologies, we intend for pgAdmin 4 to be usable
+either on a web server using a browser, or standalone on a workstation. The
+runtime/ subdirectory contains a QT based runtime application intended to allow
+this - it is essentially a browser and Python interpretor in one package which
+will be capable of hosting the Python application and presenting it to the user
+as a desktop application.
+
+%package docs
+Summary:        Documentation for pgAdmin4
+Group:          Applications/Databases
+# These are required for -docs subpackage:
+%if 0%{?fedora}
+BuildRequires:  python3-sphinx
+BuildRequires:  python3-sphinx_rtd_theme
+%else
+BuildRequires:  python-sphinx
+BuildRequires:  python-sphinx_rtd_theme
+%endif
+
+%description docs
+This package contains documentation for various languages,
+which are in html format.
+
+%package        web
+Summary:        pgAdmin4 web package
+BuildArch:      noarch
+Requires:       pgadmin4-doc-v%{pgAdmin4_release}
+%if 0%{?fedora}
+Requires:  python3-babel
+Requires:  python3-flask
+Requires:  python3-flask-sqlalchemy
+Requires:  python3-flask-wtf
+Requires:  python3-jinja2
+Requires:  python3-markupsafe
+Requires:  python3-sqlalchemy
+Requires:  python3-wtforms
+Requires:  python3-beautifulsoup4
+Requires:  python3-blinker
+Requires:  python3-html5lib
+Requires:  python3-itsdangerous
+Requires:  python3-psycopg2
+Requires:  python3-six
+Requires:  python3-crypto
+Requires:  python3-simplejson
+Requires:  python3-dateutil
+Requires:  python3-werkzeug
+Requires:  python3-sqlparse
+Requires:  python3-sqlparse
+Requires:  python3-docutils
+Requires:  python3-extras
+Requires:  python3-fixtures
+Requires:  python3-linecache2
+Requires:  python3-pbr
+Requires:  python3-pygments
+Requires:  python3-mimeparse
+Requires:  python3-snowballstemmer
+Requires:  python3-testscenarios
+Requires:  python3-testtools
+Requires:  python3-traceback2
+Requires:  python3-unittest2
+Requires:  python3-wheel
+Requires:  python3-sphinx-theme-alabaster
+#Requires:  python3-pyrsistent
+#Requires:  python3-flask-babel
+#Requires:  python3-speaklater
+#Requires:  python3-passlib
+#Requires:  python3-flask-gravatar
+#Requires:  python3-flask-mail
+#Requires:  python3-flask-security
+#Requires:  python3-flask-login
+#Requires:  python3-flask-principal
+#Requires:  python3-django-htmlmin
+%else
+Requires:  python-babel
+Requires:  python-flask
+Requires:  python-flask-sqlalchemy
+Requires:  python-flask-wtf
+Requires:  python-jinja2
+Requires:  python-markupsafe
+Requires:  python-sqlalchemy
+Requires:  python-wtforms
+Requires:  python-beautifulsoup4
+Requires:  python-blinker
+Requires:  python-html5lib
+Requires:  python-itsdangerous
+Requires:  python-psycopg2
+Requires:  python-six
+Requires:  python-crypto
+Requires:  python-simplejson
+Requires:  python-dateutil
+Requires:  python-werkzeug
+Requires:  pytz
+Requires:  python-sqlparse
+Requires:  python-sqlparse
+Requires:  python-docutils
+Requires:  python-extras
+Requires:  python-fixtures
+Requires:  python-linecache2
+Requires:  python-pbr
+Requires:  python-pygments
+Requires:  python-mimeparse
+Requires:  python-snowballstemmer
+Requires:  python-testscenarios
+Requires:  python-testtools
+Requires:  python-traceback2
+Requires:  python-unittest2
+#Requires:  python-pyrsistent
+#Requires:  python-flask-babel
+#Requires:  python-speaklater
+#Requires:  python-passlib
+#Requires:  python-flask-gravatar
+#Requires:  python-flask-mail
+#Requires:  python-flask-security
+#Requires:  python-flask-login
+#Requires:  python-flask-principal
+#Requires:  python-django-htmlmin
+#Requires:  python-importlib
+%endif
+
+%if 0%{?fedora}
+%define PYTHON_SITELIB %{python3_sitelib}
+%else
+%define PYTHON_SITELIB %{python2_sitelib}
+%endif
+
+%description    web
+This package contains the required files to run pgAdmin4 as a web application
+
+%prep
+%setup -n pgadmin4/runtime
+
+%build
+cd ../runtime
+%{QMAKE} -o Makefile pgAdmin4.pro
+make
+cd ..
+LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 make -C docs/en_US -f Makefile.sphinx html
+#chrpath -d pgAdmin4
+
+%install
+rm -rf %{buildroot}
+cd ..
+install -d -m 755 %{buildroot}/%{_docdir}/pgadmin4-docs-v%{pgAdmin4_release}
+cp -r docs/en_US/_build/html %{buildroot}/%{_docdir}/pgadmin4-docs-v%{pgAdmin4_release}
+
+cd runtime
+install -d -m 755 %{buildroot}%{pgadmin4instdir}/runtime
+cp pgAdmin4 %{buildroot}%{pgadmin4instdir}/runtime
+
+install -d -m 755 %{buildroot}%{PYTHON_SITELIB}/%{pgadmin4_webinstdir}
+cp -pR ../web/* %{buildroot}%{PYTHON_SITELIB}/%{pgadmin4_webinstdir}
+cd %{buildroot}%{PYTHON_SITELIB}/%{pgadmin4_webinstdir}
+rm -f pgadmin4.db config_local.* config*.pyc
+echo "SERVER_MODE = False" > config_local.py
+echo "MINIFY_HTML = False" >> config_local.py
+echo "HTML_HELP = '%{_docdir}/pgadmin4-doc-v1/html/'" >> config_local.py
+
+%clean
+rm -rf %{buildroot}
+
+%files
+%defattr(-,root,root,-)
+%{pgadmin4instdir}/runtime/pgAdmin4
+
+%files web
+%defattr(-,root,root,-)
+%{PYTHON_SITELIB}/%{pgadmin4_webinstdir}
+%doc
+
+%files docs
+%defattr(-,root,root)
+%{_docdir}/pgadmin4-docs-v%{pgAdmin4_release}
+
+%changelog
+* Fri Jun 03 2016 Sandeep Thakkar <sandeep.thakkar@enterprisedb.com>
+- Initial RPM for v1.0alpha1
+
diff --git a/pkg/rpm/f-23/Makefile b/pkg/rpm/f-23/Makefile
new file mode 100644
index 0000000..9316c99
--- /dev/null
+++ b/pkg/rpm/f-23/Makefile
@@ -0,0 +1,8 @@
+
+ARCH=`rpm --eval "%{_arch}"`
+DIR=`pwd`
+DIST=.f23
+SPECFILE="pgadmin4.spec"
+
+# Now, include global Makefile
+include ../common/Makefile.global
diff --git a/pkg/rpm/f-23/pgadmin4.spec.in b/pkg/rpm/f-23/pgadmin4.spec.in
new file mode 100644
index 0000000..3e58b9d
--- /dev/null
+++ b/pkg/rpm/f-23/pgadmin4.spec.in
@@ -0,0 +1,231 @@
+
+%define pgAdmin4_release APP_REL
+%define pgAdmin4_revision APP_REV
+
+%define name APP_NAME
+%define pgadmin4instdir /usr/%{name}-v%{pgAdmin4_release}
+%define pgadmin4_webinstdir %{name}-web-v%{pgAdmin4_release}
+
+Name:           %{name}
+Version:        %{pgAdmin4_release}.%{pgAdmin4_revision}
+Release:        1%{?dist}
+Summary:        pgAdmin 4 is a rewrite of the popular pgAdmin3 management tool for the PostgreSQL (http://www.postgresql.org) database.   
+
+Group:          Applications/Databases   
+License:        PostgreSQL License
+URL:            http://www.pgadmin.org
+Source0:        http://bugatti.pn.in.enterprisedb.com/temp/pgadmin4/pgadmin4-v%{version}.tar.gz
+BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+
+BuildArch:      DISTRO_ARCH
+
+BuildRequires:  mesa-libGL-devel
+BuildRequires:  gcc-c++
+Requires:       pgadmin4-web-v%{pgAdmin4_release}
+%if 0%{?fedora}
+BuildRequires:	qt5-qtbase-devel >= 5.1
+BuildRequires:  qt5-qtwebkit-devel
+%define QMAKE   /usr/bin/qmake-qt5
+%else
+BuildRequires:  qt-devel >= 4.6
+BuildRequires:  qtwebkit-devel
+%define QMAKE   /usr/lib64/qt4/bin/qmake
+%endif
+
+%if 0%{?fedora}
+BuildRequires:  python3-devel
+Requires:       python >= 3.3
+%else
+BuildRequires:  python-devel
+Requires:       python >= 2.6
+%endif
+
+%if 0%{?fedora}
+Requires:       qt >= 5.1
+%else
+Requires:       qt >= 4.6
+%endif
+
+%description
+pgAdmin 4 is a rewrite of the popular pgAdmin3 management tool for the PostgreSQL (http://www.postgresql.org) database.
+pgAdmin 4 is being written as a web application in Python, using jQuery and
+Bootstrap for the client side processing and UI. On the server side, Flask is
+being utilised.
+
+Although developed using web technologies, we intend for pgAdmin 4 to be usable
+either on a web server using a browser, or standalone on a workstation. The
+runtime/ subdirectory contains a QT based runtime application intended to allow
+this - it is essentially a browser and Python interpretor in one package which
+will be capable of hosting the Python application and presenting it to the user
+as a desktop application.
+
+%package docs
+Summary:        Documentation for pgAdmin4
+Group:          Applications/Databases
+# These are required for -docs subpackage:
+%if 0%{?fedora}
+BuildRequires:  python3-sphinx
+BuildRequires:  python3-sphinx_rtd_theme
+%else
+BuildRequires:  python-sphinx
+BuildRequires:  python-sphinx_rtd_theme
+%endif
+
+%description docs
+This package contains documentation for various languages,
+which are in html format.
+
+%package        web
+Summary:        pgAdmin4 web package
+BuildArch:      noarch
+Requires:       pgadmin4-doc-v%{pgAdmin4_release}
+%if 0%{?fedora}
+Requires:  python3-babel
+Requires:  python3-flask
+Requires:  python3-flask-sqlalchemy
+Requires:  python3-flask-wtf
+Requires:  python3-jinja2
+Requires:  python3-markupsafe
+Requires:  python3-sqlalchemy
+Requires:  python3-wtforms
+Requires:  python3-beautifulsoup4
+Requires:  python3-blinker
+Requires:  python3-html5lib
+Requires:  python3-itsdangerous
+Requires:  python3-psycopg2
+Requires:  python3-six
+Requires:  python3-crypto
+Requires:  python3-simplejson
+Requires:  python3-dateutil
+Requires:  python3-werkzeug
+Requires:  python3-sqlparse
+Requires:  python3-sqlparse
+Requires:  python3-docutils
+Requires:  python3-extras
+Requires:  python3-fixtures
+Requires:  python3-linecache2
+Requires:  python3-pbr
+Requires:  python3-pygments
+Requires:  python3-mimeparse
+Requires:  python3-snowballstemmer
+Requires:  python3-testscenarios
+Requires:  python3-testtools
+Requires:  python3-traceback2
+Requires:  python3-unittest2
+Requires:  python3-wheel
+Requires:  python3-sphinx-theme-alabaster
+#Requires:  python3-pyrsistent
+#Requires:  python3-flask-babel
+#Requires:  python3-speaklater
+#Requires:  python3-passlib
+#Requires:  python3-flask-gravatar
+#Requires:  python3-flask-mail
+#Requires:  python3-flask-security
+#Requires:  python3-flask-login
+#Requires:  python3-flask-principal
+#Requires:  python3-django-htmlmin
+%else
+Requires:  python-babel
+Requires:  python-flask
+Requires:  python-flask-sqlalchemy
+Requires:  python-flask-wtf
+Requires:  python-jinja2
+Requires:  python-markupsafe
+Requires:  python-sqlalchemy
+Requires:  python-wtforms
+Requires:  python-beautifulsoup4
+Requires:  python-blinker
+Requires:  python-html5lib
+Requires:  python-itsdangerous
+Requires:  python-psycopg2
+Requires:  python-six
+Requires:  python-crypto
+Requires:  python-simplejson
+Requires:  python-dateutil
+Requires:  python-werkzeug
+Requires:  pytz
+Requires:  python-sqlparse
+Requires:  python-sqlparse
+Requires:  python-docutils
+Requires:  python-extras
+Requires:  python-fixtures
+Requires:  python-linecache2
+Requires:  python-pbr
+Requires:  python-pygments
+Requires:  python-mimeparse
+Requires:  python-snowballstemmer
+Requires:  python-testscenarios
+Requires:  python-testtools
+Requires:  python-traceback2
+Requires:  python-unittest2
+#Requires:  python-pyrsistent
+#Requires:  python-flask-babel
+#Requires:  python-speaklater
+#Requires:  python-passlib
+#Requires:  python-flask-gravatar
+#Requires:  python-flask-mail
+#Requires:  python-flask-security
+#Requires:  python-flask-login
+#Requires:  python-flask-principal
+#Requires:  python-django-htmlmin
+#Requires:  python-importlib
+%endif
+
+%if 0%{?fedora}
+%define PYTHON_SITELIB %{python3_sitelib}
+%else
+%define PYTHON_SITELIB %{python2_sitelib}
+%endif
+
+%description    web
+This package contains the required files to run pgAdmin4 as a web application
+
+%prep
+%setup -n pgadmin4/runtime
+
+%build
+cd ../runtime
+%{QMAKE} -o Makefile pgAdmin4.pro
+make
+cd ..
+LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 make -C docs/en_US -f Makefile.sphinx html
+#chrpath -d pgAdmin4
+
+%install
+rm -rf %{buildroot}
+cd ..
+install -d -m 755 %{buildroot}/%{_docdir}/pgadmin4-docs-v%{pgAdmin4_release}
+cp -r docs/en_US/_build/html %{buildroot}/%{_docdir}/pgadmin4-docs-v%{pgAdmin4_release}
+
+cd runtime
+install -d -m 755 %{buildroot}%{pgadmin4instdir}/runtime
+cp pgAdmin4 %{buildroot}%{pgadmin4instdir}/runtime
+
+install -d -m 755 %{buildroot}%{PYTHON_SITELIB}/%{pgadmin4_webinstdir}
+cp -pR ../web/* %{buildroot}%{PYTHON_SITELIB}/%{pgadmin4_webinstdir}
+cd %{buildroot}%{PYTHON_SITELIB}/%{pgadmin4_webinstdir}
+rm -f pgadmin4.db config_local.* config*.pyc
+echo "SERVER_MODE = False" > config_local.py
+echo "MINIFY_HTML = False" >> config_local.py
+echo "HTML_HELP = '%{_docdir}/pgadmin4-doc-v1/html/'" >> config_local.py
+
+%clean
+rm -rf %{buildroot}
+
+%files
+%defattr(-,root,root,-)
+%{pgadmin4instdir}/runtime/pgAdmin4
+
+%files web
+%defattr(-,root,root,-)
+%{PYTHON_SITELIB}/%{pgadmin4_webinstdir}
+%doc
+
+%files docs
+%defattr(-,root,root)
+%{_docdir}/pgadmin4-docs-v%{pgAdmin4_release}
+
+%changelog
+* Fri Jun 03 2016 Sandeep Thakkar <sandeep.thakkar@enterprisedb.com>
+- Initial RPM for v1.0alpha1
+
diff --git a/pkg/rpm/f-24/Makefile b/pkg/rpm/f-24/Makefile
new file mode 100644
index 0000000..f48f68d
--- /dev/null
+++ b/pkg/rpm/f-24/Makefile
@@ -0,0 +1,8 @@
+
+ARCH=`rpm --eval "%{_arch}"`
+DIR=`pwd`
+DIST=.f24
+SPECFILE="pgadmin4.spec"
+
+# Now, include global Makefile
+include ../common/Makefile.global
diff --git a/pkg/rpm/f-24/pgadmin4.spec.in b/pkg/rpm/f-24/pgadmin4.spec.in
new file mode 100644
index 0000000..3e58b9d
--- /dev/null
+++ b/pkg/rpm/f-24/pgadmin4.spec.in
@@ -0,0 +1,231 @@
+
+%define pgAdmin4_release APP_REL
+%define pgAdmin4_revision APP_REV
+
+%define name APP_NAME
+%define pgadmin4instdir /usr/%{name}-v%{pgAdmin4_release}
+%define pgadmin4_webinstdir %{name}-web-v%{pgAdmin4_release}
+
+Name:           %{name}
+Version:        %{pgAdmin4_release}.%{pgAdmin4_revision}
+Release:        1%{?dist}
+Summary:        pgAdmin 4 is a rewrite of the popular pgAdmin3 management tool for the PostgreSQL (http://www.postgresql.org) database.   
+
+Group:          Applications/Databases   
+License:        PostgreSQL License
+URL:            http://www.pgadmin.org
+Source0:        http://bugatti.pn.in.enterprisedb.com/temp/pgadmin4/pgadmin4-v%{version}.tar.gz
+BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+
+BuildArch:      DISTRO_ARCH
+
+BuildRequires:  mesa-libGL-devel
+BuildRequires:  gcc-c++
+Requires:       pgadmin4-web-v%{pgAdmin4_release}
+%if 0%{?fedora}
+BuildRequires:	qt5-qtbase-devel >= 5.1
+BuildRequires:  qt5-qtwebkit-devel
+%define QMAKE   /usr/bin/qmake-qt5
+%else
+BuildRequires:  qt-devel >= 4.6
+BuildRequires:  qtwebkit-devel
+%define QMAKE   /usr/lib64/qt4/bin/qmake
+%endif
+
+%if 0%{?fedora}
+BuildRequires:  python3-devel
+Requires:       python >= 3.3
+%else
+BuildRequires:  python-devel
+Requires:       python >= 2.6
+%endif
+
+%if 0%{?fedora}
+Requires:       qt >= 5.1
+%else
+Requires:       qt >= 4.6
+%endif
+
+%description
+pgAdmin 4 is a rewrite of the popular pgAdmin3 management tool for the PostgreSQL (http://www.postgresql.org) database.
+pgAdmin 4 is being written as a web application in Python, using jQuery and
+Bootstrap for the client side processing and UI. On the server side, Flask is
+being utilised.
+
+Although developed using web technologies, we intend for pgAdmin 4 to be usable
+either on a web server using a browser, or standalone on a workstation. The
+runtime/ subdirectory contains a QT based runtime application intended to allow
+this - it is essentially a browser and Python interpretor in one package which
+will be capable of hosting the Python application and presenting it to the user
+as a desktop application.
+
+%package docs
+Summary:        Documentation for pgAdmin4
+Group:          Applications/Databases
+# These are required for -docs subpackage:
+%if 0%{?fedora}
+BuildRequires:  python3-sphinx
+BuildRequires:  python3-sphinx_rtd_theme
+%else
+BuildRequires:  python-sphinx
+BuildRequires:  python-sphinx_rtd_theme
+%endif
+
+%description docs
+This package contains documentation for various languages,
+which are in html format.
+
+%package        web
+Summary:        pgAdmin4 web package
+BuildArch:      noarch
+Requires:       pgadmin4-doc-v%{pgAdmin4_release}
+%if 0%{?fedora}
+Requires:  python3-babel
+Requires:  python3-flask
+Requires:  python3-flask-sqlalchemy
+Requires:  python3-flask-wtf
+Requires:  python3-jinja2
+Requires:  python3-markupsafe
+Requires:  python3-sqlalchemy
+Requires:  python3-wtforms
+Requires:  python3-beautifulsoup4
+Requires:  python3-blinker
+Requires:  python3-html5lib
+Requires:  python3-itsdangerous
+Requires:  python3-psycopg2
+Requires:  python3-six
+Requires:  python3-crypto
+Requires:  python3-simplejson
+Requires:  python3-dateutil
+Requires:  python3-werkzeug
+Requires:  python3-sqlparse
+Requires:  python3-sqlparse
+Requires:  python3-docutils
+Requires:  python3-extras
+Requires:  python3-fixtures
+Requires:  python3-linecache2
+Requires:  python3-pbr
+Requires:  python3-pygments
+Requires:  python3-mimeparse
+Requires:  python3-snowballstemmer
+Requires:  python3-testscenarios
+Requires:  python3-testtools
+Requires:  python3-traceback2
+Requires:  python3-unittest2
+Requires:  python3-wheel
+Requires:  python3-sphinx-theme-alabaster
+#Requires:  python3-pyrsistent
+#Requires:  python3-flask-babel
+#Requires:  python3-speaklater
+#Requires:  python3-passlib
+#Requires:  python3-flask-gravatar
+#Requires:  python3-flask-mail
+#Requires:  python3-flask-security
+#Requires:  python3-flask-login
+#Requires:  python3-flask-principal
+#Requires:  python3-django-htmlmin
+%else
+Requires:  python-babel
+Requires:  python-flask
+Requires:  python-flask-sqlalchemy
+Requires:  python-flask-wtf
+Requires:  python-jinja2
+Requires:  python-markupsafe
+Requires:  python-sqlalchemy
+Requires:  python-wtforms
+Requires:  python-beautifulsoup4
+Requires:  python-blinker
+Requires:  python-html5lib
+Requires:  python-itsdangerous
+Requires:  python-psycopg2
+Requires:  python-six
+Requires:  python-crypto
+Requires:  python-simplejson
+Requires:  python-dateutil
+Requires:  python-werkzeug
+Requires:  pytz
+Requires:  python-sqlparse
+Requires:  python-sqlparse
+Requires:  python-docutils
+Requires:  python-extras
+Requires:  python-fixtures
+Requires:  python-linecache2
+Requires:  python-pbr
+Requires:  python-pygments
+Requires:  python-mimeparse
+Requires:  python-snowballstemmer
+Requires:  python-testscenarios
+Requires:  python-testtools
+Requires:  python-traceback2
+Requires:  python-unittest2
+#Requires:  python-pyrsistent
+#Requires:  python-flask-babel
+#Requires:  python-speaklater
+#Requires:  python-passlib
+#Requires:  python-flask-gravatar
+#Requires:  python-flask-mail
+#Requires:  python-flask-security
+#Requires:  python-flask-login
+#Requires:  python-flask-principal
+#Requires:  python-django-htmlmin
+#Requires:  python-importlib
+%endif
+
+%if 0%{?fedora}
+%define PYTHON_SITELIB %{python3_sitelib}
+%else
+%define PYTHON_SITELIB %{python2_sitelib}
+%endif
+
+%description    web
+This package contains the required files to run pgAdmin4 as a web application
+
+%prep
+%setup -n pgadmin4/runtime
+
+%build
+cd ../runtime
+%{QMAKE} -o Makefile pgAdmin4.pro
+make
+cd ..
+LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 make -C docs/en_US -f Makefile.sphinx html
+#chrpath -d pgAdmin4
+
+%install
+rm -rf %{buildroot}
+cd ..
+install -d -m 755 %{buildroot}/%{_docdir}/pgadmin4-docs-v%{pgAdmin4_release}
+cp -r docs/en_US/_build/html %{buildroot}/%{_docdir}/pgadmin4-docs-v%{pgAdmin4_release}
+
+cd runtime
+install -d -m 755 %{buildroot}%{pgadmin4instdir}/runtime
+cp pgAdmin4 %{buildroot}%{pgadmin4instdir}/runtime
+
+install -d -m 755 %{buildroot}%{PYTHON_SITELIB}/%{pgadmin4_webinstdir}
+cp -pR ../web/* %{buildroot}%{PYTHON_SITELIB}/%{pgadmin4_webinstdir}
+cd %{buildroot}%{PYTHON_SITELIB}/%{pgadmin4_webinstdir}
+rm -f pgadmin4.db config_local.* config*.pyc
+echo "SERVER_MODE = False" > config_local.py
+echo "MINIFY_HTML = False" >> config_local.py
+echo "HTML_HELP = '%{_docdir}/pgadmin4-doc-v1/html/'" >> config_local.py
+
+%clean
+rm -rf %{buildroot}
+
+%files
+%defattr(-,root,root,-)
+%{pgadmin4instdir}/runtime/pgAdmin4
+
+%files web
+%defattr(-,root,root,-)
+%{PYTHON_SITELIB}/%{pgadmin4_webinstdir}
+%doc
+
+%files docs
+%defattr(-,root,root)
+%{_docdir}/pgadmin4-docs-v%{pgAdmin4_release}
+
+%changelog
+* Fri Jun 03 2016 Sandeep Thakkar <sandeep.thakkar@enterprisedb.com>
+- Initial RPM for v1.0alpha1
+
diff --git a/runtime/Server.cpp b/runtime/Server.cpp
index 8691224..d095d93 100644
--- a/runtime/Server.cpp
+++ b/runtime/Server.cpp
@@ -23,7 +23,7 @@
 #include "Server.h"
 
 Server::Server(quint16 port)
-{    
+{
     // Appserver port
     m_port = port;
     m_wcAppName = NULL;
@@ -47,6 +47,18 @@ Server::Server(quint16 port)
     // Setup the search path
     QSettings settings;
     QString python_path = settings.value("PythonPath").toString();
+#ifdef Q_OS_MAC
+    QString app_dir = qApp->applicationDirPath();
+    QString get_pymodules_path = (app_dir + "/../Resources/venv/lib/python/site-packages");
+    QFileInfo fi(get_pymodules_path);
+    QString pymodules_path = fi.canonicalFilePath();
+    if (!python_path.contains(pymodules_path))
+    {
+        python_path.prepend(pymodules_path); // Mac source tree (in a release app bundle)
+        settings.setValue("PythonPath", pymodules_path);
+	settings.sync();
+    }
+#endif
 
     if (python_path.length() > 0)
     {
@@ -66,6 +78,8 @@ Server::Server(quint16 port)
 #endif
         }
     }
+    python_path = settings.value("PythonPath").toString();
+    qDebug() << "Python path: " << python_path;
 }
 
 Server::~Server()
@@ -80,13 +94,26 @@ Server::~Server()
 bool Server::Init()
 {
     QSettings settings;
+#ifdef Q_OS_LINUX
+    QProcess process;
+    process.start("python -c \"from distutils.sysconfig import get_python_lib; print(get_python_lib())\"");
+    process.waitForFinished(-1);
+    QString pymodules_path = process.readAllStandardOutput();
+    pymodules_path = pymodules_path.trimmed();
+    webapp_path = pymodules_path + "/pgadmin4-web-v1";
+#endif
 
     // Find the webapp
     QStringList paths;
     paths.append("../web/"); // Linux source tree
     paths.append("../../web/"); // Windows source tree
     paths.append("../../../../web/"); // Mac source tree (in a dev env)
+#ifdef Q_OS_MAC
     paths.append("../Resources/web/"); // Mac source tree (in a release app bundle)
+#endif
+#ifdef Q_OS_LINUX
+    paths.append(webapp_path); // Linux (in a release rpm)
+#endif
     paths.append(settings.value("ApplicationPath").toString()); // System configured value
     paths.append(""); // Should be last!
 
