diff --git a/.gitignore b/.gitignore index 59afc3c56..5047f16b0 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,8 @@ web/config_local.py pgadmin4.log *.swp *.swo +/pgadmin4 +/pgadmin4.egg-info +/MANIFEST.in +/build +/dist diff --git a/Makefile b/Makefile new file mode 100644 index 000000000..6b0e3bcbf --- /dev/null +++ b/Makefile @@ -0,0 +1,91 @@ +######################################################################## +# +# pgAdmin 4 - PostgreSQL Tools +# +# Copyright (C) 2013 - 2016, The pgAdmin Development Team +# This software is released under the PostgreSQL Licence +# +######################################################################### + +SHELL = /bin/sh + +######################################################################### +# High-level targets +######################################################################### + +all: install-pip-requirements pip + +clean: clean-pip + +######################################################################### +# Python PIP package +######################################################################### + +ERROR_PERMISSIONS = by 'make install-pip-requirements'. The user must have permission to add files to site-packages for Python installation/virtual environment + +IS_WHEEL_INSTALLED=0 +WHEEL_CHECK_CMD = which pip &> /dev/null && pip list wheel | grep wheel 2> /dev/null +WHEEL_INSTALL_CMD = pip install wheel + +IS_PIP_INSTALLED=0 +PIP_INSTALL_CMD = easy_install pip +PIP_CHECK_CMD = which pip &> /dev/null && pip show pip | grep Metadata-Version 2>/dev/null + +PGADMIN_SRC_DIR = pgadmin4 +PGADMIN_EGG = ${PGADMIN_SRC_DIR}.egg-info +PGADMIN_BUILD = build +PGADMIN_DIST = build +PGADMIN_MANIFEST = MANIFEST.in +PGADMIN_INSTALL_CMD = pip install --use-wheel --find-links=${PGADMIN_DIST} ${PGADMIN_SRC_DIR} + + +define create_manifest +@echo 'recursive-include ${PGADMIN_SRC_DIR} *\nglobal-exclude pgadmin4.db *.pyc' > ${PGADMIN_MANIFEST} +endef + +define build + python pkg/pip/setup_pip.py bdist_wheel +endef + + +install-pip-requirements: +ifeq ($(shell ${PIP_CHECK_CMD}),) + ${PIP_INSTALL_CMD} + $(eval IS_PIP_INSTALLED=1) +endif + +ifeq ($(shell ${WHEEL_CHECK_CMD}),) + ${WHEEL_INSTALL_CMD} + $(eval IS_WHEEL_INSTALLED=1) +endif + +pip: +ifeq ($(shell ${PIP_CHECK_CMD}),) + @if [ $(value IS_PIP_INSTALLED) -ne 1 ]; \ + then \ + echo >&2 "Install pip ${ERROR_PERMISSIONS}"; \ + false; \ + fi +endif + +ifeq ($(shell ${WHEEL_CHECK_CMD}),) + @if [ $(value IS_WHEEL_INSTALLED) -ne 1 ]; \ + then \ + echo >&2 "Install wheel ${ERROR_PERMISSIONS}"; \ + false; \ + fi +endif + + cp -r web ${PGADMIN_SRC_DIR} + $(call create_manifest) + $(call build) + +install-pip: + ${PGADMIN_INSTALL_CMD} + +clean-pip: + rm -rf ${PGADMIN_SRC_DIR} + rm -rf ${PGADMIN_EGG} + rm -rf ${PGADMIN_BUILD} + rm -rf ${PGADMIN_DIST} + rm -f ${PGADMIN_MANIFEST} diff --git a/pkg/pip/setup_pip.py b/pkg/pip/setup_pip.py new file mode 100644 index 000000000..da08305b4 --- /dev/null +++ b/pkg/pip/setup_pip.py @@ -0,0 +1,83 @@ +######################################################################### +# +# pgAdmin 4 - PostgreSQL Tools +# +# Copyright (C) 2013 - 2016, The pgAdmin Development Team +# This software is released under the PostgreSQL Licence +# +########################################################################## + +import sys +import os +import imp + +from setuptools import setup +from codecs import open +from os import path + +"""This script is used to help generate PIP packages""" + +# Get the requirements list for the current version of Python +req_file='requirements_py' + str(sys.version_info[0]) + '.txt' + +with open(req_file) as reqf: + required = reqf.read().decode("utf-8").splitlines() + +# Get the app version +modl = imp.load_source('APP_VERSION', 'web/config.py') + +setup( + name='pgadmin4', + + version=modl.APP_VERSION, + + description='PostgreSQL Tools', + long_description='Administration and management tools for the PostgreSQL database.', + + url='http://www.pgadmin.org/', + + # Author details + author='The pgAdmin Development Team', + author_email='pgadmin-hackers@postgresql.org', + + # Choose your license + license='PostgreSQL Licence', + + # See https://pypi.python.org/pypi?%3Aaction=list_classifiers + classifiers=[ + # 3 - Alpha + # 4 - Beta + # 5 - Production/Stable + 'Development Status :: 3 - Alpha', + + # Suppported Programming Languages + 'Programming Language :: Python :: 2.6', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.2', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', +], + + keywords='pgadmin4,postgresql,postgres', + + # Specify package names here. + packages=["pgadmin4",], + + # To inclue dditional files into the package + include_package_data=True, + + install_requires=required, + + ##extras_require=, + + # Specify date files to be included. For Python 2.6 need to include them in MANIFEST.in + ##package_data="", + + # To package data files outside package directory. + ##data_files=, + + # 'scripts' keyword is used to provide executable scripts. It provides cross-platform support. + ##entry_points=, + +)