diff --git a/pkg/pip/build.sh b/pkg/pip/build.sh index 5b8b62f5f..8a6eefe8a 100755 --- a/pkg/pip/build.sh +++ b/pkg/pip/build.sh @@ -102,7 +102,7 @@ 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 +python ../pkg/pip/setup_pip.py bdist_wheel --universal cd ../ # Get the build diff --git a/pkg/pip/setup_pip.py b/pkg/pip/setup_pip.py index e6fb9fa79..fc797d52f 100644 --- a/pkg/pip/setup_pip.py +++ b/pkg/pip/setup_pip.py @@ -7,51 +7,68 @@ # ########################################################################## -import builtins import os import sys -from codecs import open -from importlib.machinery import SourceFileLoader from setuptools import setup +from codecs import open - -# Load a source file -def load_source(name, path): - if not os.path.exists(path): - print("ERROR: Could not find %s" % path) - sys.exit(1) - - return SourceFileLoader(name, path).load_module() - +if sys.version_info[0] >= 3: + import builtins +else: + import __builtin__ as builtins # Ensure the global server mode is set. builtins.SERVER_MODE = None +"""This script helps to generate PIP packages""" + # Get the requirements list for the current version of Python req_file = '../requirements.txt' -with open(req_file, 'r') as req_lines: - requires = req_lines.read().splitlines() +with open(req_file, 'r') as reqf: + if sys.version_info[0] >= 3: + required = reqf.read().splitlines() + else: + required = reqf.read().decode("utf-8").splitlines() # Remove any requirements with environment specifiers. These # must be explicitly listed in extras_require below. -for index, req in enumerate(requires): +for index, req in enumerate(required): if ";" in req or req.startswith("#") or req == "": - requires.remove(req) + required.remove(req) continue # Ensure the Wheel will use psycopg2-binary, not the source distro if 'psycopg2' in req: - requires[index] = req.replace('psycopg2', 'psycopg2-binary') + required[index] = req.replace('psycopg2', 'psycopg2-binary') -# Get the version -config = load_source('APP_VERSION', '../web/config.py') +# Get the app version +if sys.version_info[:2] >= (3, 3): + from importlib.machinery import SourceFileLoader + + def load_source(name, path): + if not os.path.exists(path): + print("ERROR: Could not find %s" % path) + sys.exit(1) + + return SourceFileLoader(name, path).load_module() +else: + import imp + + def load_source(name, path): + if not os.path.exists(path): + print("ERROR: Could not find %s" % path) + sys.exit(1) + + return imp.load_source(name, path) + +modl = load_source('APP_VERSION', '../web/config.py') setup( name='pgadmin4', - version=config.APP_VERSION, + version=modl.APP_VERSION, description='PostgreSQL Tools', long_description='Administration and management tools for ' @@ -69,6 +86,7 @@ setup( 'Development Status :: 5 - Production/Stable', # Supported programming languages + 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', @@ -82,7 +100,7 @@ setup( include_package_data=True, - install_requires=requires, + install_requires=required, entry_points={ 'console_scripts': ['pgadmin4=pgadmin4.pgAdmin4.__init__:main'],