Exemple #1
0
def _install_grpcio_tools_and_generate_proto_files():
    install_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                '..', '.eggs', 'grpcio-wheels')
    build_path = install_path + '-build'
    if os.path.exists(build_path):
        shutil.rmtree(build_path)
    logging.warning('Installing grpcio-tools into %s', install_path)
    try:
        start = time.time()
        subprocess.check_call([
            sys.executable, '-m', 'pip', 'install', '--prefix', install_path,
            '--build', build_path, '--upgrade', GRPC_TOOLS, "-I"
        ])
        from distutils.dist import Distribution
        install_obj = Distribution().get_command_obj('install', create=True)
        install_obj.prefix = install_path
        install_obj.finalize_options()
        logging.warning('Installing grpcio-tools took %0.2f seconds.',
                        time.time() - start)
    finally:
        sys.stderr.flush()
        shutil.rmtree(build_path, ignore_errors=True)
    sys.path.append(install_obj.install_purelib)
    if install_obj.install_purelib != install_obj.install_platlib:
        sys.path.append(install_obj.install_platlib)
    try:
        generate_proto_files()
    finally:
        sys.stderr.flush()
Exemple #2
0
def get_site_packages_paths(prefix):
    install_obj = Distribution().get_command_obj('install', create=True)
    install_obj.prefix = prefix
    install_obj.finalize_options()
    installed_dir = [install_obj.install_purelib]
    if install_obj.install_purelib != install_obj.install_platlib:
        installed_dir.append(install_obj.install_platlib)
    return installed_dir
Exemple #3
0
    def test_finalize_options(self):
        attrs = {'keywords': 'one,two', 'platforms': 'one,two'}

        dist = Distribution(attrs=attrs)
        dist.finalize_options()

        # finalize_option splits platforms and keywords
        self.assertEqual(dist.metadata.platforms, ['one', 'two'])
        self.assertEqual(dist.metadata.keywords, ['one', 'two'])
Exemple #4
0
    def test_finalize_options(self):
        attrs = {"keywords": "one,two", "platforms": "one,two"}

        dist = Distribution(attrs=attrs)
        dist.finalize_options()

        # finalize_option splits platforms and keywords
        self.assertEqual(dist.metadata.platforms, ["one", "two"])
        self.assertEqual(dist.metadata.keywords, ["one", "two"])
Exemple #5
0
    def test_finalize_options(self):
        attrs = {'keywords': 'one,two',
                 'platforms': 'one,two'}

        dist = Distribution(attrs=attrs)
        dist.finalize_options()

        # finalize_option splits platforms and keywords
        self.assertEqual(dist.metadata.platforms, ['one', 'two'])
        self.assertEqual(dist.metadata.keywords, ['one', 'two'])
Exemple #6
0
 def check_installed_files(self, prefix_dir, package_list):
     from distutils.dist import Distribution
     install_obj = Distribution().get_command_obj('install', create=True)
     install_obj.prefix = prefix_dir
     install_obj.finalize_options()
     installed_dir = [install_obj.install_purelib]
     if install_obj.install_purelib != install_obj.install_platlib:
         installed_dir.append(install_obj.install_platlib)
     for package_name in package_list:
         self.assertTrue(
             any([
                 os.path.exists(os.path.join(package_dir, package_name))
                 for package_dir in installed_dir
             ]))
