diff --git a/.gitignore b/.gitignore index 72150b7ce..ec8280307 100644 --- a/.gitignore +++ b/.gitignore @@ -20,12 +20,9 @@ web/regression/test_config.json pgadmin4.log *.swp *.swo -/pgadmin4 -/pgadmin4.egg-info -/MANIFEST.in -/build /mac-build /src-build +/pip-build /dist pkg/win32/win-build pkg/win32/installer.iss diff --git a/Makefile b/Makefile index b966d9a1d..5f7e63dab 100644 --- a/Makefile +++ b/Makefile @@ -14,105 +14,36 @@ SHELL = /bin/sh ######################################################################### # Include only platform-independent builds in all -all: docs install-pip-requirements pip src +all: docs pip src # Include all clean sub-targets in clean clean: clean-dist clean-docs clean-pip clean-appbundle clean-src -######################################################################### -# 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_MACBUILD = mac-build -PGADMIN_SRCBUILD = src-build -PGADMIN_DIST = dist -PGADMIN_MANIFEST = MANIFEST.in -PGADMIN_INSTALL_CMD = pip install --use-wheel --find-links=${PGADMIN_DIST} ${PGADMIN_SRC_DIR} - - -define create_manifest -@printf 'recursive-include ${PGADMIN_SRC_DIR} *\nglobal-exclude config_local.py\nglobal-exclude *.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 - rm -rf ${PGADMIN_SRC_DIR} - cp -r web ${PGADMIN_SRC_DIR} - $(call create_manifest) - $(call build) - -install-pip: - ${PGADMIN_INSTALL_CMD} +pip: docs + ./pkg/pip/build.sh appbundle: docs ./pkg/mac/build.sh +src: + ./pkg/src/build.sh + docs: LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 $(MAKE) -C docs/en_US -f Makefile.sphinx html +clean-pip: + rm -rf pip-build/ + +clean-appbundle: + rm -rf mac-build/ + +clean-src: + rm -rf src-build/ + 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 -f ${PGADMIN_MANIFEST} - -clean-appbundle: - rm -rf ${PGADMIN_MACBUILD} - rm -rf ${PGADMIN_DIST}/pgadmin4*.dmg* - -src: - ./pkg/src/build.sh - -clean-src: - rm -rf ${PGADMIN_SRCBUILD} - rm -rf ${PGADMIN_DIST}/pgadmin4*.tar.gz - clean-dist: - rm -rf ${PGADMIN_DIST} + rm -rf dist/ + .PHONY: docs diff --git a/pkg/pip/build.sh b/pkg/pip/build.sh new file mode 100755 index 000000000..7cbb03538 --- /dev/null +++ b/pkg/pip/build.sh @@ -0,0 +1,81 @@ +#!/bin/bash + +######################################################################## +# +# pgAdmin 4 - PostgreSQL Tools +# +# Copyright (C) 2013 - 2016, The pgAdmin Development Team +# This software is released under the PostgreSQL Licence +# +######################################################################### + +# Runtime checks +if [ ! -d runtime -a ! -d web ]; then + echo This script must be run from the top-level directory of the source tree. + exit 1 +fi + +if [ ! -d .git -a ! -f .git/config ]; then + echo This script must be run from a git checkout of the source tree. + exit 1 +fi + +# Get the required package info +APP_RELEASE=`grep "^APP_RELEASE" web/config.py | cut -d"=" -f2 | sed 's/ //g'` +APP_REVISION=`grep "^APP_REVISION" web/config.py | cut -d"=" -f2 | sed 's/ //g'` +APP_NAME=`grep "^APP_NAME" web/config.py | cut -d"=" -f2 | sed "s/'//g" | sed 's/^ //'` +APP_LONG_VERSION=$APP_RELEASE.$APP_REVISION +APP_SHORT_VERSION=`echo $APP_LONG_VERSION | cut -d . -f1,2` +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 +fi +TARBALL_NAME=`echo $APP_NAME-$APP_LONG_VERSION | sed 's/ //g' | awk '{print tolower($0)}'` + +# Output basic details to show we're working +echo Building tarballs for $APP_NAME version $APP_LONG_VERSION... + +# Create/clearout the build directory +echo Creating/cleaning required directories... +if [ ! -d pip-build ]; then + mkdir pip-build +fi + +if [ -d pip-build/pgadmin4 ]; then + rm -rf pip-build/pgadmin4 +fi + +mkdir pip-build/pgadmin4 + +# Build the clean tree +cd web +for FILE in `git ls-files` +do + echo Adding $FILE + # We use tar here to preserve the path, as Mac (for example) doesn't support cp --parents + tar cf - $FILE | (cd ../pip-build/pgadmin4; tar xf -) +done + +cd ../ +for FILE in LICENSE README libraries.txt +do + echo Adding $FILE + # We use tar here to preserve the path, as Mac (for example) doesn't support cp --parents + tar cf - $FILE | (cd pip-build/pgadmin4; tar xf -) +done + +# Create the manifest +echo Creating manifest... +echo recursive-include pgadmin4 \* > pip-build/MANIFEST.in + +# Run the build +echo Building wheel... +cd pip-build +python ../pkg/pip/setup_pip.py bdist_wheel +cd ../ + +# Get the build +if [ ! -d dist ]; then + mkdir dist +fi +cp pip-build/dist/*.whl dist/ diff --git a/pkg/pip/setup_pip.py b/pkg/pip/setup_pip.py index c5a121c07..a4249da2d 100644 --- a/pkg/pip/setup_pip.py +++ b/pkg/pip/setup_pip.py @@ -18,13 +18,13 @@ 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' +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') +modl = imp.load_source('APP_VERSION', '../web/config.py') setup( name='pgadmin4',