Skip to content

Commit

Permalink
version 1.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
aabouzaid committed Oct 8, 2017
2 parents ded1b20 + 29f0002 commit ed3e51a
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 6 deletions.
5 changes: 2 additions & 3 deletions .travis.yml
Expand Up @@ -5,10 +5,9 @@ python:
- "3.5"
cache: pip
install:
- pip install -e .
- pip install -e .[tests]
- python setup.py requirements -t
script:
- pep8 -v --ignore=E501 .
- py.test --cov=netbox
- python setup.py test -a "--cov=netbox"
after_success:
coveralls
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
1.0.5
1.0.6
82 changes: 80 additions & 2 deletions setup.py
Expand Up @@ -5,9 +5,13 @@
# setup.py file is part of Netbox dynamic inventory script.
# https://github.com/AAbouZaid/netbox-as-ansible-inventory

from setuptools import setup
from setuptools.command.install import install as InstallCommand
from setuptools.command.test import test as TestCommand
from setuptools import setup, Command
from codecs import open as openc
from os import path
import subprocess
import sys


def open_file(file_name, splitlines=False):
Expand All @@ -26,14 +30,83 @@ def open_file(file_name, splitlines=False):
main_requirements = open_file('requirements.txt', splitlines=True)
tests_requirements = open_file('tests/requirements.txt', splitlines=True)


class PyTest(TestCommand):
""" Run tests. """

user_options = [('pytest-args=', 'a', "Arguments to pass to pytest")]

def initialize_options(self):
TestCommand.initialize_options(self)
self.pytest_args = []

def run_tests(self):
import pytest
errno = pytest.main(self.pytest_args)
sys.exit(errno)


class Release(Command):
""" Tag, push, and upload to PyPI. """

user_options = []

def initialize_options(self):
pass

def finalize_options(self):
pass

def run(self):
# Create Git tag.
tag_name = 'v%s' % version
cmd = ['git', 'tag', '-a', tag_name, '-m', 'version %s' % version]
print(' '.join(cmd))
subprocess.check_call(cmd)

# Push Git tag to origin remote.
cmd = ['git', 'push', 'origin', tag_name]
print(' '.join(cmd))
subprocess.check_call(cmd)

# Push branch to origin remote.
cmd = ['git', 'push', 'origin', 'master']
print(' '.join(cmd))
subprocess.check_call(cmd)

# Upload package to PyPI.
cmd = ['python', 'setup.py', 'sdist', 'upload']
print(' '.join(cmd))
subprocess.check_call(cmd)


class Requirements(Command):
""" Install requirements. """

user_options = [('tests-requirement', 't', "Install requirements for unit test.")]

def initialize_options(self):
self.tests_requirement = False

def finalize_options(self):
pass

def run(self):
import pip

# Install requirements via pip.
pip.main(['install', '.'])
if self.tests_requirement:
pip.main(['install', '.[tests]'])

setup(
name='ansible-netbox-inventory',
version=version,
description='Ansible dynamic inventory script for Netbox',
long_description=long_description,
url='https://github.com/AAbouZaid/netbox-as-ansible-inventory',
author='Ahmed AbouZaid',
author_email='@'.join(("ahmed.m", "aabouzaid.com")), # To avoid spam,
author_email='@'.join(("ahmed.m", "aabouzaid.com")), # To avoid spam.
license='GPLv3',
classifiers=[
'Environment :: Console',
Expand All @@ -59,4 +132,9 @@ def open_file(file_name, splitlines=False):
extras_require={
'tests': tests_requirements,
},
cmdclass={
'test': PyTest,
'release': Release,
'requirements': Requirements,
},
)

0 comments on commit ed3e51a

Please sign in to comment.