Exemple #1
0
from __future__ import print_function

import errno
import json
import os
import shutil
import stat
import tempfile

import file_locks
import pkg_resources
from buck_tool import BuckTool, MovableTemporaryFile, Resource


SERVER = Resource("buck_server")
BOOTSTRAPPER = Resource("bootstrapper_jar")
BUCKFILESYSTEM = Resource("buckfilesystem_jar")
BUCK_BINARY_HASH = Resource("buck_binary_hash")

PEX_ONLY_EXPORTED_RESOURCES = [Resource("external_executor_jar")]

MODULES_DIR = "buck-modules"
MODULES_RESOURCES_DIR = "buck-modules-resources"


class BuckPackage(BuckTool):
    def __init__(self, buck_project, buck_reporter):
        super(BuckPackage, self).__init__(buck_project, buck_reporter)
        self._resource_subdir = None
        self._lock_file = None
Exemple #2
0
import os
import json
import stat
import tempfile

import pkg_resources

from buck_tool import BuckTool, Resource

SERVER = Resource("buck_server")
BOOTSTRAPPER = Resource("bootstrapper_jar")


class BuckPackage(BuckTool):
    def __init__(self, buck_project):
        super(BuckPackage, self).__init__(buck_project)
        self._package_info = json.loads(
            pkg_resources.resource_string(__name__, 'buck_package_info'))

    def _get_buck_version_uid(self):
        return self._package_info['version']

    def _get_resource_dir(self):
        if self._use_buckd():
            tmp_dir = self._buck_project.create_buckd_tmp_dir()
        else:
            tmp_dir = self._tmp_dir
        return os.path.join(tmp_dir, 'resources')

    def _has_resource(self, resource):
        return pkg_resources.resource_exists(__name__, resource.name)
Exemple #3
0
import contextlib
import os
import json
import logging
import shutil
import stat
import sys
import tempfile
import textwrap

import pkg_resources
import file_locks

from buck_tool import BuckTool, Resource

SERVER = Resource("buck_server")
BOOTSTRAPPER = Resource("bootstrapper_jar")

PEX_ONLY_EXPORTED_RESOURCES = [
    Resource("external_executor_jar"),
]


@contextlib.contextmanager
def closable_named_temporary_file(*args, **kwargs):
    """
    Due to a bug in python (https://bugs.python.org/issue14243), we need to be able to close() the
    temporary file without deleting it.
    """
    fp = tempfile.NamedTemporaryFile(*args, delete=False, **kwargs)
    try: