Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packaging #288

Merged
merged 26 commits into from
Dec 30, 2018
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4fdb7bd
remove redundant 'templates/*' - these files are covered by package_d…
micahculpepper Nov 13, 2018
d67f01f
declare package_data files explicitly
micahculpepper Nov 13, 2018
7adcc41
delete red herring comment
micahculpepper Nov 13, 2018
39c83ed
stop messing with symlinks - they are not needed
micahculpepper Nov 13, 2018
bd874d6
remove unused imports
micahculpepper Nov 13, 2018
3096f33
ln -s ntc_templates/templates ../templates
micahculpepper Nov 13, 2018
71038c7
simplify version number gathering
micahculpepper Nov 13, 2018
96ae5a9
simplify file finding
micahculpepper Nov 13, 2018
4550d51
whitespace
micahculpepper Nov 13, 2018
64004e9
document that we are zip-unsafe because we operate on real file paths
micahculpepper Nov 13, 2018
331e9cb
delete redundant comment
micahculpepper Nov 13, 2018
9d76879
revert version-identification change. See discussion on https://githu…
micahculpepper Nov 19, 2018
9758af6
remove redundant 'templates/*' - these files are covered by package_d…
micahculpepper Nov 13, 2018
230c91b
declare package_data files explicitly
micahculpepper Nov 13, 2018
c3ee4c2
delete red herring comment
micahculpepper Nov 13, 2018
d02e8a3
stop messing with symlinks - they are not needed
micahculpepper Nov 13, 2018
33fdebf
remove unused imports
micahculpepper Nov 13, 2018
fb7d1cc
ln -s ntc_templates/templates ../templates
micahculpepper Nov 13, 2018
045da6a
simplify version number gathering
micahculpepper Nov 13, 2018
a37cea6
simplify file finding
micahculpepper Nov 13, 2018
c55c36a
whitespace
micahculpepper Nov 13, 2018
a8ff0d4
document that we are zip-unsafe because we operate on real file paths
micahculpepper Nov 13, 2018
f507127
delete redundant comment
micahculpepper Nov 13, 2018
7a01331
revert version-identification change. See discussion on https://githu…
micahculpepper Nov 19, 2018
1c00ec0
Merge branch 'packaging' of github.com:micahculpepper/ntc-templates i…
micahculpepper Nov 19, 2018
1a9a06e
Merge branch 'master' into packaging
micahculpepper Nov 20, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include README.md HISTORY.rst templates/*
include README.md HISTORY.rst
8 changes: 2 additions & 6 deletions ntc_templates/parse.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
1 change: 1 addition & 0 deletions ntc_templates/templates
35 changes: 5 additions & 30 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,20 @@
"""setup.py file."""
import re
from ntc_templates import __version__
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:
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()

with open('HISTORY.rst', 'r', 'utf-8') as f:
history = f.read()


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'):
shutil.rmtree('ntc_templates/templates')

os.symlink('../templates', 'ntc_templates/templates')
config = {
'name': 'ntc_templates',
# 'package_dir': {'': 'lib'},
'packages': ['ntc_templates'],
'version': version,
'package_data': {'ntc_templates': template_files},
'version': __version__,
'package_data': {'ntc_templates': ['templates/*']},
'description': 'Package to return structured data from the output of network devices.',
'long_description': long_description,
'author': 'network.toCode()',
Expand All @@ -50,10 +27,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)

if os.path.islink('ntc_templates/templates'):
os.unlink('ntc_templates/templates')