diff options
Diffstat (limited to 'setup.py')
-rwxr-xr-x | setup.py | 85 |
1 files changed, 40 insertions, 45 deletions
@@ -20,32 +20,21 @@ Setup file for bitmask. """ from __future__ import print_function +import glob import hashlib -import sys import os +import platform import re +import shutil import sys -if not sys.version_info[0] == 2: - print("[ERROR] Sorry, Python 3 is not supported (yet). " - "Try running with python2: python2 setup.py ...") - exit() - -try: - from setuptools import setup, find_packages -except ImportError: - from pkg import distribute_setup - distribute_setup.use_setuptools() - from setuptools import setup, find_packages +from distutils.command.build import build as _build +from setuptools import Command +from setuptools.command.develop import develop as _develop from pkg import utils import versioneer -versioneer.versionfile_source = 'src/leap/bitmask/_version.py' -versioneer.versionfile_build = 'leap/bitmask/_version.py' -versioneer.tag_prefix = '' # tags are like 1.2.0 -versioneer.parentdir_prefix = 'leap.bitmask-' - # The following import avoids the premature unloading of the `util` submodule # when running tests, which would cause an error when nose finishes tests and @@ -53,6 +42,20 @@ versioneer.parentdir_prefix = 'leap.bitmask-' from multiprocessing import util assert(util) + +try: + from setuptools import setup, find_packages +except ImportError: + from pkg import distribute_setup + distribute_setup.use_setuptools() + from setuptools import setup, find_packages + +if not sys.version_info[0] == 2: + print("[ERROR] Sorry, Python 3 is not supported (yet). " + "Try running with python2: python2 setup.py ...") + exit() + + setup_root = os.path.dirname(__file__) sys.path.insert(0, os.path.join(setup_root, "src")) @@ -78,7 +81,7 @@ DOWNLOAD_BASE = ('https://github.com/leapcode/bitmask_client/' 'archive/%s.tar.gz') _versions = versioneer.get_versions() VERSION = _versions['version'] -VERSION_FULL = _versions['full'] +VERSION_REVISION = _versions['full-revisionid'] DOWNLOAD_URL = "" # get the short version for the download url @@ -87,11 +90,6 @@ if len(_version_short) > 0: VERSION_SHORT = _version_short[0] DOWNLOAD_URL = DOWNLOAD_BASE % VERSION_SHORT -cmdclass = versioneer.get_cmdclass() - - -from setuptools import Command - class freeze_debianver(Command): @@ -102,18 +100,19 @@ class freeze_debianver(Command): user_options = [] template = r""" # This file was generated by the `freeze_debianver` command in setup.py -# Using 'versioneer.py' (0.7+) from +# Using 'versioneer.py' (0.16) from # revision-control system data, or from the parent directory name of an # unpacked source archive. Distribution tarballs contain a pre-generated copy # of this file. version_version = '{version}' -version_full = '{version_full}' +full_revisionid = '{full_revisionid}' """ templatefun = r""" def get_versions(default={}, verbose=False): - return {'version': version_version, 'full': version_full} + return {'version': version_version, + 'full-revisionid': full_revisionid} """ def initialize_options(self): @@ -130,8 +129,9 @@ def get_versions(default={}, verbose=False): return subst_template = self.template.format( version=VERSION_SHORT, - version_full=VERSION_FULL) + self.templatefun - with open(versioneer.versionfile_source, 'w') as f: + full_revisionid=VERSION_REVISION) + self.templatefun + versioneer_cfg = versioneer.get_config_from_root('.') + with open(versioneer_cfg.versionfile_source, 'w') as f: f.write(subst_template) @@ -142,16 +142,16 @@ def freeze_pkg_ver(path, version_short, version_full): """ subst_template = freeze_debianver.template.format( version=version_short, - version_full=version_full) + freeze_debianver.templatefun + full_revisionid=version_full) + freeze_debianver.templatefun with open(path, 'w') as f: f.write(subst_template) - if sys.argv[:1] == '--sumo': IS_SUMO = True else: IS_SUMO = False +cmdclass = versioneer.get_cmdclass() cmdclass["freeze_debianver"] = freeze_debianver parsed_reqs = utils.parse_requirements() @@ -170,11 +170,6 @@ else: reqfiles=["pkg/requirements-leap.pip"]) -leap_launcher = 'bitmask=leap.bitmask.app:start_app' - -from setuptools.command.develop import develop as _develop - - def copy_reqs(path, withsrc=False): # add a copy of the processed requirements to the package _reqpath = ('leap', 'bitmask', 'util', 'reqs.txt') @@ -220,6 +215,7 @@ class cmd_binary_hash(Command): pass def run(self, *args): + # TODO check gnupg binary too. OPENVPN_BIN = os.environ.get('OPENVPN_BIN', None) BITMASK_ROOT = os.environ.get('BITMASK_ROOT', None) @@ -262,16 +258,15 @@ BITMASK_ROOT = "{bitmask}" cmdclass["hash_binaries"] = cmd_binary_hash -# next two classes need to augment the versioneer modified ones +# sdist class need to augment the versioneer modified ones -versioneer_build = cmdclass['build'] versioneer_sdist = cmdclass['sdist'] -class cmd_build(versioneer_build): +class cmd_build(_build): def run(self): - versioneer_build.run(self) + _build.run(self) copy_reqs(self.build_lib) @@ -371,10 +366,6 @@ class cmd_sdist(versioneer_sdist): pass -import shutil -import glob - - def _get_leap_versions(): versions = {} with open("pkg/leap_versions.txt") as vf: @@ -463,7 +454,6 @@ def copy_recursively(source_folder, destination_folder): cmdclass["build"] = cmd_build cmdclass["sdist"] = cmd_sdist -import platform _system = platform.system() IS_LINUX = _system == "Linux" IS_MAC = _system == "Darwin" @@ -487,6 +477,11 @@ if IS_LINUX: extra_options = {} +gui_launcher = 'bitmask=leap.bitmask.app:start_app' +bitmask_cli = 'bitmask_cli=leap.bitmask.cli.bitmask_cli:main' +bitmaskd = 'bitmaskd=leap.bitmask.core.launcher:run_bitmaskd' + + setup( name="leap.bitmask", package_dir={"": "src"}, @@ -522,7 +517,7 @@ setup( zip_safe=False, platforms="all", entry_points={ - 'console_scripts': [leap_launcher] + 'console_scripts': [gui_launcher, bitmask_cli, bitmaskd] }, **extra_options ) |