本文整理汇总了Python中setuptools.package_index.PackageIndex类的典型用法代码示例。如果您正苦于以下问题:Python PackageIndex类的具体用法?Python PackageIndex怎么用?Python PackageIndex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PackageIndex类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, index_url=["http://pypi.python.org/simple"], hosts=("*",), *args, **kw):
self.index_urls = []
if type(index_url) is list:
BasePackageIndex.__init__(self, index_url[0], hosts, *args, **kw)
for url in index_url:
self.index_urls.append(url + "/"[: not url.endswith("/")])
else:
BasePackageIndex.__init__(self, index_url, hosts, *args, **kw)
self.index_urls.append(index_url)
开发者ID:cyplp,项目名称:collective.eggproxy,代码行数:10,代码来源:utils.py
示例2: fetch_requirement
def fetch_requirement(req, dest_dir, force_download):
from setuptools.package_index import PackageIndex # @Reimport
from pkg_resources import working_set # @Reimport # NOQA
i = PackageIndex()
if force_download:
[i.remove(i[req.key][0]) for _ in xrange(len(i[req.key]))]
d = i.download(req, dest_dir)
else:
d = i.fetch_distribution(req, dest_dir, force_scan=True)
d = getattr(d, 'location', d) if d else ''
return (d if d else working_set.resolve([req])[0].location)
开发者ID:agiledata,项目名称:pkglib,代码行数:11,代码来源:pypi.py
示例3: __init__
def __init__(self, location, index=False, verbose=False):
self.location = format_as_url(location)
self.index = index
if index:
self.environment = PackageIndex(index_url=self.location,
search_path=[])
else:
self.environment = PackageIndex(no_default_index=True)
self.environment.add_find_links([self.location])
self._projects = None
self.tmpdir = mkdtemp(prefix="ensetuptools-")
self.verbose = verbose
开发者ID:pombredanne,项目名称:ensetuptools,代码行数:12,代码来源:repository.py
示例4: fetch_distribution
def fetch_distribution(
self, requirement, tmpdir, force_scan=False, source=False, develop_ok=False, local_index=None
):
distribute_req = pkg_resources.Requirement.parse("distribute>=0.6.14")
if pkg_resources.get_distribution("distribute") in distribute_req:
# The local_index parameter is only in distribute>=0.6.14
dist = PackageIndex.fetch_distribution(
self, requirement, tmpdir, force_scan, source, develop_ok, local_index
)
else:
dist = PackageIndex.fetch_distribution(self, requirement, tmpdir, force_scan, source, develop_ok)
if dist:
log.info("Using %s from %s" % (dist, dist.location))
return dist
开发者ID:ih64,项目名称:XRB-phot,代码行数:14,代码来源:easier_install.py
示例5: _do_upgrade
def _do_upgrade(self, dist):
# Build up a requirement for a higher bugfix release but a lower minor
# release (so API compatibility is guaranteed)
next_version = _next_version(dist.parsed_version)
req = pkg_resources.Requirement.parse(
'{0}>{1},<{2}'.format(DIST_NAME, dist.version, next_version))
package_index = PackageIndex(index_url=self.index_url)
upgrade = package_index.obtain(req)
if upgrade is not None:
return self._do_download(version=upgrade.version)
开发者ID:spacetelescope,项目名称:drizzle,代码行数:14,代码来源:ah_bootstrap.py
示例6: _do_upgrade
def _do_upgrade(dist, index_url):
# Build up a requirement for a higher bugfix release but a lower minor
# release (so API compatibility is guaranteed)
# sketchy version parsing--maybe come up with something a bit more
# robust for this
major, minor = (int(part) for part in dist.parsed_version[:2])
next_minor = '.'.join([str(major), str(minor + 1), '0'])
req = pkg_resources.Requirement.parse(
'{0}>{1},<{2}'.format(DIST_NAME, dist.version, next_minor))
package_index = PackageIndex(index_url=index_url)
upgrade = package_index.obtain(req)
if upgrade is not None:
return _do_download(version=upgrade.version, index_url=index_url)
开发者ID:astrofrog,项目名称:sphere,代码行数:16,代码来源:ah_bootstrap.py
示例7: finalize_options
def finalize_options(self):
# log file activation and config
if self.debug == "y":
logging.basicConfig(
format="%(asctime)s%(levelname)s:%(message)s", level=logging.DEBUG, filename="wss_plugin.log"
)
# load and import config file
try:
sys.path.append(self.pathConfig)
self.configDict = __import__("config_file").config_info
logging.info("Loading config_file was successful")
except Exception as err:
sys.exit("Can't import the config file." + err.message)
# load proxy setting if exist
if "proxy" in self.configDict:
self.proxySetting = self.configDict["proxy"]
if "index_url" in self.configDict:
self.pkgIndex = PackageIndex(index_url=self.configDict["index_url"])
self.projectCoordinates = Coordinates.create_project_coordinates(self.distribution)
self.userEnvironment = pk_res.Environment(get_python_lib(), platform=None, python=None)
distribution_specification = self.distribution.get_name() + "==" + self.distribution.get_version()
distribution_requirement = pk_res.Requirement.parse(distribution_specification)
# resolve all dependencies
try:
self.distDepend = pk_res.working_set.resolve([distribution_requirement], env=self.userEnvironment)
self.distDepend.pop(0)
logging.info("Finished resolving dependencies")
except Exception as err:
print "distribution was not found on this system, and is required by this application", err.message
开发者ID:pombredanne,项目名称:python-plugin-1,代码行数:33,代码来源:WssPythonPlugin.py
示例8: handle_label
def handle_label(self, label, **options):
with tempdir() as tmp:
self.pypi = PackageIndex(options["index"])
path = self.pypi.download(label, tmp)
if path:
self._save_package(path, **options)
else:
print "Could not add %s. Not found." % label
开发者ID:saxix,项目名称:pyppi,代码行数:8,代码来源:ppadd.py
示例9: initialize_options
def initialize_options(self):
self.debug = None
self.proxySetting = None
self.service = None
self.configDict = None
self.pathConfig = None
self.token = None
self.userEnvironment = None
self.distDepend = None
self.pkgIndex = PackageIndex()
self.dependencyList = []
self.projectCoordinates = None
self.tmpdir = tempfile.mkdtemp(prefix="wss_python_plugin-")
开发者ID:pombredanne,项目名称:python-plugin-1,代码行数:13,代码来源:WssPythonPlugin.py
示例10: initialize_options
def initialize_options(self):
self.bdist_base = None
self.dist_dir = None
self.format = None
self.keep_temp = False
self.name_prefix = None
self.package_index = PackageIndex()
self.requirements_mapping = None
self.selected_options = None
self.use_pypi_deps = False
self.use_wheel = False
self.with_py_prefix = False
self.initialize_manifest_options()
开发者ID:kxepal,项目名称:setuptools-pkg,代码行数:13,代码来源:bdist_pkg.py
示例11: HTMLRepository
class HTMLRepository(RemoteRepository):
"""\
A remote repository which easy_install can cope with.
"""
def __init__(self, location, index=False, verbose=False):
self.location = format_as_url(location)
self.index = index
if index:
self.environment = PackageIndex(index_url=self.location,
search_path=[])
else:
self.environment = PackageIndex(no_default_index=True)
self.environment.add_find_links([self.location])
self._projects = None
self.tmpdir = mkdtemp(prefix="ensetuptools-")
self.verbose = verbose
@property
def projects(self):
if self._projects == None:
self._projects = {}
info("Scanning repository at %s..." % self.location)
self.environment.prescan()
self.environment.scan_all()
for project in self.environment:
self._projects[project] = HTMLProject(self, project,
verbose=self.verbose)
for project in self.environment.package_pages:
if project not in self._projects:
self._projects[project] = HTMLProject(self, project,
verbose=self.verbose)
self._projects[project].scan_needed = True
return self._projects
def search(self, combiner='and', **kwargs):
if 'project' not in kwargs:
raise SearchError("EasyInstall-based remote repositories require"
" a 'project' search term.")
if isinstance(kwargs['project'], basestring):
return self.projects[kwargs['project']].match(combiner, **kwargs)
partial_match_names = set(project_name
for project_name in self.projects
if kwargs['project'].match(project_name))
matches = []
for project in partial_match_names:
matches += self.projects[project].search(combiner, **kwargs)
return matches
开发者ID:pombredanne,项目名称:ensetuptools,代码行数:48,代码来源:repository.py
示例12: finalize_options
def finalize_options(self):
# log file activation and config
if self.debug == 'y':
logging.basicConfig(format='%(asctime)s%(levelname)s:%(message)s', level=logging.DEBUG,
filename='wss_plugin.log')
# load and import config file
try:
sys.path.append(self.pathConfig)
if sys.version_info.major >= 3:
config_file_spec = importlib.util.spec_from_file_location('config_file', self.pathConfig)
config_file_module = importlib.util.module_from_spec(config_file_spec)
config_file_spec.loader.exec_module(config_file_module)
self.configDict = config_file_module.config_info
else:
self.configDict = imp.load_source('config_file', self.pathConfig).config_info
logging.info('Loading config_file was successful')
except Exception as err:
print("Can't import the config file.")
sys.exit(err)
# load proxy setting if exist
if 'proxy' in self.configDict:
self.proxySetting = self.configDict['proxy']
if 'index_url' in self.configDict:
self.pkgIndex = PackageIndex(index_url=self.configDict['index_url'])
self.projectCoordinates = Coordinates.create_project_coordinates(self.distribution)
self.userEnvironment = pk_res.Environment([get_python_lib()], platform=None, python=None)
distribution_specification = self.distribution.get_name() + "==" + self.distribution.get_version()
distribution_requirement = pk_res.Requirement.parse(distribution_specification)
# resolve all dependencies
try:
self.distDepend = pk_res.working_set.resolve([distribution_requirement], env=self.userEnvironment)
self.distDepend.pop(0)
logging.info("Finished resolving dependencies")
except Exception as err:
print("distribution was not found on this system, and is required by this application", err.message)
开发者ID:whitesource,项目名称:python-plugin,代码行数:39,代码来源:WssPythonPlugin.py
示例13: run
def run(self):
# Prepare for iterations.
pkgreqmap = reqmap()
for reqarg in self.reqarglist: pkgreqmap.append_arg(reqarg)
pkgreqmap.resolve_matchlist(self.logobj, self.options['--url'],
self.options['--skip-logged'])
pkgidx = PackageIndex(index_url = self.options['--url'])
show_sepline = False
# Main loop.
distlist = []
ok_packages = []
while len(pkgreqmap) > 0:
new_pkgreqmap = reqmap()
for idx, total, pkgreqobj in pkgreqmap.reqobj_seq():
pkgname = pkgreqobj.project_name
if pkgname in ok_packages: continue
ok_packages.append(pkgname)
reqstr = str(pkgreqobj)
if show_sepline: self.pkgsys.sepline()
else: show_sepline = True
self.pkgsys.info('======== %s: %d/%d ========' % \
(pkgname, idx + 1, total))
if self.options['--skip-broken']:
try: self.logobj.check_broken(pkgname)
except: continue
# Collect values into args step by step.
args = copy.copy(self.options)
args['self'] = self.arg0
self.pkgsys.begin('Downloading %s' % reqstr)
try:
dist = pkgidx.fetch_distribution(pkgreqobj,
self.options['--download-dir'],
source = True)
if dist is None:
raise RuntimeError, 'None'
except:
self.pkgsys.end(False)
self.logobj.in_except(pkgname,
'Download %s failed' % reqstr)
continue
else:
self.pkgsys.end(True)
self.pkgsys.begin('Unpacking %s' % dist.location)
try: smart_archive(args, dist, self.options['--unpack-dir'])
except:
self.pkgsys.end(False)
self.logobj.in_except(pkgname, 'Unpack %s failed' % reqstr)
continue
else:
self.pkgsys.end(True)
unpackpath = args['unpackpath']
config_secs = ['%s-%s' % (dist.project_name, dist.version),
dist.project_name]
for secname in config_secs:
for name, value in config.items(secname):
if name not in args: args[name] = value
if not 'patches' in args: args['patches'] = []
else: args['patches'] = args['patches'].split()
# Apply patches.
for patch in config.patches(config_secs):
self.pkgsys.begin('Applying %s' % os.path.basename(patch))
os.system('(cd %s; patch -p0 < %s) > /dev/null' % \
(unpackpath, patch))
self.pkgsys.end(True)
if os.path.isfile(os.path.join(unpackpath, 'fixsetup.py')):
os.system('(cd %s; python fixsetup.py)' % unpackpath)
self.pkgsys.begin('Get package args')
try: get_package_args(args, dist)
except:
self.pkgsys.end(False)
self.logobj.in_except(pkgname, 'Get package args failed')
continue
else:
self.pkgsys.end(True)
self.pkgsys.begin('Setup args')
try: self.pkgsys.setup_args(args)
except:
self.pkgsys.end(False)
self.logobj.in_except(pkgname, 'pkgsys.setup_args failed')
continue
else:
self.pkgsys.end(True)
self.pkgsys.begin('Writing %s' % args['output'])
try:
ensure_dir(os.path.dirname(args['output']))
#.........这里部分代码省略.........
开发者ID:schoolee,项目名称:pypi2pkgsys,代码行数:101,代码来源:pypi2packages.py
示例14: Command
class Command(LabelCommand):
option_list = LabelCommand.option_list + (
make_option("-o", "--owner", help="add packages as OWNER",
metavar="OWNER", default=None),
)
help = """Add one or more packages to the repository. Each argument can
be a package name or a URL to an archive or egg. Package names honour
the same rules as easy_install with regard to indicating versions etc.
If a version of the package exists, but is older than what we want to install,
the owner remains the same.
For new packages there needs to be an owner. If the --owner option is present
we use that value. If not, we try to match the maintainer of the package, form
the metadata, with a user in out database, based on the If it's a new package
and the maintainer emailmatches someone in our user list, we use that. If not,
the package can not be
added"""
def __init__(self, *args, **kwargs):
self.pypi = PackageIndex()
LabelCommand.__init__(self, *args, **kwargs)
def handle_label(self, label, **options):
with tempdir() as tmp:
path = self.pypi.download(label, tmp)
if path:
self._save_package(path, options["owner"])
else:
print "Could not add %s. Not found." % label
def _save_package(self, path, ownerid):
meta = self._get_meta(path)
try:
# can't use get_or_create as that demands there be an owner
package = Package.objects.get(name=meta.name)
isnewpackage = False
except Package.DoesNotExist:
package = Package(name=meta.name)
isnewpackage = True
release = package.get_release(meta.version)
if not isnewpackage and release and release.version == meta.version:
print "%s-%s already added" % (meta.name, meta.version)
return
# algorithm as follows: If owner is given, try to grab user with that
# username from db. If doesn't exist, bail. If no owner set look at
# mail address from metadata and try to get that user. If it exists
# use it. If not, bail.
owner = None
if ownerid:
try:
if "@" in ownerid:
owner = User.objects.get(email=ownerid)
else:
owner = User.objects.get(username=ownerid)
except User.DoesNotExist:
pass
else:
try:
owner = User.objects.get(email=meta.author_email)
except User.DoesNotExist:
pass
if not owner:
print "No owner defined. Use --owner to force one"
return
# at this point we have metadata and an owner, can safely add it.
package.save()
package.owners.add(owner)
package.maintainers.add(owner)
for classifier in meta.classifiers:
package.classifiers.add(
Classifier.objects.get_or_create(name=classifier)[0])
release = Release()
release.version = meta.version
release.package = package
release.metadata_version = meta.metadata_version
package_info = MultiValueDict()
package_info.update(meta.__dict__)
release.package_info = package_info
release.save()
file = File(open(path, "rb"))
if isinstance(meta, pkginfo.SDist):
dist = 'sdist'
elif meta.filename.endswith('.rmp') or meta.filename.endswith('.srmp'):
dist = 'bdist_rpm'
elif meta.filename.endswith('.exe'):
dist = 'bdist_wininst'
elif meta.filename.endswith('.egg'):
dist = 'bdist_egg'
elif meta.filename.endswith('.dmg'):
#.........这里部分代码省略.........
开发者ID:Affirm,项目名称:djangopypi2,代码行数:101,代码来源:ppadd.py
示例15: __init__
def __init__(self, *args, **kwargs):
PackageIndex.__init__(self, *args, **kwargs)
self.to_scan = dists
开发者ID:cdeil,项目名称:astropy-helpers,代码行数:3,代码来源:test_ah_bootstrap.py
示例16: Command
class Command(LabelCommand):
option_list = LabelCommand.option_list + (
make_option("-o", "--owner", help="add packages as OWNER",
metavar="OWNER", default=None),
)
help = """Add one or more packages to the repository. Each argument can
be a package name or a URL to an archive or egg. Package names honour
the same rules as easy_install with regard to indicating versions etc.
If a version of the package exists, but is older than what we want to install,
the owner remains the same.
For new packages there needs to be an owner. If the --owner option is present
we use that value. If not, we try to match the maintainer of the package, form
the metadata, with a user in out database, based on the If it's a new package
and the maintainer emailmatches someone in our user list, we use that. If not,
the package can not be
added"""
def __init__(self, *args, **kwargs):
self.pypi = PackageIndex()
LabelCommand.__init__(self, *args, **kwargs)
def handle_label(self, label, **options):
with tempdir() as tmp:
reqs = pkg_resources.parse_requirements(label)
for req in reqs:
try:
package = self.pypi.fetch_distribution(req, tmp, source=True)
except Exception as err:
print "Could not add %s: %s." % (req, err)
else:
self._save_package(package.location, options["owner"])
def _save_package(self, path, ownerid):
meta = self._get_meta(path)
try:
# can't use get_or_create as that demands there be an owner
package = Package.objects.get(name=meta.name)
isnewpackage = False
except Package.DoesNotExist:
package = Package(name=meta.name)
isnewpackage = True
release = package.get_release(meta.version)
if not isnewpackage and release and release.version == meta.version:
print "%s-%s already added" % (meta.name, meta.version)
return
# algorithm as follows: If owner is given, try to grab user with that
# username from db. If doesn't exist, bail. If no owner set look at
# mail address from metadata and try to get that user. If it exists
# use it. If not, bail.
owner = None
if ownerid:
try:
if "@" in ownerid:
owner = User.objects.get(email=ownerid)
else:
owner = User.objects.get(username=ownerid)
except User.DoesNotExist:
pass
else:
try:
owner = User.objects.get(email=meta.author_email)
except User.DoesNotExist:
pass
if not owner:
print "No owner defined. Use --owner to force one"
return
# at this point we have metadata and an owner, can safely add it.
package.owner = owner
# Some packages don't have proper licence, seems to be a problem
# with setup.py upload. Use "UNKNOWN"
package.license = meta.license or "Unknown"
package.metadata_version = meta.metadata_version
package.author = meta.author
package.home_page = meta.home_page
package.download_url = meta.download_url
package.summary = meta.summary
package.description = meta.description
package.author_email = meta.author_email
package.save()
# TODO: Do I need add classifieres objects???
# for classifier in meta.classifiers:
# package.classifiers.add(
# Classifier.objects.get_or_create(name=classifier)[0])
release = Release()
release.version = meta.version
release.package = package
release.package_info = self._get_pkg_info(meta)
# Classifiers is processed separatily since it is a list a must be
# properly set son getlist returns the right result
#.........这里部分代码省略.........
开发者ID:rafaduran,项目名称:djangopypi,代码行数:101,代码来源:ppadd.py
示例17: process_filename
def process_filename(self, fn, nested=False):
PackageIndex.process_filename(self, fn, nested)
dist = distro_from_setup_cfg(fn)
if dist:
self.add(dist)
开发者ID:ih64,项目名称:XRB-phot,代码行数:5,代码来源:easier_install.py
示例18: __init__
def __init__(self, *a, **k):
PackageIndex.__init__(self, *a, **k)
self.urls = set()
开发者ID:Malex,项目名称:pyg,代码行数:3,代码来源:web.py
示例19: load_index_servers
def load_index_servers(self):
index_servers = []
for index in IndexSite.objects.all():
pypi = PackageIndex(index_url=index.url)
pypi.scan_all()
self.index_servers.append(pypi)
开发者ID:olarcheveque,项目名称:django-vu,代码行数:6,代码来源:vu.py
示例20: __init__
def __init__(self, index_url):
PackageIndex.__init__(self, index_url)
self.platform = None
# It is necessary blow away local caches in order to not pick up stuff in site-packages.
self._distmap = {}
self._cache = {}
开发者ID:adamsxu,项目名称:commons,代码行数:6,代码来源:reqfetcher.py
注:本文中的setuptools.package_index.PackageIndex类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论