Mercurial > repos > guerler > springsuite
comparison planemo/lib/python3.7/site-packages/networkx/release.py @ 1:56ad4e20f292 draft
"planemo upload commit 6eee67778febed82ddd413c3ca40b3183a3898f1"
| author | guerler |
|---|---|
| date | Fri, 31 Jul 2020 00:32:28 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:d30785e31577 | 1:56ad4e20f292 |
|---|---|
| 1 """Release data for NetworkX. | |
| 2 | |
| 3 When NetworkX is imported a number of steps are followed to determine | |
| 4 the version information. | |
| 5 | |
| 6 1) If the release is not a development release (dev=False), then version | |
| 7 information is read from version.py, a file containing statically | |
| 8 defined version information. This file should exist on every | |
| 9 downloadable release of NetworkX since setup.py creates it during | |
| 10 packaging/installation. However, version.py might not exist if one | |
| 11 is running NetworkX from the mercurial repository. In the event that | |
| 12 version.py does not exist, then no vcs information will be available. | |
| 13 | |
| 14 2) If the release is a development release, then version information | |
| 15 is read dynamically, when possible. If no dynamic information can be | |
| 16 read, then an attempt is made to read the information from version.py. | |
| 17 If version.py does not exist, then no vcs information will be available. | |
| 18 | |
| 19 Clarification: | |
| 20 version.py is created only by setup.py | |
| 21 | |
| 22 When setup.py creates version.py, it does so before packaging/installation. | |
| 23 So the created file is included in the source distribution. When a user | |
| 24 downloads a tar.gz file and extracts the files, the files will not be in a | |
| 25 live version control repository. So when the user runs setup.py to install | |
| 26 NetworkX, we must make sure write_versionfile() does not overwrite the | |
| 27 revision information contained in the version.py that was included in the | |
| 28 tar.gz file. This is why write_versionfile() includes an early escape. | |
| 29 | |
| 30 """ | |
| 31 | |
| 32 # Copyright (C) 2004-2019 by | |
| 33 # Aric Hagberg <hagberg@lanl.gov> | |
| 34 # Dan Schult <dschult@colgate.edu> | |
| 35 # Pieter Swart <swart@lanl.gov> | |
| 36 # All rights reserved. | |
| 37 # BSD license. | |
| 38 | |
| 39 import os | |
| 40 import sys | |
| 41 import time | |
| 42 import datetime | |
| 43 | |
| 44 basedir = os.path.abspath(os.path.split(__file__)[0]) | |
| 45 | |
| 46 | |
| 47 def write_versionfile(): | |
| 48 """Creates a static file containing version information.""" | |
| 49 versionfile = os.path.join(basedir, 'version.py') | |
| 50 | |
| 51 text = '''""" | |
| 52 Version information for NetworkX, created during installation. | |
| 53 | |
| 54 Do not add this file to the repository. | |
| 55 | |
| 56 """ | |
| 57 | |
| 58 import datetime | |
| 59 | |
| 60 version = %(version)r | |
| 61 date = %(date)r | |
| 62 | |
| 63 # Was NetworkX built from a development version? If so, remember that the major | |
| 64 # and minor versions reference the "target" (rather than "current") release. | |
| 65 dev = %(dev)r | |
| 66 | |
| 67 # Format: (name, major, min, revision) | |
| 68 version_info = %(version_info)r | |
| 69 | |
| 70 # Format: a 'datetime.datetime' instance | |
| 71 date_info = %(date_info)r | |
| 72 | |
| 73 # Format: (vcs, vcs_tuple) | |
| 74 vcs_info = %(vcs_info)r | |
| 75 | |
| 76 ''' | |
| 77 | |
| 78 # Try to update all information | |
| 79 date, date_info, version, version_info, vcs_info = get_info(dynamic=True) | |
| 80 | |
| 81 def writefile(): | |
| 82 fh = open(versionfile, 'w') | |
| 83 subs = { | |
| 84 'dev': dev, | |
| 85 'version': version, | |
| 86 'version_info': version_info, | |
| 87 'date': date, | |
| 88 'date_info': date_info, | |
| 89 'vcs_info': vcs_info | |
| 90 } | |
| 91 fh.write(text % subs) | |
| 92 fh.close() | |
| 93 | |
| 94 if vcs_info[0] == 'mercurial': | |
| 95 # Then, we want to update version.py. | |
| 96 writefile() | |
| 97 else: | |
| 98 if os.path.isfile(versionfile): | |
| 99 # This is *good*, and the most likely place users will be when | |
| 100 # running setup.py. We do not want to overwrite version.py. | |
| 101 # Grab the version so that setup can use it. | |
| 102 # sys.path.insert(0, basedir) | |
| 103 from version import version | |
| 104 # del sys.path[0] | |
| 105 else: | |
| 106 # This is *bad*. It means the user might have a tarball that | |
| 107 # does not include version.py. Let this error raise so we can | |
| 108 # fix the tarball. | |
| 109 # raise Exception('version.py not found!') | |
| 110 | |
| 111 # We no longer require that prepared tarballs include a version.py | |
| 112 # So we use the possibly trunctated value from get_info() | |
| 113 # Then we write a new file. | |
| 114 writefile() | |
| 115 | |
| 116 return version | |
| 117 | |
| 118 | |
| 119 def get_revision(): | |
| 120 """Returns revision and vcs information, dynamically obtained.""" | |
| 121 vcs, revision, tag = None, None, None | |
| 122 | |
| 123 gitdir = os.path.join(basedir, '..', '.git') | |
| 124 | |
| 125 if os.path.isdir(gitdir): | |
| 126 vcs = 'git' | |
| 127 # For now, we are not bothering with revision and tag. | |
| 128 | |
| 129 vcs_info = (vcs, (revision, tag)) | |
| 130 | |
| 131 return revision, vcs_info | |
| 132 | |
| 133 | |
| 134 def get_info(dynamic=True): | |
| 135 # Date information | |
| 136 date_info = datetime.datetime.utcfromtimestamp(int(os.environ.get('SOURCE_DATE_EPOCH', time.time()))) | |
| 137 date = time.asctime(date_info.timetuple()) | |
| 138 | |
| 139 revision, version, version_info, vcs_info = None, None, None, None | |
| 140 | |
| 141 import_failed = False | |
| 142 dynamic_failed = False | |
| 143 | |
| 144 if dynamic: | |
| 145 revision, vcs_info = get_revision() | |
| 146 if revision is None: | |
| 147 dynamic_failed = True | |
| 148 | |
| 149 if dynamic_failed or not dynamic: | |
| 150 # This is where most final releases of NetworkX will be. | |
| 151 # All info should come from version.py. If it does not exist, then | |
| 152 # no vcs information will be provided. | |
| 153 # sys.path.insert(0, basedir) | |
| 154 try: | |
| 155 from version import date, date_info, version, version_info, vcs_info | |
| 156 except ImportError: | |
| 157 import_failed = True | |
| 158 vcs_info = (None, (None, None)) | |
| 159 else: | |
| 160 revision = vcs_info[1][0] | |
| 161 #del sys.path[0] | |
| 162 | |
| 163 if import_failed or (dynamic and not dynamic_failed): | |
| 164 # We are here if: | |
| 165 # we failed to determine static versioning info, or | |
| 166 # we successfully obtained dynamic revision info | |
| 167 version = ''.join([str(major), '.', str(minor)]) | |
| 168 if dev: | |
| 169 version += '.dev_' + date_info.strftime("%Y%m%d%H%M%S") | |
| 170 version_info = (name, major, minor, revision) | |
| 171 | |
| 172 return date, date_info, version, version_info, vcs_info | |
| 173 | |
| 174 | |
| 175 # Version information | |
| 176 name = 'networkx' | |
| 177 major = "2" | |
| 178 minor = "4" | |
| 179 | |
| 180 | |
| 181 # Declare current release as a development release. | |
| 182 # Change to False before tagging a release; then change back. | |
| 183 dev = False | |
| 184 | |
| 185 | |
| 186 description = "Python package for creating and manipulating graphs and networks" | |
| 187 license = 'BSD' | |
| 188 authors = {'Hagberg': ('Aric Hagberg', 'hagberg@lanl.gov'), | |
| 189 'Schult': ('Dan Schult', 'dschult@colgate.edu'), | |
| 190 'Swart': ('Pieter Swart', 'swart@lanl.gov')} | |
| 191 maintainer = "NetworkX Developers" | |
| 192 maintainer_email = "networkx-discuss@googlegroups.com" | |
| 193 url = 'http://networkx.github.io/' | |
| 194 project_urls = { | |
| 195 "Bug Tracker": "https://github.com/networkx/networkx/issues", | |
| 196 "Documentation": "https://networkx.github.io/documentation/stable/", | |
| 197 "Source Code": "https://github.com/networkx/networkx", | |
| 198 } | |
| 199 platforms = ['Linux', 'Mac OSX', 'Windows', 'Unix'] | |
| 200 keywords = ['Networks', 'Graph Theory', 'Mathematics', | |
| 201 'network', 'graph', 'discrete mathematics', 'math'] | |
| 202 classifiers = [ | |
| 203 'Development Status :: 5 - Production/Stable', | |
| 204 'Intended Audience :: Developers', | |
| 205 'Intended Audience :: Science/Research', | |
| 206 'License :: OSI Approved :: BSD License', | |
| 207 'Operating System :: OS Independent', | |
| 208 'Programming Language :: Python :: 3', | |
| 209 'Programming Language :: Python :: 3.5', | |
| 210 'Programming Language :: Python :: 3.6', | |
| 211 'Programming Language :: Python :: 3.7', | |
| 212 'Programming Language :: Python :: 3.8', | |
| 213 'Programming Language :: Python :: 3 :: Only', | |
| 214 'Topic :: Software Development :: Libraries :: Python Modules', | |
| 215 'Topic :: Scientific/Engineering :: Bio-Informatics', | |
| 216 'Topic :: Scientific/Engineering :: Information Analysis', | |
| 217 'Topic :: Scientific/Engineering :: Mathematics', | |
| 218 'Topic :: Scientific/Engineering :: Physics'] | |
| 219 | |
| 220 date, date_info, version, version_info, vcs_info = get_info() | |
| 221 | |
| 222 if __name__ == '__main__': | |
| 223 # Write versionfile for nightly snapshots. | |
| 224 write_versionfile() |
