當前位置: 首頁>>代碼示例>>Python>>正文


Python setup.py方法代碼示例

本文整理匯總了Python中distutils.core.setup.py方法的典型用法代碼示例。如果您正苦於以下問題:Python setup.py方法的具體用法?Python setup.py怎麽用?Python setup.py使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在distutils.core.setup的用法示例。


在下文中一共展示了setup.py方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run

# 需要導入模塊: from distutils.core import setup [as 別名]
# 或者: from distutils.core.setup import py [as 別名]
def run(self):
        result = install_lib.run(self)
        fullfname = os.path.join(self.install_dir, 'ivre', '__init__.py')
        tmpfname = "%s.tmp" % fullfname
        stat = os.stat(fullfname)
        os.rename(fullfname, tmpfname)
        with open(fullfname, 'w') as newf:
            with open(tmpfname) as oldf:
                for line in oldf:
                    if line.startswith('import '):
                        newf.write('VERSION = %r\n' % VERSION)
                        break
                    newf.write(line)
        os.chown(fullfname, stat.st_uid, stat.st_gid)
        os.chmod(fullfname, stat.st_mode)
        os.unlink(tmpfname)
        return result 
開發者ID:cea-sec,項目名稱:ivre,代碼行數:19,代碼來源:setup.py

示例2: test_debug_mode

# 需要導入模塊: from distutils.core import setup [as 別名]
# 或者: from distutils.core.setup import py [as 別名]
def test_debug_mode(self):
        # this covers the code called when DEBUG is set
        sys.argv = ['setup.py', '--name']
        with captured_stdout() as stdout:
            distutils.core.setup(name='bar')
        stdout.seek(0)
        self.assertEqual(stdout.read(), 'bar\n')

        distutils.core.DEBUG = True
        try:
            with captured_stdout() as stdout:
                distutils.core.setup(name='bar')
        finally:
            distutils.core.DEBUG = False
        stdout.seek(0)
        wanted = "options (after parsing config files):\n"
        self.assertEqual(stdout.readlines()[0], wanted) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:19,代碼來源:test_core.py

示例3: get_cmd

# 需要導入模塊: from distutils.core import setup [as 別名]
# 或者: from distutils.core.setup import py [as 別名]
def get_cmd(self, metadata=None):
        """Returns a cmd"""
        if metadata is None:
            metadata = {'name': 'fake', 'version': '1.0',
                        'url': 'xxx', 'author': 'xxx',
                        'author_email': 'xxx'}
        dist = Distribution(metadata)
        dist.script_name = 'setup.py'
        dist.packages = ['somecode']
        dist.include_package_data = True
        cmd = sdist(dist)
        cmd.dist_dir = 'dist'
        def _warn(*args):
            pass
        cmd.warn = _warn
        return dist, cmd 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:18,代碼來源:test_sdist.py

示例4: test_run_setup_uses_current_dir

# 需要導入模塊: from distutils.core import setup [as 別名]
# 或者: from distutils.core.setup import py [as 別名]
def test_run_setup_uses_current_dir(self):
        # This tests that the setup script is run with the current directory
        # as its own current directory; this was temporarily broken by a
        # previous patch when TESTFN did not use the current directory.
        sys.stdout = StringIO.StringIO()
        cwd = os.getcwd()

        # Create a directory and write the setup.py file there:
        os.mkdir(test.test_support.TESTFN)
        setup_py = os.path.join(test.test_support.TESTFN, "setup.py")
        distutils.core.run_setup(
            self.write_setup(setup_prints_cwd, path=setup_py))

        output = sys.stdout.getvalue()
        if output.endswith("\n"):
            output = output[:-1]
        self.assertEqual(cwd, output) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:19,代碼來源:test_core.py

示例5: get_lib_path

# 需要導入模塊: from distutils.core import setup [as 別名]
# 或者: from distutils.core.setup import py [as 別名]
def get_lib_path():
    """Get library path, name and version"""
    # We can not import `libinfo.py` in setup.py directly since __init__.py
    # Will be invoked which introduces dependences
    libinfo_py = os.path.join(CURRENT_DIR, './tvm/_ffi/libinfo.py')
    libinfo = {'__file__': libinfo_py}
    exec(compile(open(libinfo_py, "rb").read(), libinfo_py, 'exec'), libinfo, libinfo)
    version = libinfo['__version__']
    if not os.getenv('CONDA_BUILD'):
        lib_path = libinfo['find_lib_path']()
        libs = [lib_path[0]]
        if libs[0].find("runtime") == -1:
            for name in lib_path[1:]:
                if name.find("runtime") != -1:
                    libs.append(name)
                    break
    else:
        libs = None
    return libs, version 
