From 4fdb7bdf06f0a92a8916089473ebb02ad319152c Mon Sep 17 00:00:00 2001 From: Micah Culpepper Date: Tue, 13 Nov 2018 10:54:27 -0600 Subject: [PATCH 01/24] remove redundant 'templates/*' - these files are covered by package_data in setup.py --- MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index eb83332d83..5f2e8443d2 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1 @@ -include README.md HISTORY.rst templates/* +include README.md HISTORY.rst From d67f01f1d243fc3e9af6b4bb81516363d84804e1 Mon Sep 17 00:00:00 2001 From: Micah Culpepper Date: Tue, 13 Nov 2018 10:55:20 -0600 Subject: [PATCH 02/24] declare package_data files explicitly --- setup.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/setup.py b/setup.py index d1370e0495..63c1c7a8f5 100644 --- a/setup.py +++ b/setup.py @@ -23,9 +23,6 @@ long_description = readme + '\n\n' + history - -template_files = glob('templates/*') - if os.path.islink('ntc_templates/templates'): os.unlink('ntc_templates/templates') elif os.path.isdir('ntc_templates/templates'): @@ -37,7 +34,7 @@ # 'package_dir': {'': 'lib'}, 'packages': ['ntc_templates'], 'version': version, - 'package_data': {'ntc_templates': template_files}, + 'package_data': {'ntc_templates': ['templates/*']}, 'description': 'Package to return structured data from the output of network devices.', 'long_description': long_description, 'author': 'network.toCode()', From 7adcc41a661f182b5aeeb16854954dd0c43600d5 Mon Sep 17 00:00:00 2001 From: Micah Culpepper Date: Tue, 13 Nov 2018 11:05:49 -0600 Subject: [PATCH 03/24] delete red herring comment --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index 63c1c7a8f5..30164b9d68 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,6 @@ os.symlink('../templates', 'ntc_templates/templates') config = { 'name': 'ntc_templates', - # 'package_dir': {'': 'lib'}, 'packages': ['ntc_templates'], 'version': version, 'package_data': {'ntc_templates': ['templates/*']}, From 39c83ed629e47eb666f13abfbb355c935591c02d Mon Sep 17 00:00:00 2001 From: Micah Culpepper Date: Tue, 13 Nov 2018 11:08:09 -0600 Subject: [PATCH 04/24] stop messing with symlinks - they are not needed --- setup.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/setup.py b/setup.py index 30164b9d68..cae6ec76d2 100644 --- a/setup.py +++ b/setup.py @@ -23,12 +23,6 @@ long_description = readme + '\n\n' + history -if os.path.islink('ntc_templates/templates'): - os.unlink('ntc_templates/templates') -elif os.path.isdir('ntc_templates/templates'): - shutil.rmtree('ntc_templates/templates') - -os.symlink('../templates', 'ntc_templates/templates') config = { 'name': 'ntc_templates', 'packages': ['ntc_templates'], @@ -50,6 +44,3 @@ } setup(**config) - -if os.path.islink('ntc_templates/templates'): - os.unlink('ntc_templates/templates') From bd874d6d9a2fdbd6bf899c926870b499c995ac54 Mon Sep 17 00:00:00 2001 From: Micah Culpepper Date: Tue, 13 Nov 2018 11:08:26 -0600 Subject: [PATCH 05/24] remove unused imports --- setup.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/setup.py b/setup.py index cae6ec76d2..9664d43c22 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,7 @@ """setup.py file.""" import re from codecs import open -from glob import glob from setuptools import setup -import os -import shutil version = '' with open('ntc_templates/__init__.py', 'r') as fd: From 3096f331f972c60bd677e8940fde9faa75f895fd Mon Sep 17 00:00:00 2001 From: Micah Culpepper Date: Tue, 13 Nov 2018 11:22:33 -0600 Subject: [PATCH 06/24] ln -s ntc_templates/templates ../templates --- ntc_templates/templates | 1 + 1 file changed, 1 insertion(+) create mode 120000 ntc_templates/templates diff --git a/ntc_templates/templates b/ntc_templates/templates new file mode 120000 index 0000000000..564a409d41 --- /dev/null +++ b/ntc_templates/templates @@ -0,0 +1 @@ +../templates \ No newline at end of file From 71038c72f5e2677f106d80e4aa01b1e6022fe4f0 Mon Sep 17 00:00:00 2001 From: Micah Culpepper Date: Tue, 13 Nov 2018 11:24:35 -0600 Subject: [PATCH 07/24] simplify version number gathering --- setup.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/setup.py b/setup.py index 9664d43c22..e18dbec780 100644 --- a/setup.py +++ b/setup.py @@ -1,16 +1,8 @@ """setup.py file.""" -import re +from ntc_templates import __version__ from codecs import open from setuptools import setup -version = '' -with open('ntc_templates/__init__.py', 'r') as fd: - version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', - fd.read(), re.MULTILINE).group(1) - -if not version: - raise RuntimeError('Cannot find version information') - with open('README.md', 'r', 'utf-8') as f: readme = f.read() @@ -23,7 +15,7 @@ config = { 'name': 'ntc_templates', 'packages': ['ntc_templates'], - 'version': version, + 'version': __version__, 'package_data': {'ntc_templates': ['templates/*']}, 'description': 'Package to return structured data from the output of network devices.', 'long_description': long_description, From 96ae5a906c13c266c145a4c49f4d52902b06708d Mon Sep 17 00:00:00 2001 From: Micah Culpepper Date: Tue, 13 Nov 2018 11:25:34 -0600 Subject: [PATCH 08/24] simplify file finding --- ntc_templates/parse.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ntc_templates/parse.py b/ntc_templates/parse.py index b96d9dc17b..4c7c3a9205 100644 --- a/ntc_templates/parse.py +++ b/ntc_templates/parse.py @@ -1,15 +1,11 @@ """ntc_templates.parse.""" -import os -import sys +import pkg_resources from textfsm.clitable import CliTableError import textfsm.clitable as clitable def _get_template_dir(): - ntc_template_abspath = os.path.abspath(sys.modules['ntc_templates'].__file__) - base_dir = os.path.dirname(ntc_template_abspath) - template_dir = '%s%s%s' % (base_dir, os.sep, 'templates') - return template_dir + return pkg_resources.resource_filename("ntc_templates", "templates") def _clitable_to_dict(cli_table): From 4550d51bd0d22ed78127ff088f9617582e4e9aa1 Mon Sep 17 00:00:00 2001 From: Micah Culpepper Date: Tue, 13 Nov 2018 11:26:19 -0600 Subject: [PATCH 09/24] whitespace --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index e18dbec780..5d3a2d619a 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,6 @@ with open('HISTORY.rst', 'r', 'utf-8') as f: history = f.read() - long_description = readme + '\n\n' + history config = { From 64004e968fda7d1b9a697acfdaae1486fae94e05 Mon Sep 17 00:00:00 2001 From: Micah Culpepper Date: Tue, 13 Nov 2018 11:52:35 -0600 Subject: [PATCH 10/24] document that we are zip-unsafe because we operate on real file paths --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 5d3a2d619a..3c78a46acd 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,8 @@ 'classifiers': ['Development Status :: 4 - Beta', 'Intended Audience :: Developers', 'Intended Audience :: System Administrators', - 'Programming Language :: Python :: 2.7'] + 'Programming Language :: Python :: 2.7'], + 'zip_safe': False } setup(**config) From 331e9cb03cbcab67e95f07db5c16b77201c0fa1f Mon Sep 17 00:00:00 2001 From: Micah Culpepper Date: Tue, 13 Nov 2018 11:53:13 -0600 Subject: [PATCH 11/24] delete redundant comment --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index 3c78a46acd..cb1c190574 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,3 @@ -"""setup.py file.""" from ntc_templates import __version__ from codecs import open from setuptools import setup From 9d768799b16710d5a098680797099dfa39e80ccb Mon Sep 17 00:00:00 2001 From: Micah Culpepper Date: Mon, 19 Nov 2018 08:24:52 -0600 Subject: [PATCH 12/24] revert version-identification change. See discussion on https://github.com/networktocode/ntc-templates/pull/288 --- setup.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index cb1c190574..73e37f38eb 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,15 @@ -from ntc_templates import __version__ +import re from codecs import open from setuptools import setup +version = '' +with open('ntc_templates/__init__.py', 'r') as fd: + version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + with open('README.md', 'r', 'utf-8') as f: readme = f.read() @@ -13,7 +21,7 @@ config = { 'name': 'ntc_templates', 'packages': ['ntc_templates'], - 'version': __version__, + 'version': version, 'package_data': {'ntc_templates': ['templates/*']}, 'description': 'Package to return structured data from the output of network devices.', 'long_description': long_description, From 9758af6fa4a0d44eb03c1e8a05980c297d8f0407 Mon Sep 17 00:00:00 2001 From: Micah Culpepper Date: Tue, 13 Nov 2018 10:54:27 -0600 Subject: [PATCH 13/24] remove redundant 'templates/*' - these files are covered by package_data in setup.py --- MANIFEST.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MANIFEST.in b/MANIFEST.in index eb83332d83..5f2e8443d2 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1 +1 @@ -include README.md HISTORY.rst templates/* +include README.md HISTORY.rst From 230c91bdb5f00d29fda9754bdfe5be67d626f80c Mon Sep 17 00:00:00 2001 From: Micah Culpepper Date: Tue, 13 Nov 2018 10:55:20 -0600 Subject: [PATCH 14/24] declare package_data files explicitly --- setup.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/setup.py b/setup.py index 97914da9bd..31a0535d3c 100644 --- a/setup.py +++ b/setup.py @@ -23,9 +23,6 @@ long_description = readme + '\n\n' + history - -template_files = glob('templates/*') - if os.path.islink('ntc_templates/templates'): os.unlink('ntc_templates/templates') elif os.path.isdir('ntc_templates/templates'): @@ -37,7 +34,7 @@ # 'package_dir': {'': 'lib'}, 'packages': ['ntc_templates'], 'version': version, - 'package_data': {'ntc_templates': template_files}, + 'package_data': {'ntc_templates': ['templates/*']}, 'description': 'Package to return structured data from the output of network devices.', 'long_description': long_description, 'author': 'network.toCode()', From c3ee4c234b5c3ceed8de616df10d0cb32d8ca246 Mon Sep 17 00:00:00 2001 From: Micah Culpepper Date: Tue, 13 Nov 2018 11:05:49 -0600 Subject: [PATCH 15/24] delete red herring comment --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index 31a0535d3c..9c24f830ec 100644 --- a/setup.py +++ b/setup.py @@ -31,7 +31,6 @@ os.symlink('../templates', 'ntc_templates/templates') config = { 'name': 'ntc_templates', - # 'package_dir': {'': 'lib'}, 'packages': ['ntc_templates'], 'version': version, 'package_data': {'ntc_templates': ['templates/*']}, From d02e8a39cda57851497e1677b6e4bb496828fe00 Mon Sep 17 00:00:00 2001 From: Micah Culpepper Date: Tue, 13 Nov 2018 11:08:09 -0600 Subject: [PATCH 16/24] stop messing with symlinks - they are not needed --- setup.py | 9 --------- 1 file changed, 9 deletions(-) diff --git a/setup.py b/setup.py index 9c24f830ec..5db2a72c7f 100644 --- a/setup.py +++ b/setup.py @@ -23,12 +23,6 @@ long_description = readme + '\n\n' + history -if os.path.islink('ntc_templates/templates'): - os.unlink('ntc_templates/templates') -elif os.path.isdir('ntc_templates/templates'): - shutil.rmtree('ntc_templates/templates') - -os.symlink('../templates', 'ntc_templates/templates') config = { 'name': 'ntc_templates', 'packages': ['ntc_templates'], @@ -50,6 +44,3 @@ } setup(**config) - -if os.path.islink('ntc_templates/templates'): - os.unlink('ntc_templates/templates') From 33fdebf918f9f7baf99cf1d2177ea3c56d99200d Mon Sep 17 00:00:00 2001 From: Micah Culpepper Date: Tue, 13 Nov 2018 11:08:26 -0600 Subject: [PATCH 17/24] remove unused imports --- setup.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/setup.py b/setup.py index 5db2a72c7f..0cbeb57935 100644 --- a/setup.py +++ b/setup.py @@ -1,10 +1,7 @@ """setup.py file.""" import re from codecs import open -from glob import glob from setuptools import setup -import os -import shutil version = '' with open('ntc_templates/__init__.py', 'r') as fd: From fb7d1ccda07a88ccc07dba623cfeb4d034ecfd9f Mon Sep 17 00:00:00 2001 From: Micah Culpepper Date: Tue, 13 Nov 2018 11:22:33 -0600 Subject: [PATCH 18/24] ln -s ntc_templates/templates ../templates --- ntc_templates/templates | 1 + 1 file changed, 1 insertion(+) create mode 120000 ntc_templates/templates diff --git a/ntc_templates/templates b/ntc_templates/templates new file mode 120000 index 0000000000..564a409d41 --- /dev/null +++ b/ntc_templates/templates @@ -0,0 +1 @@ +../templates \ No newline at end of file From 045da6a094416091fe6c52f8bccd18a1ee7d80a5 Mon Sep 17 00:00:00 2001 From: Micah Culpepper Date: Tue, 13 Nov 2018 11:24:35 -0600 Subject: [PATCH 19/24] simplify version number gathering --- setup.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/setup.py b/setup.py index 0cbeb57935..0fbb240bb1 100644 --- a/setup.py +++ b/setup.py @@ -1,16 +1,8 @@ """setup.py file.""" -import re +from ntc_templates import __version__ from codecs import open from setuptools import setup -version = '' -with open('ntc_templates/__init__.py', 'r') as fd: - version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', - fd.read(), re.MULTILINE).group(1) - -if not version: - raise RuntimeError('Cannot find version information') - with open('README.md', 'r', 'utf-8') as f: readme = f.read() @@ -23,7 +15,7 @@ config = { 'name': 'ntc_templates', 'packages': ['ntc_templates'], - 'version': version, + 'version': __version__, 'package_data': {'ntc_templates': ['templates/*']}, 'description': 'Package to return structured data from the output of network devices.', 'long_description': long_description, From a37cea6ec432e6a7f5b5353dcf9c57e3336d73fa Mon Sep 17 00:00:00 2001 From: Micah Culpepper Date: Tue, 13 Nov 2018 11:25:34 -0600 Subject: [PATCH 20/24] simplify file finding --- ntc_templates/parse.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ntc_templates/parse.py b/ntc_templates/parse.py index b96d9dc17b..4c7c3a9205 100644 --- a/ntc_templates/parse.py +++ b/ntc_templates/parse.py @@ -1,15 +1,11 @@ """ntc_templates.parse.""" -import os -import sys +import pkg_resources from textfsm.clitable import CliTableError import textfsm.clitable as clitable def _get_template_dir(): - ntc_template_abspath = os.path.abspath(sys.modules['ntc_templates'].__file__) - base_dir = os.path.dirname(ntc_template_abspath) - template_dir = '%s%s%s' % (base_dir, os.sep, 'templates') - return template_dir + return pkg_resources.resource_filename("ntc_templates", "templates") def _clitable_to_dict(cli_table): From c55c36ad38c0a0724f4dc09591f8dc640b0a2eea Mon Sep 17 00:00:00 2001 From: Micah Culpepper Date: Tue, 13 Nov 2018 11:26:19 -0600 Subject: [PATCH 21/24] whitespace --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index 0fbb240bb1..4ae211e595 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,6 @@ with open('HISTORY.rst', 'r', 'utf-8') as f: history = f.read() - long_description = readme + '\n\n' + history config = { From a8ff0d414aa1822af8301ce83e1824ba0f64c0eb Mon Sep 17 00:00:00 2001 From: Micah Culpepper Date: Tue, 13 Nov 2018 11:52:35 -0600 Subject: [PATCH 22/24] document that we are zip-unsafe because we operate on real file paths --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 4ae211e595..80b81141d8 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,8 @@ 'classifiers': ['Development Status :: 4 - Beta', 'Intended Audience :: Developers', 'Intended Audience :: System Administrators', - 'Programming Language :: Python :: 2.7'] + 'Programming Language :: Python :: 2.7'], + 'zip_safe': False } setup(**config) From f5071275fad10511ee3904dd4ab4700eb2d0c6bb Mon Sep 17 00:00:00 2001 From: Micah Culpepper Date: Tue, 13 Nov 2018 11:53:13 -0600 Subject: [PATCH 23/24] delete redundant comment --- setup.py | 1 - 1 file changed, 1 deletion(-) diff --git a/setup.py b/setup.py index 80b81141d8..3ad197f687 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,3 @@ -"""setup.py file.""" from ntc_templates import __version__ from codecs import open from setuptools import setup From 7a0133121ebd2abf89d531e95e867328f9f78b18 Mon Sep 17 00:00:00 2001 From: Micah Culpepper Date: Mon, 19 Nov 2018 08:24:52 -0600 Subject: [PATCH 24/24] revert version-identification change. See discussion on https://github.com/networktocode/ntc-templates/pull/288 --- setup.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 3ad197f687..dae9e7919f 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,15 @@ -from ntc_templates import __version__ +import re from codecs import open from setuptools import setup +version = '' +with open('ntc_templates/__init__.py', 'r') as fd: + version = re.search(r'^__version__\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + with open('README.md', 'r', 'utf-8') as f: readme = f.read() @@ -13,7 +21,7 @@ config = { 'name': 'ntc_templates', 'packages': ['ntc_templates'], - 'version': __version__, + 'version': version, 'package_data': {'ntc_templates': ['templates/*']}, 'description': 'Package to return structured data from the output of network devices.', 'long_description': long_description,