def _egg_info(path_to_egg='../../'): path_to_egg = os.path.join(os.path.dirname(__file__), path_to_egg) egg_info = pkginfo.Develop(path_to_egg) release = egg_info.version parsed_version = parse_version(release) version = '%s.%s' % tuple([int(x) for x in parsed_version[0:2]]) return egg_info.name, egg_info.author, version, release
def get_metadata(self): from glob import glob metadata = {} ext_dir = self.path or get_extension_path(self.name) if not ext_dir or not os.path.isdir(ext_dir): return None # include *.egg-info and *.dist-info info_dirs = glob(os.path.join(ext_dir, self.name.replace('-', '_') + '*.*-info')) if not info_dirs: return None azext_metadata = WheelExtension.get_azext_metadata(ext_dir) if azext_metadata: metadata.update(azext_metadata) for dist_info_dirname in info_dirs: try: if dist_info_dirname.endswith('.egg-info'): ext_whl_metadata = pkginfo.Develop(dist_info_dirname) elif dist_info_dirname.endswith('.dist-info'): ext_whl_metadata = pkginfo.Wheel(dist_info_dirname) else: raise ValueError() if self.name == ext_whl_metadata.name: metadata.update(vars(ext_whl_metadata)) except ValueError: logger.warning('extension %s contains invalid metadata for Python Package', self.name) return metadata
def get_metadata(self): if not extension_exists(self.name): return None metadata = {} ext_dir = self.path egg_info_dirs = [ f for f in os.listdir(ext_dir) if f.endswith('.egg-info') ] azext_metadata = DevExtension.get_azext_metadata(ext_dir) if azext_metadata: metadata.update(azext_metadata) for egg_info_dirname in egg_info_dirs: egg_metadata_path = os.path.join( ext_dir, egg_info_dirname, ) try: ext_whl_metadata = pkginfo.Develop(egg_metadata_path) metadata.update(vars(ext_whl_metadata)) except ValueError: logger.warning( 'extension % contains invalid metadata for Python Package', self.name) return metadata
def get_metadata(self): from glob import glob if not extension_exists(self.name): return None metadata = {} ext_dir = self.path or get_extension_path(self.name) info_dirs = glob(os.path.join(ext_dir, '*.*-info')) azext_metadata = WheelExtension.get_azext_metadata(ext_dir) if azext_metadata: metadata.update(azext_metadata) for dist_info_dirname in info_dirs: parsed_dist_info_dir = WHEEL_INFO_RE(dist_info_dirname) if not parsed_dist_info_dir: continue parsed_dist_info_dir = parsed_dist_info_dir.groupdict().get('name') if os.path.split(parsed_dist_info_dir)[-1] == self.name.replace( '-', '_'): whl_metadata_filepath = os.path.join(dist_info_dirname, WHL_METADATA_FILENAME) if os.path.isfile(whl_metadata_filepath): with open(whl_metadata_filepath) as f: metadata.update(json.loads(f.read())) elif os.path.isfile(os.path.join(dist_info_dirname, 'PKG-INFO')): metadata.update( pkginfo.Develop(dist_info_dirname).__dict__) return metadata
def configure_metadata(app): """Add distribution metadata for display in templates""" metadata = pkginfo.Develop(os.path.join(app.root_path, "..")) # Get git hash from version if present # Todo: extend Develop instead of monkey patching if metadata.version and '+ng' in metadata.version: metadata.git_hash = metadata.version.split('+ng')[-1].split('.')[0] app.config.metadata = metadata
def find_pkg_info(self, path): versions = set() for root, dirs, files in os.walk(path): if not root.endswith('.egg'): continue if not os.path.exists(os.path.join(root, 'EGG-INFO', 'PKG-INFO')): continue package = pkginfo.Develop(root) versions.add('%s==%s' % (package.name, package.version)) return versions
def crawl(self): """ Crawl config file following the 'extend' option of 'Buildout' section """ for item in os.listdir(self.eggs_dir): egg_filepath = os.path.join(self.eggs_dir, item) #print "Opening egg: ", egg_filepath infos = pkginfo.Develop(os.path.join(self.eggs_dir, item)) #print "Name:", infos.name #print "-"*200 #print "Version:", infos.version #print "Path:", os.path.join(self.eggs_dir, item) #print "Url:", infos.home_page #print "Summary:", len(infos.summary or '') #print infos.description #print #print self.add_egg(infos.name, Version(infos))
def get_nni_meta(source): if not os.path.exists(source): print_error('{} does not exist'.format(source)) return None if os.path.isdir(source): if not os.path.exists(os.path.join(source, 'setup.py')): print_error('setup.py not found') return None pkg = pkginfo.Develop(source) else: if not source.endswith('.whl'): print_error('File name {} must ends with \'.whl\''.format(source)) return False pkg = pkginfo.Wheel(source) classifiers = pkg.classifiers meta = parse_classifiers(classifiers) meta['package_name'] = pkg.name return meta
def set_defaults(egg=True): _confpy = sys._getframe(1).f_locals author = 'gocept' if egg: _dist = pkginfo.Develop(os.path.join('..', 'src')) project = _dist.name author = _dist.author release = _dist.version version = [] for x in release: try: version.append(str(int(x))) except ValueError: break version = '.'.join(version) _year = datetime.date.today().year _year_started = _confpy.get('_year_started', _year) if str(_year) != str(_year_started): _year = u'%s-%s' % (_year_started, _year) copyright = u'%s %s' % (_year, author) source_suffix = '.txt' master_doc = 'index' needs_sphinx = '1.0' extensions = [ 'sphinx.ext.autosummary', 'sphinx.ext.autodoc', 'sphinx.ext.viewcode', ] autosummary_generate = ['api.txt'] _autosummary_output = AUTOSUMMARY_OUTPUT templates_path = [ pkg_resources.resource_filename( 'gocept.package', 'themes/gocept/templates'), ] html_theme_path = [ pkg_resources.resource_filename('gocept.package', 'themes')] html_theme = 'gocept' _default_sidebars = ['globaltoc.html', 'searchbox.html'] if egg: _default_sidebars.insert(0, 'project-links.html') html_sidebars = { '**': _default_sidebars, } html_context = {} html_logo = pkg_resources.resource_filename( 'gocept.package', 'themes/gocept/static/gocept.png') html_favicon = pkg_resources.resource_filename( 'gocept.package', 'themes/gocept/static/favicon.ico') html_show_sourcelink = False for key, value in locals().copy().items(): if key not in _confpy: _confpy[key] = value # We use the autosummary extension to build API docs from source code. # However, this extension doesn't update the generated docs if the source # files change. Therefore, we need to remove the generated stuff before # each run. The _autosummary_output variable tells the relative path to # the directory that autosummary uses to put its generated files and which # we, therefore, need to remove. It must be the same that the autosummary # directive in api.txt points to. if os.path.isdir(_autosummary_output): shutil.rmtree(_autosummary_output) elif os.path.exists(_autosummary_output): raise RuntimeError('Expected %s to be a directory.' % os.path.abspath(_autosummary_output)) os.mkdir(_autosummary_output)
except: print("Requires dmgbuild-module, use pip install dmgbuild") exit() # Make sure we are in the src folder if not os.path.exists("builder"): raise FileNotFoundError( "Run from the main SABnzbd source folder: python builder/package.py" ) # Check if signing is possible authority = os.environ.get("SIGNING_AUTH") # Extract version info and set DMG path # Create sub-folder to upload later release = pkginfo.Develop(".").version prod = "SABnzbd-" + release fileDmg = prod + "-osx.dmg" # Path to app file apppath = "dist/SABnzbd.app" # Copy Readme readmepath = os.path.join(apppath, "Contents/Resources/README.txt") # Path to background and the icon backgroundpath = "builder/osx/image/sabnzbd_new_bg.png" iconpath = "builder/osx/image/sabnzbdplus.icns" # Make DMG print("Building DMG")
templates_path = ['_templates'] # The suffix of source filenames. source_suffix = '.rst' # The encoding of source files. #source_encoding = 'utf-8' # The master toctree document. master_doc = 'index' # General information about the project. parent = os.path.dirname(os.path.dirname(__file__)) parent_dir = os.path.abspath(parent) sys.path.append(parent_dir) pkg_info = pkginfo.Develop(parent_dir) year = datetime.datetime.now().year project = u'%s' % pkg_info.name copyright = u'2010-%s, CMF Developers' % year # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. version = pkg_info.version.replace('dev', '') # The full version, including alpha/beta/rc tags. release = pkg_info.version # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages.
target = None execute = True else: target = sys.argv[1] execute = len(sys.argv) > 2 and bool(sys.argv[2]) if not execute: # Copy this script to build folder and launch it shutil.copyfile(pgm, os.path.join('src', pgm)) os.chdir('src') ret = os.system(' '.join(['python', pgm, target, 'execute'])) os.remove(pgm) exit(ret) # Extract version info release = pkginfo.Develop('.').version # Check paths Git = CheckPath('git') if os.name == 'nt': msg = 'Requires the Unicode version of NSIS' NSIS = CheckPath('makensis') if NSIS: log = '%s.log' % NSIS os.system('%s >%s' % (NSIS, log)) if 'Unicode' in open(log).read(): msg = '' delete_files(log) if msg: print msg
try: import dmgbuild except: print 'Requires dmgbuild-module, use pip install dmgbuild' exit() # Check if signing is possible authority = os.environ.get('SIGNING_AUTH') if not authority: print 'No SIGNING_AUTH set! Aborting.' exit(1) # Extract version info and set DMG path # Create sub-folder to upload later os.system('mkdir dmg') release = pkginfo.Develop('./src/').version prod = 'SABnzbd-' + release fileDmg = os.path.join('dmg', prod + '-osx.dmg') # Path to app file apppath = 'src/dist/SABnzbd.app' # Copy Readme readmepath_old = os.path.join(apppath, 'Contents/Resources/README.mkd') readmepath_new = 'README.txt' os.system('cp -p "%s" "%s"' % (readmepath_old, readmepath_new)) # Path to background backgroundpath = 'osx/image/sabnzbd_new_bg.png' # Mae DMG
# -*- coding: utf-8 -*- # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import os import sys import pkginfo dist = pkginfo.Develop('..') # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.append(os.path.abspath('..')) # -- General configuration ----------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] # The suffix of source filenames.
# # mako-version-tag documentation build configuration file, created by # sphinx-quickstart on Fri Jul 10 19:59:59 2009. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import sys, os import pkginfo dist = pkginfo.Develop('../src') # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.append(os.path.abspath('../src')) # -- General configuration ----------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be extensions # coming with Sphinx (named 'sphinx.ext.*') or your custom ones. extensions = ['sphinx.ext.autodoc'] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates']
def get_directory_details(path, pbr_version=None): if not sh.isdir(path): raise IOError("Can not detail non-existent directory %s" % (path)) # Check if we already got the details of this dir previously with EGGS_DETAILED_LOCK: path = sh.abspth(path) cache_key = "d:%s" % (sh.abspth(path)) if cache_key in EGGS_DETAILED: return EGGS_DETAILED[cache_key] details = None skip_paths = [ sh.joinpths(path, "PKG-INFO"), sh.joinpths(path, "EGG-INFO"), ] skip_paths.extend(glob.glob(sh.joinpths(path, "*.egg-info"))) if any(sh.exists(a_path) for a_path in skip_paths): # Some packages seem to not support the 'egg_info' call and # provide there own path/file that contains this information # already, so just use it if we can get at it... # # Ie for pyyaml3.x: # # error: invalid command 'egg_info' details = pkginfo.Develop(path) if not details or not details.name: cmd = [sys.executable, 'setup.py', 'egg_info'] if pbr_version: env_overrides = { "PBR_VERSION": str(pbr_version), } else: env_overrides = {} sh.execute(cmd, cwd=path, env_overrides=env_overrides) details = pkginfo.get_metadata(path) if not details or not details.name: raise RuntimeError("No egg detail information discovered" " at '%s'" % path) egg_details = { 'req': create_requirement(details.name, version=details.version), } for attr_name in [ 'description', 'author', 'version', 'name', 'summary' ]: egg_details[attr_name] = getattr(details, attr_name) for attr_name in ['description', 'author', 'summary']: attr_value = egg_details[attr_name] if isinstance(attr_value, six.text_type): # Fix any unicode which will cause unicode decode failures... # versions or names shouldn't be unicode, and the rest # we don't really care about being unicode (since its # just used for logging right now anyway...). # # The reason this is done is that 'elasticsearch' seems to # have a unicode author name, and that causes the log_object # to blowup, so just avoid that by replacing this information # in the first place. egg_details[attr_name] = attr_value.encode("ascii", errors='replace') LOG.debug("Extracted '%s' egg detail information:", path) utils.log_object(egg_details, logger=LOG, level=logging.DEBUG) EGGS_DETAILED[cache_key] = egg_details return egg_details
# This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import datetime import sys import os import pkginfo metadata = pkginfo.Develop( os.path.join(os.path.dirname(__file__), '../..') ) # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. #needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones.
# -*- coding: utf-8 -*- import sys, os, pkginfo, datetime pkg_info = pkginfo.Develop(os.path.join(os.path.dirname(__file__), '..')) extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx'] intersphinx_mapping = dict(python=('http://docs.python.org/dev', None), ) # General source_suffix = '.txt' master_doc = 'index' project = pkg_info.name start_year = 2012 current_year = datetime.datetime.now().year if current_year == start_year: copyright = '%s Simplistix Ltd' % (start_year) else: copyright = '%s-%s Simplistix Ltd' % (start_year, current_year) version = release = pkg_info.version exclude_trees = ['_build'] unused_docs = ['description', 'ideas'] pygments_style = 'sphinx' # Options for HTML output html_theme = 'default' htmlhelp_basename = project + 'doc' # Options for LaTeX output latex_documents = [
ver.write(version_file) if __name__ == "__main__": # Was any option supplied? if len(sys.argv) < 2: raise TypeError("Please specify what to do") # Make sure we are in the src folder if not os.path.exists("builder"): raise FileNotFoundError( "Run from the main SABnzbd source folder: python builder/package.py" ) # Extract version info RELEASE_VERSION = pkginfo.Develop(".").version # Check if we have the needed certificates try: import certifi except ImportError: raise FileNotFoundError("Need certifi module") # Define release name RELEASE_NAME = "SABnzbd-%s" % RELEASE_VERSION RELEASE_TITLE = "SABnzbd %s" % RELEASE_VERSION RELEASE_SRC = RELEASE_NAME + "-src.tar.gz" RELEASE_BINARY_32 = RELEASE_NAME + "-win32-bin.zip" RELEASE_BINARY_64 = RELEASE_NAME + "-win64-bin.zip" RELEASE_INSTALLER = RELEASE_NAME + "-win-setup.exe" RELEASE_MACOS = RELEASE_NAME + "-osx.dmg"