開發者ID:mlperf,項目名稱:training_results_v0.6,代碼行數:21,代碼來源:setup.py

示例6: get_lib_path

# 需要導入模塊: from distutils.core import setup [as 別名]
# 或者: from distutils.core.setup import py [as 別名]
def get_lib_path():
    """Get library path, name and version"""
    # We can not import `libinfo.py` in setup.py directly since __init__.py
    # Will be invoked which introduces dependences
    CURRENT_DIR = os.path.dirname(__file__)
    libinfo_py = os.path.join(CURRENT_DIR, '../../python/tvm/_ffi/libinfo.py')
    libinfo = {'__file__': libinfo_py}
    exec(compile(open(libinfo_py, "rb").read(), libinfo_py, 'exec'), libinfo, libinfo)
    version = libinfo['__version__']
    if not os.getenv('CONDA_BUILD'):
        lib_path = libinfo['find_lib_path'](get_lib_names())
        libs = [lib_path[0]]
        if libs[0].find("runtime") == -1:
            for name in lib_path[1:]:
                if name.find("runtime") != -1:
                    libs.append(name)
                    break
    else:
        libs = None
    return libs, version 
開發者ID:mlperf,項目名稱:training_results_v0.6,代碼行數:22,代碼來源:setup.py

示例7: test_run_setup_uses_current_dir

# 需要導入模塊: from distutils.core import setup [as 別名]
# 或者: from distutils.core.setup import py [as 別名]
def test_run_setup_uses_current_dir(self):
        # This tests that the setup script is run with the current directory
        # as its own current directory; this was temporarily broken by a
        # previous patch when TESTFN did not use the current directory.
        sys.stdout = io.StringIO()
        cwd = os.getcwd()

        # Create a directory and write the setup.py file there:
        os.mkdir(test.support.TESTFN)
        setup_py = os.path.join(test.support.TESTFN, "setup.py")
        distutils.core.run_setup(
            self.write_setup(setup_prints_cwd, path=setup_py))

        output = sys.stdout.getvalue()
        if output.endswith("\n"):
            output = output[:-1]
        self.assertEqual(cwd, output) 
開發者ID:CedricGuillemet,項目名稱:Imogen,代碼行數:19,代碼來源:test_core.py

示例8: get_package_data_files

# 需要導入模塊: from distutils.core import setup [as 別名]
# 或者: from distutils.core.setup import py [as 別名]
def get_package_data_files(directory, exclude=[]):
    """
    Find data files recursibely.
    Original version from: https://stackoverflow.com/questions/27664504/how-to-add-package-data-recursively-in-python-setup-py
    :param directory: directory to search recursively
    :type directory: str
    :param exclude: list of absolute paths to ignore
    :type exclude: list of str
    :return: package data files to include
    :rtype: list of str
    """
    paths = []
    for (path, directories, filenames) in os.walk(directory):
        for filename in filenames:
            fp = os.path.abspath(os.path.join('..', path, filename))
            skip = False
            for v in exclude:
                if fp.startswith(v):
                    skip = True
            if not skip:
                paths.append(fp)
    return paths 
開發者ID:ywangd,項目名稱:stash,代碼行數:24,代碼來源:setup.py

示例9: get_stash_version

# 需要導入模塊: from distutils.core import setup [as 別名]
# 或者: from distutils.core.setup import py [as 別名]
def get_stash_version(corepath):
    """
    Find and return the current StaSh version.
    :param corepath: path to the 'core.py' file in the StaSh root directory
    :type corepath: str
    :return: the StaSh version defined in the corepath
    :rtype: str
    """
    with open(corepath, "r") as fin:
        for line in fin:
             if line.startswith("__version__"):
                 version = ast.literal_eval(line.split("=")[1].strip())
                 return version
    raise Exception("Could not find StaSh version in file '{f}'", f=corepath)


# before we start with the setup, we must be outside of the stash root path. 
開發者ID:ywangd,項目名稱:stash,代碼行數:19,代碼來源:setup.py

