summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.coveragerc2
-rw-r--r--networkx/__init__.py32
-rw-r--r--networkx/release.py234
-rw-r--r--setup.py92
4 files changed, 62 insertions, 298 deletions
diff --git a/.coveragerc b/.coveragerc
index a9858459..64641b7b 100644
--- a/.coveragerc
+++ b/.coveragerc
@@ -1,4 +1,4 @@
[run]
branch = True
source = networkx
-omit = */tests/*, conftest.py, *release.py, *testing/test.py
+omit = */tests/*, conftest.py, *testing/test.py
diff --git a/networkx/__init__.py b/networkx/__init__.py
index 9d3e57cb..bd1e05a9 100644
--- a/networkx/__init__.py
+++ b/networkx/__init__.py
@@ -8,37 +8,7 @@ structure, dynamics, and functions of complex networks.
See https://networkx.org for complete documentation.
"""
-import sys
-
-if sys.version_info[:2] < (3, 7):
- m = "Python 3.7 or later is required for NetworkX (%d.%d detected)."
- raise ImportError(m % sys.version_info[:2])
-del sys
-
-# Release data
-from networkx import release
-
-
-__author__ = (
- f"{release.authors['Hagberg'][0]} <{release.authors['Hagberg'][1]}>\n"
- f"{release.authors['Schult'][0]} <{release.authors['Schult'][1]}>\n"
- f"{release.authors['Swart'][0]} <{release.authors['Swart'][1]}>"
-)
-
-__date__ = release.date
-__version__ = release.version
-
-__bibtex__ = """@inproceedings{hagberg-2008-exploring,
-author = {Aric A. Hagberg and Daniel A. Schult and Pieter J. Swart},
-title = {Exploring network structure, dynamics, and function using {NetworkX}},
-year = {2008},
-month = Aug,
-urlpdf = {http://math.lanl.gov/~hagberg/Papers/hagberg-2008-exploring.pdf},
-booktitle = {Proceedings of the 7th Python in Science Conference (SciPy2008)},
-editors = {G\"{a}el Varoquaux, Travis Vaught, and Jarrod Millman},
-address = {Pasadena, CA USA},
-pages = {11--15}
-}"""
+__version__ = "2.6rc1.dev0"
# These are import orderwise
from networkx.exception import *
diff --git a/networkx/release.py b/networkx/release.py
deleted file mode 100644
index 94b3a42a..00000000
--- a/networkx/release.py
+++ /dev/null
@@ -1,234 +0,0 @@
-"""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 version.py, a file containing statically
- defined version information. This file should exist on every
- downloadable release of NetworkX since setup.py creates it during
- packaging/installation. However, version.py might not exist if one
- is running NetworkX from the mercurial repository. In the event that
- version.py 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 version.py.
- If version.py does not exist, then no vcs information will be available.
-
-Clarification:
- version.py is created only by setup.py
-
-When setup.py creates version.py, 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 setup.py to install
-NetworkX, we must make sure write_versionfile() does not overwrite the
-revision information contained in the version.py 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, "version.py")
-
- 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)
- fh.close()
-
- if vcs_info[0] == "mercurial":
- # Then, we want to update version.py.
- writefile()
- else:
- if os.path.isfile(versionfile):
- # This is *good*, and the most likely place users will be when
- # running setup.py. We do not want to overwrite version.py.
- # Grab the version so that setup can use it.
- # sys.path.insert(0, basedir)
- from version import version
-
- # del sys.path[0]
- else:
- # This is *bad*. It means the user might have a tarball that
- # does not include version.py. Let this error raise so we can
- # fix the tarball.
- # raise Exception('version.py not found!')
-
- # We no longer require that prepared tarballs include a version.py
- # So we use the possibly trunctated value from get_info()
- # Then we write a new file.
- writefile()
-
- 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 version.py. If it does not exist, then
- # no vcs information will be provided.
- # sys.path.insert(0, basedir)
- try:
- from networkx.version import (
- date,
- date_info,
- version,
- version_info,
- vcs_info,
- )
- except ImportError:
- import_failed = True
- vcs_info = (None, (None, None))
- else:
- 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 = "6rc1"
-
-
-# Declare current release as a development release.
-# Change to False before tagging a release; then change back.
-dev = True
-
-
-description = "Python package for creating and manipulating graphs and networks"
-authors = {
- "Hagberg": ("Aric Hagberg", "hagberg@lanl.gov"),
- "Schult": ("Dan Schult", "dschult@colgate.edu"),
- "Swart": ("Pieter Swart", "swart@lanl.gov"),
-}
-maintainer = "NetworkX Developers"
-maintainer_email = "networkx-discuss@googlegroups.com"
-url = "https://networkx.org/"
-project_urls = {
- "Bug Tracker": "https://github.com/networkx/networkx/issues",
- "Documentation": "https://networkx.org/documentation/stable/",
- "Source Code": "https://github.com/networkx/networkx",
-}
-platforms = ["Linux", "Mac OSX", "Windows", "Unix"]
-keywords = [
- "Networks",
- "Graph Theory",
- "Mathematics",
- "network",
- "graph",
- "discrete mathematics",
- "math",
-]
-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.7",
- "Programming Language :: Python :: 3.8",
- "Programming Language :: Python :: 3.9",
- "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.
- write_versionfile()
diff --git a/setup.py b/setup.py
index 73514221..20d355f0 100644
--- a/setup.py
+++ b/setup.py
@@ -1,23 +1,8 @@
-"""
-Setup script for networkx
-
-You can install networkx with
-
-python setup.py install
-"""
from glob import glob
import os
import sys
-
-if os.path.exists("MANIFEST"):
- os.remove("MANIFEST")
-
from setuptools import setup
-if sys.argv[-1] == "setup.py":
- print("To install, run 'python setup.py install'")
- print()
-
if sys.version_info[:2] < (3, 7):
error = (
"NetworkX 2.6+ requires Python 3.7 or later (%d.%d detected). \n"
@@ -27,12 +12,55 @@ if sys.version_info[:2] < (3, 7):
sys.stderr.write(error + "\n")
sys.exit(1)
-# Write the version information.
-sys.path.insert(0, "networkx")
-import release
-version = release.write_versionfile()
-sys.path.pop(0)
+name = "networkx"
+description = "Python package for creating and manipulating graphs and networks"
+authors = {
+ "Hagberg": ("Aric Hagberg", "hagberg@lanl.gov"),
+ "Schult": ("Dan Schult", "dschult@colgate.edu"),
+ "Swart": ("Pieter Swart", "swart@lanl.gov"),
+}
+maintainer = "NetworkX Developers"
+maintainer_email = "networkx-discuss@googlegroups.com"
+url = "https://networkx.org/"
+project_urls = {
+ "Bug Tracker": "https://github.com/networkx/networkx/issues",
+ "Documentation": "https://networkx.org/documentation/stable/",
+ "Source Code": "https://github.com/networkx/networkx",
+}
+platforms = ["Linux", "Mac OSX", "Windows", "Unix"]
+keywords = [
+ "Networks",
+ "Graph Theory",
+ "Mathematics",
+ "network",
+ "graph",
+ "discrete mathematics",
+ "math",
+]
+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.7",
+ "Programming Language :: Python :: 3.8",
+ "Programming Language :: Python :: 3.9",
+ "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",
+]
+
+with open("networkx/__init__.py") as fid:
+ for line in fid:
+ if line.startswith("__version__"):
+ version = line.strip().split()[-1][1:-1]
+ break
packages = [
"networkx",
@@ -126,7 +154,7 @@ package_data = {
def parse_requirements_file(filename):
- with open(filename, encoding="utf-8") as fid:
+ with open(filename) as fid:
requires = [l.strip() for l in fid.readlines() if l]
return requires
@@ -144,19 +172,19 @@ with open("README.rst", "r") as fh:
if __name__ == "__main__":
setup(
- name=release.name.lower(),
+ name=name,
version=version,
- maintainer=release.maintainer,
- maintainer_email=release.maintainer_email,
- author=release.authors["Hagberg"][0],
- author_email=release.authors["Hagberg"][1],
- description=release.description,
- keywords=release.keywords,
+ maintainer=maintainer,
+ maintainer_email=maintainer_email,
+ author=authors["Hagberg"][0],
+ author_email=authors["Hagberg"][1],
+ description=description,
+ keywords=keywords,
long_description=long_description,
- platforms=release.platforms,
- url=release.url,
- project_urls=release.project_urls,
- classifiers=release.classifiers,
+ platforms=platforms,
+ url=url,
+ project_urls=project_urls,
+ classifiers=classifiers,
packages=packages,
data_files=data,
package_data=package_data,