Python pkg_resources.Distribution() Examples
The following are 30
code examples of pkg_resources.Distribution().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pkg_resources
, or try the search function
.
Example #1
Source File: bdist_egg.py From ironpython2 with Apache License 2.0 | 6 votes |
def finalize_options(self): ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info") self.egg_info = ei_cmd.egg_info if self.bdist_dir is None: bdist_base = self.get_finalized_command('bdist').bdist_base self.bdist_dir = os.path.join(bdist_base, 'egg') if self.plat_name is None: self.plat_name = get_build_platform() self.set_undefined_options('bdist', ('dist_dir', 'dist_dir')) if self.egg_output is None: # Compute filename of the output egg basename = Distribution( None, None, ei_cmd.egg_name, ei_cmd.egg_version, get_python_version(), self.distribution.has_ext_modules() and self.plat_name ).egg_name() self.egg_output = os.path.join(self.dist_dir, basename + '.egg')
Example #2
Source File: install_scripts.py From oss-ftp with MIT License | 6 votes |
def run(self): from setuptools.command.easy_install import get_script_args from setuptools.command.easy_install import sys_executable self.run_command("egg_info") if self.distribution.scripts: orig.install_scripts.run(self) # run first to set up self.outfiles else: self.outfiles = [] if self.no_ep: # don't install entry point scripts into .egg file! return ei_cmd = self.get_finalized_command("egg_info") dist = Distribution( ei_cmd.egg_base, PathMetadata(ei_cmd.egg_base, ei_cmd.egg_info), ei_cmd.egg_name, ei_cmd.egg_version, ) bs_cmd = self.get_finalized_command('build_scripts') executable = getattr(bs_cmd, 'executable', sys_executable) is_wininst = getattr( self.get_finalized_command("bdist_wininst"), '_is_running', False ) for args in get_script_args(dist, executable, is_wininst): self.write_script(*args)
Example #3
Source File: test_dist.py From calmjs with GNU General Public License v2.0 | 6 votes |
def test_get_dist_package_decoding_error(self): # Quiet stdout from distutils logs stub_stdouts(self) # trailing comma package_json = '{"dependencies": {"left-pad": "~1.1.1"},}' # bad data could be created by a competiting package. mock_provider = MockProvider({ self.pkgname: package_json, }) mock_dist = pkg_resources.Distribution( metadata=mock_provider, project_name='dummydist', version='0.0.0') results = calmjs_dist.read_dist_egginfo_json(mock_dist) # Should still not fail. self.assertIsNone(results)
Example #4
Source File: bdist_egg.py From Mastering-Elasticsearch-7.0 with MIT License | 6 votes |
def finalize_options(self): ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info") self.egg_info = ei_cmd.egg_info if self.bdist_dir is None: bdist_base = self.get_finalized_command('bdist').bdist_base self.bdist_dir = os.path.join(bdist_base, 'egg') if self.plat_name is None: self.plat_name = get_build_platform() self.set_undefined_options('bdist', ('dist_dir', 'dist_dir')) if self.egg_output is None: # Compute filename of the output egg basename = Distribution( None, None, ei_cmd.egg_name, ei_cmd.egg_version, get_python_version(), self.distribution.has_ext_modules() and self.plat_name ).egg_name() self.egg_output = os.path.join(self.dist_dir, basename + '.egg')
Example #5
Source File: bdist_egg.py From anpr with Creative Commons Attribution 4.0 International | 6 votes |
def finalize_options(self): ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info") self.egg_info = ei_cmd.egg_info if self.bdist_dir is None: bdist_base = self.get_finalized_command('bdist').bdist_base self.bdist_dir = os.path.join(bdist_base, 'egg') if self.plat_name is None: self.plat_name = get_build_platform() self.set_undefined_options('bdist', ('dist_dir', 'dist_dir')) if self.egg_output is None: # Compute filename of the output egg basename = Distribution( None, None, ei_cmd.egg_name, ei_cmd.egg_version, get_python_version(), self.distribution.has_ext_modules() and self.plat_name ).egg_name() self.egg_output = os.path.join(self.dist_dir, basename + '.egg')
Example #6
Source File: test_cli.py From calmjs with GNU General Public License v2.0 | 6 votes |
def test_pkg_manager_view_extras_requires(self): working_set = self.setup_requirements_json() working_set.add(pkg_resources.Distribution( metadata=MockProvider({ 'requires.txt': '[dev]\ncalmpy.pip', }), project_name='site', version='0.0.0', )) driver = cli.PackageManagerDriver( pkg_manager_bin='mgr', pkgdef_filename='requirements.json', dep_keys=('require',), ) result = driver.pkg_manager_view('site') self.assertEqual(result, { "require": {}, "name": "site", }) result = driver.pkg_manager_view('site[dev]') self.assertEqual(result, { "require": {"setuptools": "25.1.6"}, # should be "site[dev]", but npm fails on that. "name": "site", })
Example #7
Source File: test_cli.py From calmjs with GNU General Public License v2.0 | 6 votes |
def test_pkg_manager_view_requires(self): working_set = self.setup_requirements_json() working_set.add(pkg_resources.Distribution( metadata=MockProvider({ 'requires.txt': 'calmpy.pip', }), project_name='site', version='0.0.0', )) driver = cli.PackageManagerDriver( pkg_manager_bin='mgr', pkgdef_filename='requirements.json', dep_keys=('require',), ) result = driver.pkg_manager_view('site') self.assertEqual(result, { "require": {"setuptools": "25.1.6"}, "name": "site", }) # try explicit result = driver.pkg_manager_view('site', explicit=True) self.assertEqual(result, { "require": {}, "name": "site", })
Example #8
Source File: test_base.py From calmjs with GNU General Public License v2.0 | 6 votes |
def test_simple_record(self): working_set = mocks.WorkingSet({__name__: [ 'dummy/whatever/module.js = module', 'dummy/whatever/module-slim.js = module', ]}, dist=Distribution(project_name='calmjs.testing')) registry = base.BaseExternalModuleRegistry( __name__, _working_set=working_set) self.assertEqual(len(registry.raw_entry_points), 2) self.assertEqual(registry.get_record('module'), { 'dummy/whatever/module.js', 'dummy/whatever/module-slim.js', }) self.assertEqual(list(registry.iter_records()), [('module', { 'dummy/whatever/module.js', 'dummy/whatever/module-slim.js', })]) self.assertEqual(registry.get_records_for_package('calmjs.testing'), [ 'dummy/whatever/module.js', 'dummy/whatever/module-slim.js', ])
Example #9
Source File: bdist_egg.py From oss-ftp with MIT License | 6 votes |
def finalize_options(self): ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info") self.egg_info = ei_cmd.egg_info if self.bdist_dir is None: bdist_base = self.get_finalized_command('bdist').bdist_base self.bdist_dir = os.path.join(bdist_base, 'egg') if self.plat_name is None: self.plat_name = get_build_platform() self.set_undefined_options('bdist', ('dist_dir', 'dist_dir')) if self.egg_output is None: # Compute filename of the output egg basename = Distribution( None, None, ei_cmd.egg_name, ei_cmd.egg_version, get_python_version(), self.distribution.has_ext_modules() and self.plat_name ).egg_name() self.egg_output = os.path.join(self.dist_dir, basename + '.egg')
Example #10
Source File: test_dist.py From calmjs with GNU General Public License v2.0 | 6 votes |
def test_build_calmjs_artifacts_standard(self): dist = distutils_dist.Distribution() build_cmd = dist.get_command_obj('build') original_subcmds = list(build_cmd.sub_commands) calmjs_dist.build_calmjs_artifacts(dist, 'build_artifact', False) self.assertEqual(original_subcmds, build_cmd.sub_commands) # keys are named after the build step. calmjs_dist.build_calmjs_artifacts(dist, 'build_artifact', True) self.assertEqual( ('build_artifact', calmjs_dist.has_calmjs_artifact_declarations), build_cmd.sub_commands[-1], ) calmjs_dist.build_calmjs_artifacts(dist, 'calmjs_artifact', True) self.assertEqual( ('calmjs_artifact', calmjs_dist.has_calmjs_artifact_declarations), build_cmd.sub_commands[-1], )
Example #11
Source File: utils.py From calmjs with GNU General Public License v2.0 | 6 votes |
def make_dummy_dist(testcase_inst, metadata_map=(), pkgname='dummydist', version='0.0', working_dir=None): """ Test case helper function for creating a distribution dummy that uses PathMetadata for the foundation for integration level testing. """ if working_dir is None: working_dir = mkdtemp_singleton(testcase_inst) egg_info = '%s-%s.egg-info' % (pkgname, version) egg_info_dir = join(working_dir, egg_info) if not exists(egg_info_dir): makedirs(egg_info_dir) metadata = PathMetadata(working_dir, egg_info_dir) for fn, data in metadata_map: with open(join(egg_info_dir, fn), 'w') as fd: fd.write(data) return Distribution( working_dir, project_name=pkgname, metadata=metadata, version=version)
Example #12
Source File: bdist_egg.py From jbox with MIT License | 6 votes |
def finalize_options(self): ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info") self.egg_info = ei_cmd.egg_info if self.bdist_dir is None: bdist_base = self.get_finalized_command('bdist').bdist_base self.bdist_dir = os.path.join(bdist_base, 'egg') if self.plat_name is None: self.plat_name = get_build_platform() self.set_undefined_options('bdist', ('dist_dir', 'dist_dir')) if self.egg_output is None: # Compute filename of the output egg basename = Distribution( None, None, ei_cmd.egg_name, ei_cmd.egg_version, get_python_version(), self.distribution.has_ext_modules() and self.plat_name ).egg_name() self.egg_output = os.path.join(self.dist_dir, basename + '.egg')
Example #13
Source File: util.py From jbox with MIT License | 6 votes |
def matches_requirement(req, wheels): """List of wheels matching a requirement. :param req: The requirement to satisfy :param wheels: List of wheels to search. """ try: from pkg_resources import Distribution, Requirement except ImportError: raise RuntimeError("Cannot use requirements without pkg_resources") req = Requirement.parse(req) selected = [] for wf in wheels: f = wf.parsed_filename dist = Distribution(project_name=f.group("name"), version=f.group("ver")) if dist in req: selected.append(wf) return selected
Example #14
Source File: bdist_egg.py From Safejumper-for-Desktop with GNU General Public License v2.0 | 6 votes |
def finalize_options(self): ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info") self.egg_info = ei_cmd.egg_info if self.bdist_dir is None: bdist_base = self.get_finalized_command('bdist').bdist_base self.bdist_dir = os.path.join(bdist_base, 'egg') if self.plat_name is None: self.plat_name = get_build_platform() self.set_undefined_options('bdist', ('dist_dir', 'dist_dir')) if self.egg_output is None: # Compute filename of the output egg basename = Distribution( None, None, ei_cmd.egg_name, ei_cmd.egg_version, get_python_version(), self.distribution.has_ext_modules() and self.plat_name ).egg_name() self.egg_output = os.path.join(self.dist_dir, basename + '.egg')
Example #15
Source File: bdist_egg.py From lambda-packs with MIT License | 6 votes |
def finalize_options(self): ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info") self.egg_info = ei_cmd.egg_info if self.bdist_dir is None: bdist_base = self.get_finalized_command('bdist').bdist_base self.bdist_dir = os.path.join(bdist_base, 'egg') if self.plat_name is None: self.plat_name = get_build_platform() self.set_undefined_options('bdist', ('dist_dir', 'dist_dir')) if self.egg_output is None: # Compute filename of the output egg basename = Distribution( None, None, ei_cmd.egg_name, ei_cmd.egg_version, get_python_version(), self.distribution.has_ext_modules() and self.plat_name ).egg_name() self.egg_output = os.path.join(self.dist_dir, basename + '.egg')
Example #16
Source File: bdist_egg.py From pledgeservice with Apache License 2.0 | 6 votes |
def finalize_options(self): ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info") self.egg_info = ei_cmd.egg_info if self.bdist_dir is None: bdist_base = self.get_finalized_command('bdist').bdist_base self.bdist_dir = os.path.join(bdist_base, 'egg') if self.plat_name is None: self.plat_name = get_build_platform() self.set_undefined_options('bdist',('dist_dir', 'dist_dir')) if self.egg_output is None: # Compute filename of the output egg basename = Distribution( None, None, ei_cmd.egg_name, ei_cmd.egg_version, get_python_version(), self.distribution.has_ext_modules() and self.plat_name ).egg_name() self.egg_output = os.path.join(self.dist_dir, basename+'.egg')
Example #17
Source File: bdist_egg.py From lambda-chef-node-cleanup with Apache License 2.0 | 6 votes |
def finalize_options(self): ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info") self.egg_info = ei_cmd.egg_info if self.bdist_dir is None: bdist_base = self.get_finalized_command('bdist').bdist_base self.bdist_dir = os.path.join(bdist_base, 'egg') if self.plat_name is None: self.plat_name = get_build_platform() self.set_undefined_options('bdist', ('dist_dir', 'dist_dir')) if self.egg_output is None: # Compute filename of the output egg basename = Distribution( None, None, ei_cmd.egg_name, ei_cmd.egg_version, get_python_version(), self.distribution.has_ext_modules() and self.plat_name ).egg_name() self.egg_output = os.path.join(self.dist_dir, basename + '.egg')
Example #18
Source File: install_egg_info.py From python-netsurv with MIT License | 6 votes |
def finalize_options(self): self.set_undefined_options('install_lib', ('install_dir', 'install_dir')) self.set_undefined_options('install',('install_layout','install_layout')) if sys.hexversion > 0x2060000: self.set_undefined_options('install',('prefix_option','prefix_option')) ei_cmd = self.get_finalized_command("egg_info") basename = pkg_resources.Distribution( None, None, ei_cmd.egg_name, ei_cmd.egg_version ).egg_name() + '.egg-info' if self.install_layout: if not self.install_layout.lower() in ['deb']: raise DistutilsOptionError("unknown value for --install-layout") self.install_layout = self.install_layout.lower() basename = basename.replace('-py%s' % pkg_resources.PY_MAJOR, '') elif self.prefix_option or 'real_prefix' in sys.__dict__: # don't modify for virtualenv pass else: basename = basename.replace('-py%s' % pkg_resources.PY_MAJOR, '') self.source = ei_cmd.egg_info self.target = os.path.join(self.install_dir, basename) self.outputs = []
Example #19
Source File: util.py From auto-alt-text-lambda-api with MIT License | 6 votes |
def matches_requirement(req, wheels): """List of wheels matching a requirement. :param req: The requirement to satisfy :param wheels: List of wheels to search. """ try: from pkg_resources import Distribution, Requirement except ImportError: raise RuntimeError("Cannot use requirements without pkg_resources") req = Requirement.parse(req) selected = [] for wf in wheels: f = wf.parsed_filename dist = Distribution(project_name=f.group("name"), version=f.group("ver")) if dist in req: selected.append(wf) return selected
Example #20
Source File: bdist_egg.py From python-netsurv with MIT License | 6 votes |
def finalize_options(self): ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info") self.egg_info = ei_cmd.egg_info if self.bdist_dir is None: bdist_base = self.get_finalized_command('bdist').bdist_base self.bdist_dir = os.path.join(bdist_base, 'egg') if self.plat_name is None: self.plat_name = get_build_platform() self.set_undefined_options('bdist', ('dist_dir', 'dist_dir')) if self.egg_output is None: # Compute filename of the output egg basename = Distribution( None, None, ei_cmd.egg_name, ei_cmd.egg_version, get_python_version(), self.distribution.has_ext_modules() and self.plat_name ).egg_name() self.egg_output = os.path.join(self.dist_dir, basename + '.egg')
Example #21
Source File: install_egg_info.py From python-netsurv with MIT License | 6 votes |
def finalize_options(self): self.set_undefined_options('install_lib', ('install_dir', 'install_dir')) self.set_undefined_options('install',('install_layout','install_layout')) if sys.hexversion > 0x2060000: self.set_undefined_options('install',('prefix_option','prefix_option')) ei_cmd = self.get_finalized_command("egg_info") basename = pkg_resources.Distribution( None, None, ei_cmd.egg_name, ei_cmd.egg_version ).egg_name() + '.egg-info' if self.install_layout: if not self.install_layout.lower() in ['deb']: raise DistutilsOptionError("unknown value for --install-layout") self.install_layout = self.install_layout.lower() basename = basename.replace('-py%s' % pkg_resources.PY_MAJOR, '') elif self.prefix_option or 'real_prefix' in sys.__dict__: # don't modify for virtualenv pass else: basename = basename.replace('-py%s' % pkg_resources.PY_MAJOR, '') self.source = ei_cmd.egg_info self.target = os.path.join(self.install_dir, basename) self.outputs = []
Example #22
Source File: bdist_egg.py From kobo-predict with BSD 2-Clause "Simplified" License | 6 votes |
def finalize_options(self): ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info") self.egg_info = ei_cmd.egg_info if self.bdist_dir is None: bdist_base = self.get_finalized_command('bdist').bdist_base self.bdist_dir = os.path.join(bdist_base, 'egg') if self.plat_name is None: self.plat_name = get_build_platform() self.set_undefined_options('bdist', ('dist_dir', 'dist_dir')) if self.egg_output is None: # Compute filename of the output egg basename = Distribution( None, None, ei_cmd.egg_name, ei_cmd.egg_version, get_python_version(), self.distribution.has_ext_modules() and self.plat_name ).egg_name() self.egg_output = os.path.join(self.dist_dir, basename + '.egg')
Example #23
Source File: bdist_egg.py From python-netsurv with MIT License | 6 votes |
def finalize_options(self): ei_cmd = self.ei_cmd = self.get_finalized_command("egg_info") self.egg_info = ei_cmd.egg_info if self.bdist_dir is None: bdist_base = self.get_finalized_command('bdist').bdist_base self.bdist_dir = os.path.join(bdist_base, 'egg') if self.plat_name is None: self.plat_name = get_build_platform() self.set_undefined_options('bdist', ('dist_dir', 'dist_dir')) if self.egg_output is None: # Compute filename of the output egg basename = Distribution( None, None, ei_cmd.egg_name, ei_cmd.egg_version, get_python_version(), self.distribution.has_ext_modules() and self.plat_name ).egg_name() self.egg_output = os.path.join(self.dist_dir, basename + '.egg')
Example #24
Source File: util.py From kobo-predict with BSD 2-Clause "Simplified" License | 6 votes |
def matches_requirement(req, wheels): """List of wheels matching a requirement. :param req: The requirement to satisfy :param wheels: List of wheels to search. """ try: from pkg_resources import Distribution, Requirement except ImportError: raise RuntimeError("Cannot use requirements without pkg_resources") req = Requirement.parse(req) selected = [] for wf in wheels: f = wf.parsed_filename dist = Distribution(project_name=f.group("name"), version=f.group("ver")) if dist in req: selected.append(wf) return selected
Example #25
Source File: develop.py From ironpython2 with Apache License 2.0 | 5 votes |
def finalize_options(self): ei = self.get_finalized_command("egg_info") if ei.broken_egg_info: template = "Please rename %r to %r before using 'develop'" args = ei.egg_info, ei.broken_egg_info raise DistutilsError(template % args) self.args = [ei.egg_name] easy_install.finalize_options(self) self.expand_basedirs() self.expand_dirs() # pick up setup-dir .egg files only: no .egg-info self.package_index.scan(glob.glob('*.egg')) egg_link_fn = ei.egg_name + '.egg-link' self.egg_link = os.path.join(self.install_dir, egg_link_fn) self.egg_base = ei.egg_base if self.egg_path is None: self.egg_path = os.path.abspath(ei.egg_base) target = pkg_resources.normalize_path(self.egg_base) egg_path = pkg_resources.normalize_path( os.path.join(self.install_dir, self.egg_path)) if egg_path != target: raise DistutilsOptionError( "--egg-path must be a relative path from the install" " directory to " + target ) # Make a distribution for the package's source self.dist = pkg_resources.Distribution( target, pkg_resources.PathMetadata(target, os.path.abspath(ei.egg_info)), project_name=ei.egg_name ) self.setup_path = self._resolve_setup_path( self.egg_base, self.install_dir, self.egg_path, )
Example #26
Source File: wheel.py From ironpython2 with Apache License 2.0 | 5 votes |
def egg_name(self): return pkg_resources.Distribution( project_name=self.project_name, version=self.version, platform=(None if self.platform == 'any' else get_platform()), ).egg_name() + '.egg'
Example #27
Source File: install_egg_info.py From pledgeservice with Apache License 2.0 | 5 votes |
def finalize_options(self): self.set_undefined_options('install_lib',('install_dir','install_dir')) ei_cmd = self.get_finalized_command("egg_info") basename = pkg_resources.Distribution( None, None, ei_cmd.egg_name, ei_cmd.egg_version ).egg_name()+'.egg-info' self.source = ei_cmd.egg_info self.target = os.path.join(self.install_dir, basename) self.outputs = [self.target]
Example #28
Source File: install_egg_info.py From anpr with Creative Commons Attribution 4.0 International | 5 votes |
def finalize_options(self): self.set_undefined_options('install_lib', ('install_dir', 'install_dir')) ei_cmd = self.get_finalized_command("egg_info") basename = pkg_resources.Distribution( None, None, ei_cmd.egg_name, ei_cmd.egg_version ).egg_name() + '.egg-info' self.source = ei_cmd.egg_info self.target = os.path.join(self.install_dir, basename) self.outputs = []
Example #29
Source File: develop.py From anpr with Creative Commons Attribution 4.0 International | 5 votes |
def finalize_options(self): ei = self.get_finalized_command("egg_info") if ei.broken_egg_info: template = "Please rename %r to %r before using 'develop'" args = ei.egg_info, ei.broken_egg_info raise DistutilsError(template % args) self.args = [ei.egg_name] easy_install.finalize_options(self) self.expand_basedirs() self.expand_dirs() # pick up setup-dir .egg files only: no .egg-info self.package_index.scan(glob.glob('*.egg')) egg_link_fn = ei.egg_name + '.egg-link' self.egg_link = os.path.join(self.install_dir, egg_link_fn) self.egg_base = ei.egg_base if self.egg_path is None: self.egg_path = os.path.abspath(ei.egg_base) target = normalize_path(self.egg_base) egg_path = normalize_path(os.path.join(self.install_dir, self.egg_path)) if egg_path != target: raise DistutilsOptionError( "--egg-path must be a relative path from the install" " directory to " + target ) # Make a distribution for the package's source self.dist = Distribution( target, PathMetadata(target, os.path.abspath(ei.egg_info)), project_name=ei.egg_name ) self.setup_path = self._resolve_setup_path( self.egg_base, self.install_dir, self.egg_path, )
Example #30
Source File: install_scripts.py From ironpython2 with Apache License 2.0 | 5 votes |
def run(self): import setuptools.command.easy_install as ei self.run_command("egg_info") if self.distribution.scripts: orig.install_scripts.run(self) # run first to set up self.outfiles else: self.outfiles = [] if self.no_ep: # don't install entry point scripts into .egg file! return ei_cmd = self.get_finalized_command("egg_info") dist = Distribution( ei_cmd.egg_base, PathMetadata(ei_cmd.egg_base, ei_cmd.egg_info), ei_cmd.egg_name, ei_cmd.egg_version, ) bs_cmd = self.get_finalized_command('build_scripts') exec_param = getattr(bs_cmd, 'executable', None) bw_cmd = self.get_finalized_command("bdist_wininst") is_wininst = getattr(bw_cmd, '_is_running', False) writer = ei.ScriptWriter if is_wininst: exec_param = "python.exe" writer = ei.WindowsScriptWriter if exec_param == sys.executable: # In case the path to the Python executable contains a space, wrap # it so it's not split up. exec_param = [exec_param] # resolve the writer to the environment writer = writer.best() cmd = writer.command_spec_class.best().from_param(exec_param) for args in writer.get_args(dist, cmd.as_header()): self.write_script(*args)