示例10: main

# 需要導入模塊: from distutils.core import setup [as 別名]
# 或者: from distutils.core.setup import py [as 別名]
def main () :
    
    if platform.architecture()[0] == "32bit":
        helper = 'helper32'
    else :
        helper = 'helper64'
        
    py2exe_options = dict(
        packages = [],
        optimize=2,
        compressed=True, # uncompressed may or may not have a faster startup
        bundle_files=3,
        dist_dir=helper,
        )
    
    setup(console=['eml2pst.py'],
          name = "EML2PST",
          version = "0.1",
          description = "A simple EML to PST conversion utility",
          options={"py2exe": py2exe_options},
        ) 
開發者ID:adb014,項目名稱:nsf2x,代碼行數:23,代碼來源:create_helper.py

示例11: discover_and_run_tests

# 需要導入模塊: from distutils.core import setup [as 別名]
# 或者: from distutils.core.setup import py [as 別名]
def discover_and_run_tests():
    import os
    import sys
    import unittest

    # get setup.py directory
    setup_file = sys.modules['__main__'].__file__
    setup_dir = os.path.abspath(os.path.dirname(setup_file))

    # use the default shared TestLoader instance
    test_loader = unittest.defaultTestLoader

    # use the basic test runner that outputs to sys.stderr
    test_runner = unittest.TextTestRunner()

    # automatically discover all tests
    # NOTE: only works for python 2.7 and later
    test_suite = test_loader.discover(setup_dir)

    # run the test suite
    result = test_runner.run(test_suite)
    if len(result.failures) + len(result.errors) > 0:
        exit(1) 
開發者ID:MartijnBraam,項目名稱:python-isc-dhcp-leases,代碼行數:25,代碼來源:setup.py

示例12: create_files

# 需要導入模塊: from distutils.core import setup [as 別名]
# 或者: from distutils.core.setup import py [as 別名]
def create_files(self):
        decor = '~' * len(self.shortname)
        with open(os.path.join(self.output_folder, self.shortname,
                               '__init__.py'), 'w') as f:
            f.write(FILE_HEADER_TEMPLATE % dict(
                module=self.shortname,
                moduledecor=decor,
                year=datetime.utcnow().year,
                name=self.author,
            ))
        with open(os.path.join(self.output_folder, 'setup.py'), 'w') as f:
            f.write(SETUP_PY_TEMPLATE % dict(
                name=self.name,
                namedecor='~' * len(self.name),
                urlname=quote(self.name),
                author=self.author,
                extname=self.shortname,
                email=self.email,
            )) 
開發者ID:BillBillBillBill,項目名稱:Tickeys-linux,代碼行數:21,代碼來源:make-kivyext.py

示例13: get_version

# 需要導入模塊: from distutils.core import setup [as 別名]
# 或者: from distutils.core.setup import py [as 別名]
def get_version(*file_paths):
    """Retrieves the version from django_json_widget/__init__.py"""
    filename = os.path.join(os.path.dirname(__file__), *file_paths)
    version_file = open(filename).read()
    version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
                              version_file, re.M)
    if version_match:
        return version_match.group(1)
    raise RuntimeError('Unable to find version string.')


# version = get_version("django_json_widget", "__init__.py") 
開發者ID:jmrivas86,項目名稱:django-json-widget,代碼行數:14,代碼來源:setup.py

示例14: is_package

# 需要導入模塊: from distutils.core import setup [as 別名]
# 或者: from distutils.core.setup import py [as 別名]
def is_package(path):
    return (os.path.isdir(path) and os.path.isfile(os.path.join(path, '__init__.py'))) 
開發者ID:bachiraoun,項目名稱:fullrmc,代碼行數:4,代碼來源:setup.py

示例15: get_version

# 需要導入模塊: from distutils.core import setup [as 別名]
# 或者: from distutils.core.setup import py [as 別名]
def get_version(package):
    """
    Return package version as listed in `__version__` in `init.py`.
    """
    init_py = open(os.path.join(package, '__init__.py')).read()
    return re.search("^__version__ = ['\"]([^'\"]+)['\"]",
                     init_py, re.MULTILINE).group(1) 
開發者ID:contentful,項目名稱:contentful.py,代碼行數:9,代碼來源:setup.py


注:本文中的distutils.core.setup.py方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。