diff --git a/osbuild.py b/osbuild/__init__.py similarity index 100% rename from osbuild.py rename to osbuild/__init__.py diff --git a/osbuild b/osbuild/executable.py similarity index 87% rename from osbuild rename to osbuild/executable.py index 91c2f5a1..841b3b6a 100755 --- a/osbuild +++ b/osbuild/executable.py @@ -1,11 +1,8 @@ -#!/usr/bin/python3 - import argparse import json import os -import osbuild -import subprocess import sys +import osbuild RESET = "\033[0m" @@ -13,7 +10,7 @@ BOLD = "\033[1m" RED = "\033[31m" -if __name__ == "__main__": +def main(): parser = argparse.ArgumentParser(description="Build operating system images") parser.add_argument("pipeline_path", metavar="PIPELINE", help="json file containing the pipeline that should be built") @@ -22,7 +19,7 @@ if __name__ == "__main__": help="the directory where intermediary os trees are stored") requiredNamed = parser.add_argument_group('required named arguments') requiredNamed.add_argument("-o", "--output", dest="output_dir", metavar="DIRECTORY", type=os.path.abspath, - help="provide the empty DIRECTORY as output argument to the last stage", required=True) + help="provide the empty DIRECTORY as output argument to the last stage", required=True) args = parser.parse_args() with open(args.pipeline_path) as f: diff --git a/setup.py b/setup.py index fe569e0d..22426541 100644 --- a/setup.py +++ b/setup.py @@ -1,4 +1,3 @@ - import glob import setuptools @@ -6,11 +5,13 @@ setuptools.setup( name="osbuild", version="1", description="A build system for OS images", - py_modules=["osbuild"], + packages=["osbuild"], + entry_points={ + "console_scripts": ["osbuild = osbuild.executable:main"] + }, data_files=[ - ("/usr/bin", ["osbuild"]), ("/usr/lib/osbuild", ["osbuild-run"]), ("/usr/lib/osbuild/stages", glob.glob("./stages/*")), ("/usr/lib/osbuild/assemblers", glob.glob("./assemblers/*")) ] -) +) \ No newline at end of file