@@ -214,7 +214,6 @@ def _log(self, level, msg, args):
214214 '' : 'text/plain' , # fallback in case README file has no extension
215215}
216216README = ['%s%s' % (base , ext ) for base in README_BASE for ext in README_EXT ]
217- print ('READMEEEE' , README )
218217
219218# location of LICENSE file
220219LICENSE = 'LICENSE'
@@ -348,9 +347,6 @@ def __init__(self):
348347 self .package_files = self .files_in_packages ()
349348 self .private_repo = False
350349
351- # determine location of README file in the package
352- self .readme = self .locate_readme ()
353-
354350 @staticmethod
355351 def release_on_pypi (lic ):
356352 """Given license lic, can/will we release on PyPI"""
@@ -1344,14 +1340,15 @@ def locate_readme(self):
13441340 """
13451341 readme = None
13461342
1347- for readme_path in [os .path .join (self .REPO_BASE_DIR , readme_file ) for readme_file in README ]:
1343+ for readme_path in [os .path .join (self .REPO_BASE_DIR , readme ) for readme in README ]:
13481344 if os .path .exists (readme_path ):
13491345 readme = readme_path
13501346 break
13511347
13521348 if readme is None :
13531349 raise Exception ('README is missing (was looking for: %s)' % ", " .join (README ))
13541350
1351+ log .info ('found README file at %s' % readme )
13551352 return readme
13561353
13571354 def parse_target (self , target , urltemplate = None ):
@@ -1407,12 +1404,15 @@ def parse_target(self, target, urltemplate=None):
14071404 new_target ['download_url' ] = "%s/tarball/master" % new_target ['url' ]
14081405
14091406 # Readme are required
1410- vsc_description = target .pop ('vsc_description' , True )
1411- if vsc_description :
1412- if 'long_description' in target :
1413- log .info (('Going to ignore the provided long_descripton.'
1414- 'Set it in the %s or disable vsc_description' ) % os .path .basename (self .readme ))
1415- readmetxt = _read (self .readme )
1407+ if target .pop ('vsc_description' , True ):
1408+ long_description = target .pop ('long_description' , '' )
1409+ if long_description [0 :5 ] == 'file:' :
1410+ # long description is a file, use README file from target
1411+ readme_file = long_description [5 :]
1412+ else :
1413+ # locate the README file
1414+ readme_file = self .locate_readme ()
1415+ readmetxt = _read (readme_file )
14161416
14171417 # look for description block, read text until double empty line or new block
14181418 # allow 'words with === on next line' or comment-like block '# title'
@@ -1429,16 +1429,16 @@ def parse_target(self, target, urltemplate=None):
14291429 descr = re .sub (r'\s+' , ' ' , descr ) # squash whitespace
14301430 except IndexError :
14311431 raise Exception ('Could not find a Description block in the README %s to create the long description' %
1432- self . readme )
1432+ readme_file )
14331433 log .info ('using long_description %s' % descr )
14341434 new_target ['description' ] = descr # summary in PKG-INFO
14351435 new_target ['long_description' ] = readmetxt # description in PKG-INFO
14361436
1437- readme_ext = os .path .splitext (self . readme )[- 1 ]
1437+ readme_ext = os .path .splitext (readme_file )[- 1 ]
14381438 if readme_ext in README_TYPES :
14391439 new_target ['long_description_content_type' ] = README_TYPES [readme_ext ]
14401440 else :
1441- raise Exception ("Failed to derive content type for README file '%s' based on extension" % self . readme )
1441+ raise Exception ("Failed to derive content type for README file '%s' based on extension" % readme_file )
14421442
14431443 vsc_scripts = target .pop ('vsc_scripts' , True )
14441444 if vsc_scripts :
@@ -1536,7 +1536,7 @@ def parse_target(self, target, urltemplate=None):
15361536 return new_target
15371537
15381538 @staticmethod
1539- def build_setup_cfg_for_bdist_rpm (target , readme ):
1539+ def build_setup_cfg_for_bdist_rpm (target ):
15401540 """Generates a setup.cfg on a per-target basis.
15411541
15421542 Create [bdist_rpm] section with
@@ -1545,10 +1545,8 @@ def build_setup_cfg_for_bdist_rpm(target, readme):
15451545 setup_requires => build_requires
15461546
15471547 @type target: dict
1548- @type readme: string
15491548
15501549 @param target: specifies the options to be passed to setup()
1551- @param readme: path to README file provided by package
15521550 """
15531551
15541552 if target .pop ('makesetupcfg' , True ):
@@ -1576,7 +1574,12 @@ def build_setup_cfg_for_bdist_rpm(target, readme):
15761574 txt .extend (["build_requires = %s" % (klass .sanitize (target ['setup_requires' ]))])
15771575
15781576 # add metadata
1579- txt += ['' , '[metadata]' , '' , 'description-file = %s' % os .path .basename (readme ), '' ]
1577+ if 'long_description' in target and target ['long_description' ][0 :5 ] == 'file:' :
1578+ # long description is a file, use README file from target
1579+ description_file = os .path .basename (target ['long_description' ][5 :])
1580+ else :
1581+ description_file = 'Unknown'
1582+ txt += ['' , '[metadata]' , '' , 'description-file = %s' % description_file , '' ]
15801583
15811584 setup_cfg .write ("\n " .join (txt + ['' ]))
15821585 setup_cfg .close ()
@@ -1598,7 +1601,7 @@ def prepare_rpm(self, target):
15981601 # therefor we regenerate self.package files with the excluded pkgs as extra param
15991602 self .package_files = self .files_in_packages (excluded_pkgs = pkgs )
16001603 _fvs ('prepare_rpm' ).SHARED_TARGET ['packages' ] = self .generate_packages ()
1601- self .build_setup_cfg_for_bdist_rpm (target , self . readme )
1604+ self .build_setup_cfg_for_bdist_rpm (target )
16021605
16031606 def action_target (self , target , setupfn = None , extra_sdist = None , urltemplate = None ):
16041607 """
@@ -1628,6 +1631,13 @@ def action_target(self, target, setupfn=None, extra_sdist=None, urltemplate=None
16281631 if do_cleanup :
16291632 self .cleanup ()
16301633
1634+ # add location of README to target long description
1635+ readme_file = self .locate_readme ()
1636+ if 'long_description' in target :
1637+ log .info (('Ignoring the provided long_descripton.'
1638+ 'Please set it in the %s or disable vsc_description' ) % os .path .basename (readme_file ))
1639+ target ['long_description' ] = 'file:%s' % readme_file
1640+
16311641 self .prepare_rpm (target )
16321642 x = self .parse_target (target , urltemplate )
16331643 setupfn (** x )
0 commit comments