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