diff --git a/.gitignore b/.gitignore index c9b568f..2f7c0ea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ *.pyc *.swp +build +gofedlib.egg-info diff --git a/go/symbolsextractor/testdata/example b/go/symbolsextractor/testdata/example deleted file mode 160000 index ef176d8..0000000 --- a/go/symbolsextractor/testdata/example +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ef176d87c165436ba6961f6c52716d11be05ebd4 diff --git a/gofedlib-cli b/gofedlib-cli new file mode 100755 index 0000000..b217a55 --- /dev/null +++ b/gofedlib-cli @@ -0,0 +1,115 @@ +#!/bin/env python + +import json +from argparse import ArgumentParser +from gofedlib.go.functions import api, project_packages +from gofedlib.go.importpath.decomposerbuilder import ImportPathsDecomposerBuilder +from gofedlib.go.importpath.normalizer import ImportPathNormalizer +from gofedlib.go.importpath.parserbuilder import ImportPathParserBuilder +from gofedlib.providers.providerbuilder import ProviderBuilder + + +def dict2json(o, pretty=True): + if pretty is True: + return json.dumps(o, sort_keys=True, separators=(',', ': '), indent=2) + else: + return json.dumps(o) + + +def ippaths2providers(deps_list): + normalizer = ImportPathNormalizer() + dependencies = map(lambda l: normalizer.normalize(l), deps_list) + dependencies = list(set(dependencies)) + + decomposer = ImportPathsDecomposerBuilder().buildLocalDecomposer() + decomposer.decompose(dependencies) + + project_provider = ProviderBuilder().buildUpstreamWithLocalMapping() + + result = [] + for prefix in decomposer.classes().keys(): + if prefix != 'Native' and prefix != 'Unknown': + result.append(project_provider.parse(prefix).prefix()) + + return result + + +def get_dependencies(packages, selection): + dependencies = {} + + if selection['packages']: + dependencies['deps-packages'] = [] + for dependency in packages['dependencies']: + for item in dependency['dependencies']: + dependencies['deps-packages'].append(item['name']) + + if selection['main']: + dependencies['deps-main'] = [] + for record in packages['main']: + for dependency in record['dependencies']: + dependencies['deps-main'].append(dependency) + + if selection['tests']: + dependencies['deps-tests'] = [] + for record in packages['tests']: + for dependency in record['dependencies']: + dependencies['deps-tests'].append(dependency) + + for key in dependencies.keys(): + dependencies[key] = ippaths2providers(dependencies[key]) + dependencies[key] = map(lambda l: 'https://%s' % l, dependencies[key]) + + return dependencies + + +if __name__ == '__main__': + ap = ArgumentParser() + ap.add_argument('path') + ap.add_argument('-m', '--dependencies-main', help="list of dependencies in main packages", + default=False, action='store_true') + ap.add_argument('-d', '--dependencies-packages', help="list of dependencies in packages", + default=False, action='store_true') + ap.add_argument('-t', '--dependencies-tests', help="list of dependencies in tests", + default=False, action='store_true') + ap.add_argument('-a', '--api', help="API listing", + default=False, action='store_true') + ap.add_argument('-j', '--pretty', help="print JSON nicely formatted", + default=False, action='store_true') + ap.add_argument('-p', '--packages', help="packages listing", + default=False, action='store_true') + ap.add_argument('-o', '--output', help="output file", + default=None, type=str) + ap.add_argument('-r', '--raw-project-packages', help="raw output from gofedlib", + default=False, action='store_true') + + args = ap.parse_args() + result = {} + project_package_info = None + + if args.raw_project_packages: + project_package_info = project_packages(args.path) + result['raw-project-packages'] = project_package_info + + if args.packages: + if not project_package_info: + packages_info = project_packages(args.path) + result['packages'] = packages_info['packages'] + + if args.api: + result['api'] = api(args.path) + + if args.dependencies_main \ + or args.dependencies_tests or args.dependencies_packages: + selection = { + 'main': args.dependencies_main, + 'packages': args.dependencies_packages, + 'tests': args.dependencies_tests + } + + result.update(get_dependencies(project_packages(args.path), selection)) + + if args.output: + with open(args.output, 'w') as f: + f.write(dict2json(result, args.pretty)) + else: + print(dict2json(result, args.pretty)) diff --git a/__init__.py b/gofedlib/__init__.py similarity index 52% rename from __init__.py rename to gofedlib/__init__.py index f674c2d..feaa8c7 100644 --- a/__init__.py +++ b/gofedlib/__init__.py @@ -1,4 +1,4 @@ -import sys +import sys -if __name__ == "gofed_lib": +if __name__ == "gofedlib": sys.modules['lib'] = sys.modules[__name__] diff --git a/config/__init__.py b/gofedlib/config/__init__.py similarity index 100% rename from config/__init__.py rename to gofedlib/config/__init__.py diff --git a/config/config.py b/gofedlib/config/config.py similarity index 91% rename from config/config.py rename to gofedlib/config/config.py index 1142db6..eb69c42 100644 --- a/config/config.py +++ b/gofedlib/config/config.py @@ -1,5 +1,5 @@ import ConfigParser -from gofed_lib.utils import getScriptDir +from gofedlib.utils import getScriptDir import os class Config(object): diff --git a/config/lib.conf b/gofedlib/config/lib.conf similarity index 100% rename from config/lib.conf rename to gofedlib/config/lib.conf diff --git a/config/libconfig.py b/gofedlib/config/libconfig.py similarity index 100% rename from config/libconfig.py rename to gofedlib/config/libconfig.py diff --git a/distribution/__init__.py b/gofedlib/distribution/__init__.py similarity index 100% rename from distribution/__init__.py rename to gofedlib/distribution/__init__.py diff --git a/distribution/clients/__init__.py b/gofedlib/distribution/clients/__init__.py similarity index 100% rename from distribution/clients/__init__.py rename to gofedlib/distribution/clients/__init__.py diff --git a/distribution/clients/bodhi/__init__.py b/gofedlib/distribution/clients/bodhi/__init__.py similarity index 100% rename from distribution/clients/bodhi/__init__.py rename to gofedlib/distribution/clients/bodhi/__init__.py diff --git a/distribution/clients/bodhi/client.py b/gofedlib/distribution/clients/bodhi/client.py similarity index 100% rename from distribution/clients/bodhi/client.py rename to gofedlib/distribution/clients/bodhi/client.py diff --git a/distribution/clients/fakedata/data.json b/gofedlib/distribution/clients/fakedata/data.json similarity index 100% rename from distribution/clients/fakedata/data.json rename to gofedlib/distribution/clients/fakedata/data.json diff --git a/distribution/clients/koji/__init__.py b/gofedlib/distribution/clients/koji/__init__.py similarity index 100% rename from distribution/clients/koji/__init__.py rename to gofedlib/distribution/clients/koji/__init__.py diff --git a/distribution/clients/koji/client.py b/gofedlib/distribution/clients/koji/client.py similarity index 100% rename from distribution/clients/koji/client.py rename to gofedlib/distribution/clients/koji/client.py diff --git a/distribution/clients/koji/fakeclient.py b/gofedlib/distribution/clients/koji/fakeclient.py similarity index 100% rename from distribution/clients/koji/fakeclient.py rename to gofedlib/distribution/clients/koji/fakeclient.py diff --git a/distribution/clients/koji/test_client.py b/gofedlib/distribution/clients/koji/test_client.py similarity index 100% rename from distribution/clients/koji/test_client.py rename to gofedlib/distribution/clients/koji/test_client.py diff --git a/distribution/clients/pkgdb/__init__.py b/gofedlib/distribution/clients/pkgdb/__init__.py similarity index 100% rename from distribution/clients/pkgdb/__init__.py rename to gofedlib/distribution/clients/pkgdb/__init__.py diff --git a/distribution/clients/pkgdb/client.py b/gofedlib/distribution/clients/pkgdb/client.py similarity index 100% rename from distribution/clients/pkgdb/client.py rename to gofedlib/distribution/clients/pkgdb/client.py diff --git a/distribution/clients/pkgdb/fakeclient.py b/gofedlib/distribution/clients/pkgdb/fakeclient.py similarity index 100% rename from distribution/clients/pkgdb/fakeclient.py rename to gofedlib/distribution/clients/pkgdb/fakeclient.py diff --git a/distribution/clients/pkgdb/fakedata.json b/gofedlib/distribution/clients/pkgdb/fakedata.json similarity index 100% rename from distribution/clients/pkgdb/fakedata.json rename to gofedlib/distribution/clients/pkgdb/fakedata.json diff --git a/distribution/clients/pkgdb/test_client.py b/gofedlib/distribution/clients/pkgdb/test_client.py similarity index 100% rename from distribution/clients/pkgdb/test_client.py rename to gofedlib/distribution/clients/pkgdb/test_client.py diff --git a/distribution/data/ip2package_mapping.json b/gofedlib/distribution/data/ip2package_mapping.json similarity index 100% rename from distribution/data/ip2package_mapping.json rename to gofedlib/distribution/data/ip2package_mapping.json diff --git a/distribution/distributionnameparser.py b/gofedlib/distribution/distributionnameparser.py similarity index 100% rename from distribution/distributionnameparser.py rename to gofedlib/distribution/distributionnameparser.py diff --git a/distribution/distributionsnapshot.py b/gofedlib/distribution/distributionsnapshot.py similarity index 100% rename from distribution/distributionsnapshot.py rename to gofedlib/distribution/distributionsnapshot.py diff --git a/distribution/eco/__init__.py b/gofedlib/distribution/eco/__init__.py similarity index 100% rename from distribution/eco/__init__.py rename to gofedlib/distribution/eco/__init__.py diff --git a/distribution/eco/capturer.py b/gofedlib/distribution/eco/capturer.py similarity index 100% rename from distribution/eco/capturer.py rename to gofedlib/distribution/eco/capturer.py diff --git a/distribution/helpers.py b/gofedlib/distribution/helpers.py similarity index 100% rename from distribution/helpers.py rename to gofedlib/distribution/helpers.py diff --git a/distribution/packagemanager.py b/gofedlib/distribution/packagemanager.py similarity index 100% rename from distribution/packagemanager.py rename to gofedlib/distribution/packagemanager.py diff --git a/distribution/packagenamegenerator.py b/gofedlib/distribution/packagenamegenerator.py similarity index 100% rename from distribution/packagenamegenerator.py rename to gofedlib/distribution/packagenamegenerator.py diff --git a/distribution/packagenamegeneratorbuilder.py b/gofedlib/distribution/packagenamegeneratorbuilder.py similarity index 100% rename from distribution/packagenamegeneratorbuilder.py rename to gofedlib/distribution/packagenamegeneratorbuilder.py diff --git a/distribution/test_distributionnameparser.py b/gofedlib/distribution/test_distributionnameparser.py similarity index 100% rename from distribution/test_distributionnameparser.py rename to gofedlib/distribution/test_distributionnameparser.py diff --git a/distribution/test_packagenamegenerator.py b/gofedlib/distribution/test_packagenamegenerator.py similarity index 100% rename from distribution/test_packagenamegenerator.py rename to gofedlib/distribution/test_packagenamegenerator.py diff --git a/docs/proposal.md b/gofedlib/docs/proposal.md similarity index 100% rename from docs/proposal.md rename to gofedlib/docs/proposal.md diff --git a/docs/providers.md b/gofedlib/docs/providers.md similarity index 100% rename from docs/providers.md rename to gofedlib/docs/providers.md diff --git a/go/__init__.py b/gofedlib/go/__init__.py similarity index 100% rename from go/__init__.py rename to gofedlib/go/__init__.py diff --git a/go/apidiff/__init__.py b/gofedlib/go/apidiff/__init__.py similarity index 100% rename from go/apidiff/__init__.py rename to gofedlib/go/apidiff/__init__.py diff --git a/go/apidiff/apidiff.py b/gofedlib/go/apidiff/apidiff.py similarity index 100% rename from go/apidiff/apidiff.py rename to gofedlib/go/apidiff/apidiff.py diff --git a/go/apidiff/test_apidiff.py b/gofedlib/go/apidiff/test_apidiff.py similarity index 100% rename from go/apidiff/test_apidiff.py rename to gofedlib/go/apidiff/test_apidiff.py diff --git a/go/apidiff/testdata/api1.json b/gofedlib/go/apidiff/testdata/api1.json similarity index 100% rename from go/apidiff/testdata/api1.json rename to gofedlib/go/apidiff/testdata/api1.json diff --git a/go/apidiff/testdata/api2.json b/gofedlib/go/apidiff/testdata/api2.json similarity index 100% rename from go/apidiff/testdata/api2.json rename to gofedlib/go/apidiff/testdata/api2.json diff --git a/go/contentmetadataextractor.py b/gofedlib/go/contentmetadataextractor.py similarity index 100% rename from go/contentmetadataextractor.py rename to gofedlib/go/contentmetadataextractor.py diff --git a/go/data2specmodeldata.py b/gofedlib/go/data2specmodeldata.py similarity index 100% rename from go/data2specmodeldata.py rename to gofedlib/go/data2specmodeldata.py diff --git a/go/functions.py b/gofedlib/go/functions.py similarity index 100% rename from go/functions.py rename to gofedlib/go/functions.py diff --git a/go/importpath/__init__.py b/gofedlib/go/importpath/__init__.py similarity index 100% rename from go/importpath/__init__.py rename to gofedlib/go/importpath/__init__.py diff --git a/go/importpath/data/known_prefixes.json b/gofedlib/go/importpath/data/known_prefixes.json similarity index 100% rename from go/importpath/data/known_prefixes.json rename to gofedlib/go/importpath/data/known_prefixes.json diff --git a/go/importpath/data/native_packages.json b/gofedlib/go/importpath/data/native_packages.json similarity index 100% rename from go/importpath/data/native_packages.json rename to gofedlib/go/importpath/data/native_packages.json diff --git a/go/importpath/decomposer.py b/gofedlib/go/importpath/decomposer.py similarity index 100% rename from go/importpath/decomposer.py rename to gofedlib/go/importpath/decomposer.py diff --git a/go/importpath/decomposerbuilder.py b/gofedlib/go/importpath/decomposerbuilder.py similarity index 100% rename from go/importpath/decomposerbuilder.py rename to gofedlib/go/importpath/decomposerbuilder.py diff --git a/go/importpath/normalizer.py b/gofedlib/go/importpath/normalizer.py similarity index 100% rename from go/importpath/normalizer.py rename to gofedlib/go/importpath/normalizer.py diff --git a/go/importpath/parser.py b/gofedlib/go/importpath/parser.py similarity index 100% rename from go/importpath/parser.py rename to gofedlib/go/importpath/parser.py diff --git a/go/importpath/parserbuilder.py b/gofedlib/go/importpath/parserbuilder.py similarity index 100% rename from go/importpath/parserbuilder.py rename to gofedlib/go/importpath/parserbuilder.py diff --git a/go/importpath/test_decomposer.py b/gofedlib/go/importpath/test_decomposer.py similarity index 100% rename from go/importpath/test_decomposer.py rename to gofedlib/go/importpath/test_decomposer.py diff --git a/go/importpath/test_parser.py b/gofedlib/go/importpath/test_parser.py similarity index 100% rename from go/importpath/test_parser.py rename to gofedlib/go/importpath/test_parser.py diff --git a/go/projectinfo.py b/gofedlib/go/projectinfo.py similarity index 100% rename from go/projectinfo.py rename to gofedlib/go/projectinfo.py diff --git a/go/projectinfobuilder.py b/gofedlib/go/projectinfobuilder.py similarity index 100% rename from go/projectinfobuilder.py rename to gofedlib/go/projectinfobuilder.py diff --git a/go/snapshot.py b/gofedlib/go/snapshot.py similarity index 100% rename from go/snapshot.py rename to gofedlib/go/snapshot.py diff --git a/go/symbolsextractor/__init__.py b/gofedlib/go/symbolsextractor/__init__.py similarity index 100% rename from go/symbolsextractor/__init__.py rename to gofedlib/go/symbolsextractor/__init__.py diff --git a/go/symbolsextractor/coder.py b/gofedlib/go/symbolsextractor/coder.py similarity index 100% rename from go/symbolsextractor/coder.py rename to gofedlib/go/symbolsextractor/coder.py diff --git a/go/symbolsextractor/extractor.py b/gofedlib/go/symbolsextractor/extractor.py similarity index 100% rename from go/symbolsextractor/extractor.py rename to gofedlib/go/symbolsextractor/extractor.py diff --git a/go/symbolsextractor/parseGo b/gofedlib/go/symbolsextractor/parseGo similarity index 100% rename from go/symbolsextractor/parseGo rename to gofedlib/go/symbolsextractor/parseGo diff --git a/go/symbolsextractor/parseGo.go b/gofedlib/go/symbolsextractor/parseGo.go similarity index 100% rename from go/symbolsextractor/parseGo.go rename to gofedlib/go/symbolsextractor/parseGo.go diff --git a/go/symbolsextractor/test_symbolsextractor.py b/gofedlib/go/symbolsextractor/test_symbolsextractor.py similarity index 100% rename from go/symbolsextractor/test_symbolsextractor.py rename to gofedlib/go/symbolsextractor/test_symbolsextractor.py diff --git a/graphs/__init__.py b/gofedlib/graphs/__init__.py similarity index 100% rename from graphs/__init__.py rename to gofedlib/graphs/__init__.py diff --git a/graphs/graphutils.py b/gofedlib/graphs/graphutils.py similarity index 100% rename from graphs/graphutils.py rename to gofedlib/graphs/graphutils.py diff --git a/graphs/test_graphutils.py b/gofedlib/graphs/test_graphutils.py similarity index 100% rename from graphs/test_graphutils.py rename to gofedlib/graphs/test_graphutils.py diff --git a/logger/__init__.py b/gofedlib/logger/__init__.py similarity index 100% rename from logger/__init__.py rename to gofedlib/logger/__init__.py diff --git a/logger/logger.py b/gofedlib/logger/logger.py similarity index 100% rename from logger/logger.py rename to gofedlib/logger/logger.py diff --git a/logger/logging.yaml b/gofedlib/logger/logging.yaml similarity index 92% rename from logger/logging.yaml rename to gofedlib/logger/logging.yaml index fddf1eb..0b1b05a 100644 --- a/logger/logging.yaml +++ b/gofedlib/logger/logging.yaml @@ -1,4 +1,4 @@ ---- +--- version: 1 formatters: simpleFormatter: @@ -18,12 +18,12 @@ loggers: pkgdb_client: level: INFO handlers: [consoleHandler] - qualname: gofed_lib.distribution.clients.pkgdb.client + qualname: gofedlib.distribution.clients.pkgdb.client propagate: 0 distribution_capturer: level: INFO handlers: [consoleHandler] - qualname: gofed_lib.distribution.eco.capturer + qualname: gofedlib.distribution.eco.capturer propagate: 0 distribution_snapshot_capturer: level: INFO diff --git a/projectsignature/__init__.py b/gofedlib/projectsignature/__init__.py similarity index 100% rename from projectsignature/__init__.py rename to gofedlib/projectsignature/__init__.py diff --git a/projectsignature/parser.py b/gofedlib/projectsignature/parser.py similarity index 92% rename from projectsignature/parser.py rename to gofedlib/projectsignature/parser.py index 4817f8c..427ea2a 100644 --- a/projectsignature/parser.py +++ b/gofedlib/projectsignature/parser.py @@ -8,8 +8,8 @@ # import re -from gofed_lib.providers.providerbuilder import ProviderBuilder -from gofed_lib.distribution.distributionnameparser import DistributionNameParser +from gofedlib.providers.providerbuilder import ProviderBuilder +from gofedlib.distribution.distributionnameparser import DistributionNameParser class ProjectSignatureParser(object): diff --git a/projectsignature/signature.py b/gofedlib/projectsignature/signature.py similarity index 100% rename from projectsignature/signature.py rename to gofedlib/projectsignature/signature.py diff --git a/projectsignature/test_parser.py b/gofedlib/projectsignature/test_parser.py similarity index 100% rename from projectsignature/test_parser.py rename to gofedlib/projectsignature/test_parser.py diff --git a/providers/__init__.py b/gofedlib/providers/__init__.py similarity index 100% rename from providers/__init__.py rename to gofedlib/providers/__init__.py diff --git a/providers/data/ip2pp_mapping.json b/gofedlib/providers/data/ip2pp_mapping.json similarity index 100% rename from providers/data/ip2pp_mapping.json rename to gofedlib/providers/data/ip2pp_mapping.json diff --git a/providers/providerbuilder.py b/gofedlib/providers/providerbuilder.py similarity index 100% rename from providers/providerbuilder.py rename to gofedlib/providers/providerbuilder.py diff --git a/providers/test_upstreamprovider.py b/gofedlib/providers/test_upstreamprovider.py similarity index 100% rename from providers/test_upstreamprovider.py rename to gofedlib/providers/test_upstreamprovider.py diff --git a/providers/upstreamprovider.py b/gofedlib/providers/upstreamprovider.py similarity index 100% rename from providers/upstreamprovider.py rename to gofedlib/providers/upstreamprovider.py diff --git a/repository/__init__.py b/gofedlib/repository/__init__.py similarity index 100% rename from repository/__init__.py rename to gofedlib/repository/__init__.py diff --git a/repository/bitbucketclient.py b/gofedlib/repository/bitbucketclient.py similarity index 100% rename from repository/bitbucketclient.py rename to gofedlib/repository/bitbucketclient.py diff --git a/repository/githubclient.py b/gofedlib/repository/githubclient.py similarity index 100% rename from repository/githubclient.py rename to gofedlib/repository/githubclient.py diff --git a/repository/gitlocalclient.py b/gofedlib/repository/gitlocalclient.py similarity index 100% rename from repository/gitlocalclient.py rename to gofedlib/repository/gitlocalclient.py diff --git a/repository/mercuriallocalclient.py b/gofedlib/repository/mercuriallocalclient.py similarity index 100% rename from repository/mercuriallocalclient.py rename to gofedlib/repository/mercuriallocalclient.py diff --git a/repository/repositoryclientbuilder.py b/gofedlib/repository/repositoryclientbuilder.py similarity index 100% rename from repository/repositoryclientbuilder.py rename to gofedlib/repository/repositoryclientbuilder.py diff --git a/schemas/distribution_packages.json b/gofedlib/schemas/distribution_packages.json similarity index 100% rename from schemas/distribution_packages.json rename to gofedlib/schemas/distribution_packages.json diff --git a/schemas/golang_native_imports.json b/gofedlib/schemas/golang_native_imports.json similarity index 100% rename from schemas/golang_native_imports.json rename to gofedlib/schemas/golang_native_imports.json diff --git a/schemas/import_path_to_package_name.json b/gofedlib/schemas/import_path_to_package_name.json similarity index 100% rename from schemas/import_path_to_package_name.json rename to gofedlib/schemas/import_path_to_package_name.json diff --git a/schemas/import_path_to_provider_prefix.json b/gofedlib/schemas/import_path_to_provider_prefix.json similarity index 100% rename from schemas/import_path_to_provider_prefix.json rename to gofedlib/schemas/import_path_to_provider_prefix.json diff --git a/schemas/spec_model.json b/gofedlib/schemas/spec_model.json similarity index 100% rename from schemas/spec_model.json rename to gofedlib/schemas/spec_model.json diff --git a/snapshot/__init__.py b/gofedlib/snapshot/__init__.py similarity index 100% rename from snapshot/__init__.py rename to gofedlib/snapshot/__init__.py diff --git a/snapshot/capturer.py b/gofedlib/snapshot/capturer.py similarity index 100% rename from snapshot/capturer.py rename to gofedlib/snapshot/capturer.py diff --git a/snapshot/projectbitbucketrepositorycapturer.py b/gofedlib/snapshot/projectbitbucketrepositorycapturer.py similarity index 100% rename from snapshot/projectbitbucketrepositorycapturer.py rename to gofedlib/snapshot/projectbitbucketrepositorycapturer.py diff --git a/snapshot/projectgithubrepositorycapturer.py b/gofedlib/snapshot/projectgithubrepositorycapturer.py similarity index 100% rename from snapshot/projectgithubrepositorycapturer.py rename to gofedlib/snapshot/projectgithubrepositorycapturer.py diff --git a/snapshot/projectsnapshotcapturer.py b/gofedlib/snapshot/projectsnapshotcapturer.py similarity index 100% rename from snapshot/projectsnapshotcapturer.py rename to gofedlib/snapshot/projectsnapshotcapturer.py diff --git a/snapshot/test_projectcapturer.py b/gofedlib/snapshot/test_projectcapturer.py similarity index 100% rename from snapshot/test_projectcapturer.py rename to gofedlib/snapshot/test_projectcapturer.py diff --git a/test.sh b/gofedlib/test.sh similarity index 100% rename from test.sh rename to gofedlib/test.sh diff --git a/types.py b/gofedlib/types.py similarity index 100% rename from types.py rename to gofedlib/types.py diff --git a/urlbuilder/__init__.py b/gofedlib/urlbuilder/__init__.py similarity index 100% rename from urlbuilder/__init__.py rename to gofedlib/urlbuilder/__init__.py diff --git a/urlbuilder/api.py b/gofedlib/urlbuilder/api.py similarity index 100% rename from urlbuilder/api.py rename to gofedlib/urlbuilder/api.py diff --git a/urlbuilder/builder.py b/gofedlib/urlbuilder/builder.py similarity index 97% rename from urlbuilder/builder.py rename to gofedlib/urlbuilder/builder.py index 00aa6aa..1dfcbe7 100644 --- a/urlbuilder/builder.py +++ b/gofedlib/urlbuilder/builder.py @@ -5,7 +5,7 @@ # - upstream repository clone url (github.com, bitbucket.org) # -from gofed_lib.distribution.helpers import Build, Rpm +from gofedlib.distribution.helpers import Build, Rpm class UrlBuilder(object): diff --git a/urlbuilder/test_urlbuilder.py b/gofedlib/urlbuilder/test_urlbuilder.py similarity index 100% rename from urlbuilder/test_urlbuilder.py rename to gofedlib/urlbuilder/test_urlbuilder.py diff --git a/utils.py b/gofedlib/utils.py similarity index 100% rename from utils.py rename to gofedlib/utils.py diff --git a/setup.py b/setup.py new file mode 100755 index 0000000..ba5e7af --- /dev/null +++ b/setup.py @@ -0,0 +1,84 @@ +#!/usr/bin/python + +import os +import subprocess +from setuptools import setup, find_packages +from distutils.command.install import install as DistutilsInstall + + +class GofedlibInstall(DistutilsInstall): + + def _compile_parsego(self): + path = os.path.join("gofedlib", "go", "symbolsextractor") + cmd = "go build -o %s %s" % (os.path.join(path, + "parseGo"), os.path.join(path, "parseGo.go")) + + process = subprocess.Popen( + cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + stdout, stderr = process.communicate() + retval = process.returncode + + if retval != 0: + raise RuntimeError(stderr) + + def run(self): + self._compile_parsego() + return DistutilsInstall.run(self) + + +def get_requirements(): + with open('requirements.txt') as fd: + return fd.read().splitlines() + + +def gofedlib_find_packages(): + packages = find_packages() + # data files are often placed outside of package dir, we have to add them + # manually + additional = [ + 'gofedlib.config', + 'gofedlib.docs', + 'gofedlib.distribution.clients.fakedata', + 'gofedlib.distribution.data', + 'gofedlib.go.apidiff.testdata', + 'gofedlib.go.importpath.data', + 'gofedlib.providers.data', + 'gofedlib.schemas' + ] + return packages + additional + +setup( + name='gofedlib', + version='0.1.0a1', + packages=gofedlib_find_packages(), + scripts=['gofedlib-cli'], + install_requires=get_requirements(), + cmdclass={'install': GofedlibInstall}, + package_data={ + 'gofedlib.config': ['lib.conf'], + 'gofedlib.docs': ['proposal.md', 'providers.md'], + 'gofedlib.distribution.clients.fakedata': ['data.json'], + 'gofedlib.distribution.clients.pkgdb': ['fakedata.json'], + 'gofedlib.distribution.data': ['ip2package_mapping.json'], + 'gofedlib.go.apidiff.testdata': ['api1.json', 'api2.json'], + 'gofedlib.go.importpath.data': ['known_prefixes.json', 'native_packages.json'], + 'gofedlib.go.symbolsextractor': ['parseGo.go', 'parseGo'], + 'gofedlib.logger': ['logger.yaml'], + 'gofedlib.providers.data': ['ip2pp_mapping.json'], + 'gofedlib.schemas': [ + 'distribution_packages.json', + 'golang_native_imports.json', + 'import_path_to_package_name.json', + 'import_path_to_provider_prefix.json', + 'spec_model.json' + ] + }, + author='Jan Chaloupka', + author_email='jchaloup@redhat.com', + maintainer='Jan Chaloupka', + maintainer_email='jchaloup@redhat.com', + description='A set of python modules carrying operation related to Go source codes analysis used in Gofed', + url='https://github.com/gofed/gofedlib', + license='GPL', + keywords='gofed golang API dependencies', +)