
Hi, Thank you Phillip for your help and support!
I would like to access a package metadata before it is installed:
I use the following class
####################CLASS class Easy_deb: def __init__(self,req_string): self.requirement = pkg_resources.Requirement.parse(req_string) self.index = PackageIndex() self.found = None self.dest = None self.filename = None self.source_dir = None
def download_source(self): self.index.find_packages(self.requirement) self.found=self.index.obtain(self.requirement) if self.found: self.dest='deb-pkg-'+self.found.key+self.found.version if os.path.isdir(self.dest): shutil.rmtree(self.dest) os.makedirs(self.dest) self.filename=self.index.download(self.found.location, self.dest)
def unpack(self): unpack_archive(self.filename, self.dest) setups = glob.glob(os.path.join(self.dest, '*', 'setup.py')) self.source_dir = os.path.dirname(setups[0])
def deb_src(self): debian_dir=os.path.join(self.source_dir,'debian') shutil.copytree('template',debian_dir) #file=os.path.join(debian_dir,"control") #print file sed(os.path.join(debian_dir,"control"),"%%PKGNAME%%",self.requirement.key) <------ SED LINE os.chdir(self.source_dir)
#inst_dir=os.path.join('./debian','tmp') #main(['-d']+[inst_dir,'.'])
def create(self): self.download_source() self.unpack() self.deb_src() ####################END OF CLASS
to download modules and create a deb package. I need to retrieve other metadata like description, author and license. I nned it to put it into lines like SED LINE.
Thank you again Vincenzo
___________________________________ Yahoo! Mail: gratis 1GB per i messaggi e allegati da 10MB http://mail.yahoo.it

At 10:58 PM 8/14/2005 +0200, Vincenzo Di Massa wrote:
def download_source(self): self.index.find_packages(self.requirement)
The above line is redundant; obtain() will call find_packages() automatically. Also, you may not want to use obtain anyway. For what you are trying to do, I would suggest running "easy_install --editable --build_dir=somewhere requirement", because then it will handle all the details of finding and unpacking the source. The source tree will then be "somewhere/projectname" (the project name will be all-lowercase). You could use a temporary directory for "somewhere", if you like. In any case this will take care of most of the things you're doing in this code outside of the deb_src() method.
I need to retrieve other metadata like description, author and license. I nned it to put it into lines like SED LINE.
Well, you can always run the package's setup script, and in fact you will need to do so if you're working with an unbuilt source distribution. Most of the PKG-INFO metadata items can be displayed using options to setup.py, however. For example, running this in the setuptools directory:
python setup.py --name --version --author --license --url
produces this output:
setuptools 0.6a0 Phillip J. Eby PSF or ZPL http://peak.telecommunity.com/DevCenter/setuptools
Use setup.py --help to get a list of the available options.
Note that you may want to pass the name and version results through pkg_resources' safe_name() and safe_version() functions.
participants (2)
-
Phillip J. Eby
-
Vincenzo Di Massa