From 2be3319ac9ac7e2c8863f4ce6de36f85c071b02a Mon Sep 17 00:00:00 2001 From: Nolan Brubaker Date: Thu, 2 Mar 2017 11:45:21 -0500 Subject: [PATCH] Restructure lib directory to install via pip This change allows the currently existing modules to be imported from the `osa_toolkit` package. In order to install the python modules used by the inventory via setup.py with pbr, we need to rename the lib directory to match the name of the package we wish to install. pbr doesn't allow for doing any kind of directory renaming within the setup.{cfg,py} files, but we need to keep using it in order to consume global requirements updates. Change-Id: Idb7780f55e4a1fd77dd76becbf67c1ccbf220db7 --- {lib => osa_toolkit}/__init__.py | 0 {lib => osa_toolkit}/dictutils.py | 0 {lib => osa_toolkit}/filesystem.py | 0 {lib => osa_toolkit}/generate.py | 0 {lib => osa_toolkit}/ip.py | 0 {lib => osa_toolkit}/manage.py | 0 {lib => osa_toolkit}/tools.py | 0 playbooks/inventory/dynamic_inventory.py | 2 +- scripts/gen-config.py | 2 +- scripts/inventory-manage.py | 2 +- setup.cfg | 3 +++ tests/test_dictutils.py | 2 +- tests/test_filesystem.py | 2 +- tests/test_inventory.py | 2 +- tests/test_ip.py | 2 +- tests/test_manage.py | 2 +- tox.ini | 2 +- 17 files changed, 12 insertions(+), 9 deletions(-) rename {lib => osa_toolkit}/__init__.py (100%) rename {lib => osa_toolkit}/dictutils.py (100%) rename {lib => osa_toolkit}/filesystem.py (100%) rename {lib => osa_toolkit}/generate.py (100%) rename {lib => osa_toolkit}/ip.py (100%) rename {lib => osa_toolkit}/manage.py (100%) rename {lib => osa_toolkit}/tools.py (100%) diff --git a/lib/__init__.py b/osa_toolkit/__init__.py similarity index 100% rename from lib/__init__.py rename to osa_toolkit/__init__.py diff --git a/lib/dictutils.py b/osa_toolkit/dictutils.py similarity index 100% rename from lib/dictutils.py rename to osa_toolkit/dictutils.py diff --git a/lib/filesystem.py b/osa_toolkit/filesystem.py similarity index 100% rename from lib/filesystem.py rename to osa_toolkit/filesystem.py diff --git a/lib/generate.py b/osa_toolkit/generate.py similarity index 100% rename from lib/generate.py rename to osa_toolkit/generate.py diff --git a/lib/ip.py b/osa_toolkit/ip.py similarity index 100% rename from lib/ip.py rename to osa_toolkit/ip.py diff --git a/lib/manage.py b/osa_toolkit/manage.py similarity index 100% rename from lib/manage.py rename to osa_toolkit/manage.py diff --git a/lib/tools.py b/osa_toolkit/tools.py similarity index 100% rename from lib/tools.py rename to osa_toolkit/tools.py diff --git a/playbooks/inventory/dynamic_inventory.py b/playbooks/inventory/dynamic_inventory.py index 14f3d50c54..5eee369411 100755 --- a/playbooks/inventory/dynamic_inventory.py +++ b/playbooks/inventory/dynamic_inventory.py @@ -20,7 +20,7 @@ import os import sys current_path = os.path.abspath(os.path.dirname(os.path.realpath(__file__))) -lib_path = os.path.join(current_path, '..', '..', 'lib') +lib_path = os.path.join(current_path, '..', '..', 'osa_toolkit') sys.path.append(lib_path) import generate diff --git a/scripts/gen-config.py b/scripts/gen-config.py index c222c8d75d..dab9d06b09 100755 --- a/scripts/gen-config.py +++ b/scripts/gen-config.py @@ -20,7 +20,7 @@ import os import sys cwd = os.path.abspath(os.path.dirname(__file__)) -import_path = os.path.join(cwd, '..', 'lib') +import_path = os.path.join(cwd, '..', 'osa_toolkit') sys.path.append(import_path) import tools diff --git a/scripts/inventory-manage.py b/scripts/inventory-manage.py index 305ad82666..dd2ed5561a 100755 --- a/scripts/inventory-manage.py +++ b/scripts/inventory-manage.py @@ -27,7 +27,7 @@ import os import sys cwd = os.path.abspath(os.path.dirname(__file__)) -import_path = os.path.join(cwd, '..', 'lib') +import_path = os.path.join(cwd, '..', 'osa_toolkit') sys.path.append(import_path) import manage diff --git a/setup.cfg b/setup.cfg index bfa3c570fc..5f614d43d4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -22,3 +22,6 @@ warnerrors = True [wheel] universal = 1 + +[files] +packages = osa_toolkit diff --git a/tests/test_dictutils.py b/tests/test_dictutils.py index c99a232d91..7568ab1b6e 100644 --- a/tests/test_dictutils.py +++ b/tests/test_dictutils.py @@ -17,7 +17,7 @@ from os import path import sys import unittest -LIB_DIR = 'lib' +LIB_DIR = 'osa_toolkit' sys.path.append(path.join(os.getcwd(), LIB_DIR)) diff --git a/tests/test_filesystem.py b/tests/test_filesystem.py index 460ea7bbf7..4ce0176657 100644 --- a/tests/test_filesystem.py +++ b/tests/test_filesystem.py @@ -24,7 +24,7 @@ from test_inventory import get_inventory from test_inventory import make_config INV_DIR = 'playbooks/inventory' -LIB_DIR = 'lib' +LIB_DIR = 'osa_toolkit' sys.path.append(path.join(os.getcwd(), LIB_DIR)) sys.path.append(path.join(os.getcwd(), INV_DIR)) diff --git a/tests/test_inventory.py b/tests/test_inventory.py index c524965cff..017c3849ee 100644 --- a/tests/test_inventory.py +++ b/tests/test_inventory.py @@ -23,7 +23,7 @@ import warnings import yaml INV_DIR = 'playbooks/inventory' -LIB_DIR = 'lib' +LIB_DIR = 'osa_toolkit' sys.path.append(path.join(os.getcwd(), LIB_DIR)) sys.path.append(path.join(os.getcwd(), INV_DIR)) diff --git a/tests/test_ip.py b/tests/test_ip.py index c81bb1b4dd..b80011c743 100644 --- a/tests/test_ip.py +++ b/tests/test_ip.py @@ -17,7 +17,7 @@ from os import path import sys import unittest -LIB_DIR = path.join(os.getcwd(), 'lib') +LIB_DIR = path.join(os.getcwd(), 'osa_toolkit') sys.path.append(LIB_DIR) diff --git a/tests/test_manage.py b/tests/test_manage.py index b5831ab94c..0d05445aa9 100644 --- a/tests/test_manage.py +++ b/tests/test_manage.py @@ -18,7 +18,7 @@ import sys import test_inventory import unittest -MANAGE_DIR = path.join(os.getcwd(), 'lib') +MANAGE_DIR = path.join(os.getcwd(), 'osa_toolkit') TARGET_DIR = path.join(os.getcwd(), 'tests', 'inventory') sys.path.append(MANAGE_DIR) diff --git a/tox.ini b/tox.ini index 37dcf123c0..435af40947 100644 --- a/tox.ini +++ b/tox.ini @@ -154,7 +154,7 @@ commands = coverage run -a {toxinidir}/tests/test_dictutils.py coverage run -a {toxinidir}/tests/test_ip.py coverage run -a {toxinidir}/tests/test_filesystem.py - coverage report --show-missing --include={toxinidir}/playbooks/inventory/*,{toxinidir}/lib/* + coverage report --show-missing --include={toxinidir}/playbooks/inventory/*,{toxinidir}/osa_toolkit/* [testenv:linters]