Exemple #7
0
def _install_grpcio_tools_and_generate_proto_files(force, output_dir):
    install_path = os.path.join(PYFLINK_ROOT_PATH, '..', '.eggs',
                                'grpcio-wheels')
    build_path = install_path + '-build'
    if os.path.exists(build_path):
        shutil.rmtree(build_path)
    logging.warning('Installing grpcio-tools into %s', install_path)
    try:
        start = time.time()
        # since '--prefix' option is only supported for pip 8.0+, so here we fallback to
        # use '--install-option' when the pip version is lower than 8.0.0.
        pip_version = pkg_resources.get_distribution("pip").version
        from pkg_resources import parse_version
        if parse_version(pip_version) >= parse_version('8.0.0'):
            subprocess.check_call([
                sys.executable, '-m', 'pip', 'install', '--prefix',
                install_path, '--build', build_path, '--upgrade', GRPC_TOOLS,
                "-I"
            ])
        else:
            subprocess.check_call([
                sys.executable, '-m', 'pip', 'install', '--install-option',
                '--prefix=' + install_path, '--build', build_path, '--upgrade',
                GRPC_TOOLS, "-I"
            ])
        from distutils.dist import Distribution
        install_obj = Distribution().get_command_obj('install', create=True)
        install_obj.prefix = install_path
        install_obj.finalize_options()
        logging.warning('Installing grpcio-tools took %0.2f seconds.',
                        time.time() - start)
    finally:
        sys.stderr.flush()
        shutil.rmtree(build_path, ignore_errors=True)
    sys.path.append(install_obj.install_purelib)
    pkg_resources.working_set.add_entry(install_obj.install_purelib)
    if install_obj.install_purelib != install_obj.install_platlib:
        sys.path.append(install_obj.install_platlib)
        pkg_resources.working_set.add_entry(install_obj.install_platlib)
    try:
        generate_proto_files(force, output_dir)
    finally:
        sys.stderr.flush()
Exemple #8
0
 def finalize_options(self):
     self.source_dir = distutils.util.convert_path(self.source_dir)
     Distribution.finalize_options(self)
Exemple #9
0
 def finalize_options(self):
     # Establish the default version number
     self.metadata.version = '0.00'
     Distribution.finalize_options(self)
Exemple #10
0
# If the program's directory has a plover.cfg file then run in "portable mode",
# i.e. store all data in the same directory. This allows keeping all Plover
# files in a portable drive.
if os.path.isfile(os.path.join(PROGRAM_DIR, 'plover.cfg')):
    CONFIG_DIR = PROGRAM_DIR
else:
    CONFIG_DIR = appdirs.user_data_dir('plover', 'plover')

# Setup plugins directory.
if sys.platform.startswith('darwin'):
    PLUGINS_PLATFORM = 'mac'
elif sys.platform.startswith('linux'):
    PLUGINS_PLATFORM = 'linux'
elif sys.platform.startswith('win'):
    PLUGINS_PLATFORM = 'win'
else:
    PLUGINS_PLATFORM = None
if PLUGINS_PLATFORM is None:
    PLUGINS_DIR = None
else:
    dist = Distribution().get_command_obj('install', create=True)
    dist.prefix = os.path.join(CONFIG_DIR, 'plugins', PLUGINS_PLATFORM)
    dist.finalize_options()
    PLUGINS_DIR = dist.install_lib
    sys.path.insert(0, PLUGINS_DIR)

# This need to be imported after patching sys.path.
import pkg_resources

ASSETS_DIR = pkg_resources.resource_filename('plover', 'assets')
Exemple #11
0
# files in a portable drive.
if os.path.isfile(os.path.join(PROGRAM_DIR, 'plover.cfg')):
    CONFIG_DIR = PROGRAM_DIR
else:
    CONFIG_DIR = appdirs.user_data_dir('plover', 'plover')

# Setup plugins directory.
if sys.platform.startswith('darwin'):
    PLUGINS_PLATFORM = 'mac'
elif sys.platform.startswith('linux'):
    PLUGINS_PLATFORM = 'linux'
elif sys.platform.startswith('win'):
    PLUGINS_PLATFORM = 'win'
else:
    PLUGINS_PLATFORM = None
if PLUGINS_PLATFORM is None:
    PLUGINS_BASE = None
    PLUGINS_DIR = None
else:
    PLUGINS_BASE = os.path.join(CONFIG_DIR, 'plugins', PLUGINS_PLATFORM)
    dist = Distribution().get_command_obj('install', create=True)
    dist.prefix = PLUGINS_BASE
    dist.finalize_options()
    PLUGINS_DIR = dist.install_lib
    sys.path.insert(0, PLUGINS_DIR)

# This need to be imported after patching sys.path.
import pkg_resources

ASSETS_DIR = pkg_resources.resource_filename('plover', 'assets')