我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用setuptools.depends.Require()。
def setUp(self): self.req = Require('Distutils','1.0.3','distutils') self.dist = makeSetup( features={ 'foo': Feature("foo",standard=True,require_features=['baz',self.req]), 'bar': Feature("bar", standard=True, packages=['pkg.bar'], py_modules=['bar_et'], remove=['bar.ext'], ), 'baz': Feature( "baz", optional=False, packages=['pkg.baz'], scripts = ['scripts/baz_it'], libraries=[('libfoo','foo/foofoo.c')] ), 'dwim': Feature("DWIM", available=False, remove='bazish'), }, script_args=['--without-bar', 'install'], packages = ['pkg.bar', 'pkg.foo'], py_modules = ['bar_et', 'bazish'], ext_modules = [Extension('bar.ext',['bar.c'])] )
def setup_method(self, method): self.req = Require('Distutils','1.0.3','distutils') self.dist = makeSetup( features={ 'foo': Feature("foo",standard=True,require_features=['baz',self.req]), 'bar': Feature("bar", standard=True, packages=['pkg.bar'], py_modules=['bar_et'], remove=['bar.ext'], ), 'baz': Feature( "baz", optional=False, packages=['pkg.baz'], scripts = ['scripts/baz_it'], libraries=[('libfoo','foo/foofoo.c')] ), 'dwim': Feature("DWIM", available=False, remove='bazish'), }, script_args=['--without-bar', 'install'], packages = ['pkg.bar', 'pkg.foo'], py_modules = ['bar_et', 'bazish'], ext_modules = [Extension('bar.ext',['bar.c'])] )
def setup_method(self, method): self.req = Require('Distutils', '1.0.3', 'distutils') self.dist = makeSetup( features={ 'foo': Feature("foo", standard=True, require_features=['baz', self.req]), 'bar': Feature("bar", standard=True, packages=['pkg.bar'], py_modules=['bar_et'], remove=['bar.ext'], ), 'baz': Feature( "baz", optional=False, packages=['pkg.baz'], scripts=['scripts/baz_it'], libraries=[('libfoo', 'foo/foofoo.c')] ), 'dwim': Feature("DWIM", available=False, remove='bazish'), }, script_args=['--without-bar', 'install'], packages=['pkg.bar', 'pkg.foo'], py_modules=['bar_et', 'bazish'], ext_modules=[Extension('bar.ext', ['bar.c'])] )
def __init__( self, description, standard=False, available=True, optional=True, require_features=(), remove=(), **extras): self.warn_deprecated() self.description = description self.standard = standard self.available = available self.optional = optional if isinstance(require_features, (str, Require)): require_features = require_features, self.require_features = [ r for r in require_features if isinstance(r, str) ] er = [r for r in require_features if not isinstance(r, str)] if er: extras['require_features'] = er if isinstance(remove, str): remove = remove, self.remove = remove self.extras = extras if not remove and not require_features and not extras: raise DistutilsSetupError( "Feature %s: must define 'require_features', 'remove', or " "at least one of 'packages', 'py_modules', etc." )
def __init__(self, description, standard=False, available=True, optional=True, require_features=(), remove=(), **extras): self.warn_deprecated() self.description = description self.standard = standard self.available = available self.optional = optional if isinstance(require_features,(str,Require)): require_features = require_features, self.require_features = [ r for r in require_features if isinstance(r,str) ] er = [r for r in require_features if not isinstance(r,str)] if er: extras['require_features'] = er if isinstance(remove,str): remove = remove, self.remove = remove self.extras = extras if not remove and not require_features and not extras: raise DistutilsSetupError( "Feature %s: must define 'require_features', 'remove', or at least one" " of 'packages', 'py_modules', etc." )
def testRequire(self): if not hasattr(dep, 'extract_constant'): # skip on non-bytecode platformsh return req = Require('Email','1.0.3','email') self.assertEqual(req.name, 'Email') self.assertEqual(req.module, 'email') self.assertEqual(req.requested_version, '1.0.3') self.assertEqual(req.attribute, '__version__') self.assertEqual(req.full_name(), 'Email-1.0.3') from email import __version__ self.assertEqual(req.get_version(), __version__) self.assertTrue(req.version_ok('1.0.9')) self.assertTrue(not req.version_ok('0.9.1')) self.assertTrue(not req.version_ok('unknown')) self.assertTrue(req.is_present()) self.assertTrue(req.is_current()) req = Require('Email 3000','03000','email',format=LooseVersion) self.assertTrue(req.is_present()) self.assertTrue(not req.is_current()) self.assertTrue(not req.version_ok('unknown')) req = Require('Do-what-I-mean','1.0','d-w-i-m') self.assertTrue(not req.is_present()) self.assertTrue(not req.is_current()) req = Require('Tests', None, 'tests', homepage="http://example.com") self.assertEqual(req.format, None) self.assertEqual(req.attribute, None) self.assertEqual(req.requested_version, None) self.assertEqual(req.full_name(), 'Tests') self.assertEqual(req.homepage, 'http://example.com') paths = [os.path.dirname(p) for p in __path__] self.assertTrue(req.is_present(paths)) self.assertTrue(req.is_current(paths))
def __init__(self, description, standard=False, available=True, optional=True, require_features=(), remove=(), **extras): self.warn_deprecated() self.description = description self.standard = standard self.available = available self.optional = optional if isinstance(require_features, (str, Require)): require_features = require_features, self.require_features = [ r for r in require_features if isinstance(r, str) ] er = [r for r in require_features if not isinstance(r, str)] if er: extras['require_features'] = er if isinstance(remove, str): remove = remove, self.remove = remove self.extras = extras if not remove and not require_features and not extras: raise DistutilsSetupError( "Feature %s: must define 'require_features', 'remove', or at least one" " of 'packages', 'py_modules', etc." )