]> Frank Brehm's Git Trees - pixelpark/create-terraform.git/commitdiff
Adding setupo stuff
authorFrank Brehm <frank.brehm@pixelpark.com>
Tue, 24 Sep 2019 16:03:03 +0000 (18:03 +0200)
committerFrank Brehm <frank.brehm@pixelpark.com>
Tue, 24 Sep 2019 16:03:03 +0000 (18:03 +0200)
.gitignore
requirements.txt
setup.cfg [new file with mode: 0644]
setup.py [new file with mode: 0644]

index f26d1f960a78b769bf5fab1018867e3139d1652f..488ca6c799ee038cf036d60029efdeaa56028da1 100644 (file)
@@ -21,3 +21,5 @@ etc/*.ini
 *.backup
 .idea
 .vscode
+build
+dist
index a9d1722c2b428773b9fb5ed2363796e92a43ede5..87e9a98925c5e637e044be37adcc2abaedf57e0e 100644 (file)
@@ -1,5 +1,4 @@
 pip
-ansible
 babel
 PyYAML
 pyvmomi>=v6.5.0.2017.5-1
@@ -9,7 +8,5 @@ pytz
 paramiko
 dnspython
 flake8
-docker-py
-pathlib
 setuptools
 git+https://git.pixelpark.com/python/python_fb_tools.git@master
diff --git a/setup.cfg b/setup.cfg
new file mode 100644 (file)
index 0000000..881857a
--- /dev/null
+++ b/setup.cfg
@@ -0,0 +1,55 @@
+[metadata]
+name = create-terraform
+description = A Tool for creating a terraform project based on a YAML file for provisioning virtual machines. 
+author = Frank Brehm
+author_email = frank.brehm@pixelpark.com
+url = https://git.pixelpark.com/ppadmin/create-terraform
+license = LGPL3+
+platforms = posix
+provides = create_terraform
+classifiers =
+    Development Status :: 3 - Alpha
+    Environment :: Console
+    Intended Audience :: System Administrators 
+    License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
+    Natural Language :: English
+    Natural Language :: German
+    Operating System :: POSIX :: Linux
+    Programming Language :: Python :: 3.5
+    Programming Language :: Python :: 3.6
+    Programming Language :: Python :: 3.7
+    Topic :: System :: Systems Administration 
+
+[options]
+package_dir=
+    =lib
+
+install_requires =
+    requests
+    Babel
+    PyYAML
+    pyvmomi
+    six
+    pytz
+    dnspython
+    fb_tools
+
+setup_requires =
+    Babel
+    six
+
+packages=find:
+
+[options.packages.find]
+where=lib
+
+[compile_catalog]
+domain = create_terraform
+directory = locale
+statistics = 1
+
+[pep8]
+
+max-line-length = 99
+
+# vim: filetype=dosini
diff --git a/setup.py b/setup.py
new file mode 100644 (file)
index 0000000..04fa929
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,168 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+"""
+@author: Frank Brehm
+@contact: frank.brehm@pixelpark.com
+@license: LGPL3+
+@copyright: © 2019 Frank Brehm, Berlin
+@summary: A Tool for creating a terraform project based on a YAML file for provisioning virtual machines.
+"""
+
+import os
+import sys
+import re
+import pprint
+import datetime
+import textwrap
+import glob
+import pathlib
+import subprocess
+
+# Third party modules
+from setuptools import setup
+from setuptools.command.install import install
+
+# own modules:
+__base_dir__ = os.path.abspath(os.path.dirname(__file__))
+__bin_dir__ = os.path.join(__base_dir__, 'bin')
+__lib_dir__ = os.path.join(__base_dir__, 'lib')
+__module_dir__ = os.path.join(__lib_dir__, 'cr_tf')
+__init_py__ = os.path.join(__module_dir__, '__init__.py')
+
+PATHS = {
+    '__base_dir__': __base_dir__,
+    '__bin_dir__': __bin_dir__,
+    '__lib_dir__': __lib_dir__,
+    '__module_dir__': __module_dir__,
+    '__init_py__': __init_py__,
+}
+
+# -----------------------------------
+def pp(obj):
+    pprinter = pprint.PrettyPrinter(indent=4)
+    return pprinter.pformat(obj)
+
+#print("Paths:\n{}".format(pp(PATHS)))
+
+if os.path.exists(__module_dir__) and os.path.isfile(__init_py__):
+    sys.path.insert(0, os.path.abspath(__lib_dir__))
+
+import cr_tf
+
+ENCODING = "utf-8"
+
+__packet_version__ = cr_tf.__version__
+
+__packet_name__ = 'create_terraform'
+
+__author__ = 'Frank Brehm'
+__contact__ = 'frank.brehm@pixelpark.com'
+__copyright__ = '(C) 2019 Frank Brehm, Pixelpark GmbH, Berlin'
+__license__ = 'LGPL3+'
+__url__ = 'https://git.pixelpark.com/ppadmin/create-terraform'
+
+
+__open_args__ = {}
+if sys.version_info[0] >= 3:
+    __open_args__ = {'encoding': ENCODING, 'errors': 'surrogateescape'}
+
+# -----------------------------------
+def read(fname):
+
+    content = None
+
+    if sys.version_info[0] < 3:
+        with open(fname, 'r') as fh:
+            content = fh.read()
+    else:
+        with open(fname, 'r', **__open_args__) as fh:
+            content = fh.read()
+
+    return content
+
+
+# -----------------------------------
+def is_python_file(filename):
+    if filename.endswith('.py'):
+        return True
+    else:
+        return False
+
+# -----------------------------------
+__requirements__ = [
+    'argparse',
+    'fb_tools',
+    'six'
+]
+
+# -----------------------------------
+def read_requirements():
+
+    req_file = os.path.join(__base_dir__, 'requirements.txt')
+    if not os.path.isfile(req_file):
+        return
+
+    f_content = read(req_file)
+    if not f_content:
+        return
+
+    re_comment = re.compile(r'\s*#.*')
+    re_gitrepo = re.compile(r'^(git@|(git\+)?https?://)', re.IGNORECASE)
+    re_module = re.compile(r'([a-z][a-z0-9_]*[a-z0-9])', re.IGNORECASE)
+
+    for line in f_content.splitlines():
+        line = line.strip()
+        line = re_comment.sub('', line)
+        if not line:
+            continue
+        if re_gitrepo.match(line):
+            continue
+        match = re_module.search(line)
+        if not match:
+            continue
+        module = match.group(1)
+        if module not in __requirements__:
+            __requirements__.append(module)
+
+    # print("Found required modules: {}\n".format(pp(__requirements__)))
+
+read_requirements()
+
+# -----------------------------------
+__scripts__ = [
+    'bin/create-terraform'
+]
+
+# -----------------------------------
+MO_FILES = 'locale/*/LC_MESSAGES/*.mo'
+PO_FILES = 'locale/*/LC_MESSAGES/*.po'
+
+def create_mo_files():
+    mo_files = []
+    for po_path in glob.glob(PO_FILES):
+        mo = pathlib.Path(po_path.replace('.po', '.mo'))
+        if not mo.exists():
+            subprocess.call(['msgfmt', '-o', str(mo), po_path])
+        mo_files.append(str(mo))
+
+    # print("Found mo files: {}\n".format(pp(mo_files)))
+    return mo_files
+
+
+# -----------------------------------
+setup(
+    version=__packet_version__,
+    long_description=read('README.md'),
+    scripts=__scripts__,
+    requires=__requirements__,
+    package_dir={'': 'lib'},
+    package_data = {
+        '': create_mo_files(),
+    },
+)
+
+
+# =======================================================================
+
+# vim: fileencoding=utf-8 filetype=python ts=4 expandtab