view env/lib/python3.9/site-packages/networkx/ @ 0:4f3585e2f14b draft default tip

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author shellac
date Mon, 22 Mar 2021 18:12:50 +0000
line wrap: on
line source

"""Release data for NetworkX.

When NetworkX is imported a number of steps are followed to determine
the version information.

   1) If the release is not a development release (dev=False), then version
      information is read from, a file containing statically
      defined version information.  This file should exist on every
      downloadable release of NetworkX since creates it during
      packaging/installation.  However, might not exist if one
      is running NetworkX from the mercurial repository.  In the event that does not exist, then no vcs information will be available.

   2) If the release is a development release, then version information
      is read dynamically, when possible.  If no dynamic information can be
      read, then an attempt is made to read the information from
      If does not exist, then no vcs information will be available.

Clarification: is created only by

When creates, it does so before packaging/installation.
So the created file is included in the source distribution.  When a user
downloads a tar.gz file and extracts the files, the files will not be in a
live version control repository.  So when the user runs to install
NetworkX, we must make sure write_versionfile() does not overwrite the
revision information contained in the that was included in the
tar.gz file. This is why write_versionfile() includes an early escape.


import os
import sys
import time
import datetime

basedir = os.path.abspath(os.path.split(__file__)[0])

def write_versionfile():
    """Creates a static file containing version information."""
    versionfile = os.path.join(basedir, "")

    text = '''"""
Version information for NetworkX, created during installation.

Do not add this file to the repository.


import datetime

version = %(version)r
date = %(date)r

# Was NetworkX built from a development version? If so, remember that the major
# and minor versions reference the "target" (rather than "current") release.
dev = %(dev)r

# Format: (name, major, min, revision)
version_info = %(version_info)r

# Format: a 'datetime.datetime' instance
date_info = %(date_info)r

# Format: (vcs, vcs_tuple)
vcs_info = %(vcs_info)r


    # Try to update all information
    date, date_info, version, version_info, vcs_info = get_info(dynamic=True)

    def writefile():
        fh = open(versionfile, "w")
        subs = {
            "dev": dev,
            "version": version,
            "version_info": version_info,
            "date": date,
            "date_info": date_info,
            "vcs_info": vcs_info,
        fh.write(text % subs)

    if vcs_info[0] == "mercurial":
        # Then, we want to update
        if os.path.isfile(versionfile):
            # This is *good*, and the most likely place users will be when
            # running We do not want to overwrite
            # Grab the version so that setup can use it.
            # sys.path.insert(0, basedir)
            from version import version

            # del sys.path[0]
            # This is *bad*.  It means the user might have a tarball that
            # does not include  Let this error raise so we can
            # fix the tarball.
            # raise Exception(' not found!')

            # We no longer require that prepared tarballs include a
            # So we use the possibly trunctated value from get_info()
            # Then we write a new file.

    return version

def get_revision():
    """Returns revision and vcs information, dynamically obtained."""
    vcs, revision, tag = None, None, None

    gitdir = os.path.join(basedir, "..", ".git")

    if os.path.isdir(gitdir):
        vcs = "git"
        # For now, we are not bothering with revision and tag.

    vcs_info = (vcs, (revision, tag))

    return revision, vcs_info

def get_info(dynamic=True):
    # Date information
    date_info = datetime.datetime.utcfromtimestamp(
        int(os.environ.get("SOURCE_DATE_EPOCH", time.time()))
    date = time.asctime(date_info.timetuple())

    revision, version, version_info, vcs_info = None, None, None, None

    import_failed = False
    dynamic_failed = False

    if dynamic:
        revision, vcs_info = get_revision()
        if revision is None:
            dynamic_failed = True

    if dynamic_failed or not dynamic:
        # This is where most final releases of NetworkX will be.
        # All info should come from If it does not exist, then
        # no vcs information will be provided.
        # sys.path.insert(0, basedir)
            from version import date, date_info, version, version_info, vcs_info
        except ImportError:
            import_failed = True
            vcs_info = (None, (None, None))
            revision = vcs_info[1][0]
        # del sys.path[0]

    if import_failed or (dynamic and not dynamic_failed):
        # We are here if:
        #   we failed to determine static versioning info, or
        #   we successfully obtained dynamic revision info
        version = "".join([str(major), ".", str(minor)])
        if dev:
            version += ".dev_" + date_info.strftime("%Y%m%d%H%M%S")
        version_info = (name, major, minor, revision)

    return date, date_info, version, version_info, vcs_info

# Version information
name = "networkx"
major = "2"
minor = "5"

# Declare current release as a development release.
# Change to False before tagging a release; then change back.
dev = False

description = "Python package for creating and manipulating graphs and networks"
authors = {
    "Hagberg": ("Aric Hagberg", ""),
    "Schult": ("Dan Schult", ""),
    "Swart": ("Pieter Swart", ""),
maintainer = "NetworkX Developers"
maintainer_email = ""
url = ""
project_urls = {
    "Bug Tracker": "",
    "Documentation": "",
    "Source Code": "",
platforms = ["Linux", "Mac OSX", "Windows", "Unix"]
keywords = [
    "Graph Theory",
    "discrete mathematics",
classifiers = [
    "Development Status :: 5 - Production/Stable",
    "Intended Audience :: Developers",
    "Intended Audience :: Science/Research",
    "License :: OSI Approved :: BSD License",
    "Operating System :: OS Independent",
    "Programming Language :: Python :: 3",
    "Programming Language :: Python :: 3.6",
    "Programming Language :: Python :: 3.7",
    "Programming Language :: Python :: 3.8",
    "Programming Language :: Python :: 3 :: Only",
    "Topic :: Software Development :: Libraries :: Python Modules",
    "Topic :: Scientific/Engineering :: Bio-Informatics",
    "Topic :: Scientific/Engineering :: Information Analysis",
    "Topic :: Scientific/Engineering :: Mathematics",
    "Topic :: Scientific/Engineering :: Physics",

date, date_info, version, version_info, vcs_info = get_info()

if __name__ == "__main__":
    # Write versionfile for nightly snapshots.