diff --git a/.gitignore b/.gitignore index d562a27b..f7ef7928 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Apache Kibble files api/yaml/kibble.yaml +kibble/api/yaml/kibble.yaml # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b3ef0dd1..d420751e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,6 +15,11 @@ We also have: ## Development installation +You should be able to install Apache Kibble by simply doing: +``` +pip install -e ."[devel]" +``` + The easiest option to spin up a development environment is to use our development docker-compose. The development image has mounted all Kibble sources so all your local code changes will be automatically reflected in the running app. diff --git a/Dockerfile.dev b/Dockerfile.dev index ab76414d..690be03d 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -15,17 +15,15 @@ # specific language governing permissions and limitations # under the License. -FROM python:3.6 +FROM python:3.8 USER root RUN apt-get update RUN apt-get install -y gcc unzip -COPY ./api /kibble/api/ -COPY ./setup /kibble/setup/ -COPY ./ui /kibble/ui/ - -RUN pip install --upgrade pip -RUN pip install -r /kibble/setup/requirements.txt +COPY . /kibble/ WORKDIR /kibble + +RUN pip install --upgrade pip +RUN pip install -e . diff --git a/docker-compose-dev.yaml b/docker-compose-dev.yaml index c53e9905..be6f1363 100644 --- a/docker-compose-dev.yaml +++ b/docker-compose-dev.yaml @@ -7,24 +7,22 @@ services: build: context: . dockerfile: Dockerfile.dev - command: bash -c "python setup/setup.py -e elasticsearch -a -k" + command: bash -c "python kibble/setup/setup.py -e elasticsearch -a -k" volumes: - - ./setup/:/kibble/setup/ + - .:/kibble/ depends_on: - elasticsearch # Apache Kibble API server kibble: image: *img - command: bash -c "gunicorn --reload -w 1 -b 0.0.0.0:8001 api.handler:application" + command: bash -c "gunicorn --reload -w 1 -b 0.0.0.0:8001 kibble.api.handler:application" expose: - 8001 ports: - 8001:8001 volumes: - - ./api/:/kibble/api/ - - ./setup/:/kibble/setup/ - - ./ui/:/kibble/ui/ + - .:/kibble/ depends_on: - elasticsearch diff --git a/api/__init__.py b/kibble/__init__.py similarity index 100% rename from api/__init__.py rename to kibble/__init__.py diff --git a/kibble/__main__.py b/kibble/__main__.py new file mode 100644 index 00000000..c7a18f74 --- /dev/null +++ b/kibble/__main__.py @@ -0,0 +1,23 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +def main(): + print("Hello to kibble!") + + +if __name__ == '__main__': + main() diff --git a/kibble/api/__init__.py b/kibble/api/__init__.py new file mode 100644 index 00000000..13a83393 --- /dev/null +++ b/kibble/api/__init__.py @@ -0,0 +1,16 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. diff --git a/api/handler.py b/kibble/api/handler.py similarity index 94% rename from api/handler.py rename to kibble/api/handler.py index 466d4b5e..508a7c0c 100644 --- a/api/handler.py +++ b/kibble/api/handler.py @@ -30,30 +30,31 @@ import yaml import json -from api.plugins import openapi -from api.plugins.database import KibbleDatabase -from api.plugins.session import KibbleSession +from kibble.api.plugins import openapi +from kibble.api.plugins.database import KibbleDatabase +from kibble.api.plugins.session import KibbleSession # Compile valid API URLs from the pages library # Allow backwards compatibility by also accepting .lua URLs +from kibble.settings import KIBBLE_YAML, YAML_DIRECTORY + urls = [] if __name__ != '__main__': - from api.pages import handlers + from kibble.api.pages import handlers for page, handler in handlers.items(): urls.append((r"^(/api/%s)(/.+)?$" % page, handler.run)) # Load Kibble master configuration -config_yaml = os.path.join(os.path.dirname(os.path.realpath(__file__)), "yaml", "kibble.yaml") -with open(config_yaml, "r") as f: +with open(KIBBLE_YAML, "r") as f: config = yaml.load(f) # Instantiate database connections DB = None # Load Open API specifications -openapi_yaml = os.path.join(os.path.dirname(os.path.realpath(__file__)), "yaml", "openapi.yaml") +openapi_yaml = os.path.join(YAML_DIRECTORY, "openapi.yaml") KibbleOpenAPI = openapi.OpenAPI(openapi_yaml) diff --git a/api/pages/__init__.py b/kibble/api/pages/__init__.py similarity index 95% rename from api/pages/__init__.py rename to kibble/api/pages/__init__.py index f3ba204f..a9b1b9db 100644 --- a/api/pages/__init__.py +++ b/kibble/api/pages/__init__.py @@ -42,5 +42,5 @@ def loadPage(path): p = filepath.replace(rootpath, "")[1:].replace('/', '.')[:-3] xp = p.replace('.', '/') print("Loading endpoint pages.%s as %s" % (p, xp)) - handlers[xp] = importlib.import_module("api.pages.%s" % p) + handlers[xp] = importlib.import_module(f"kibble.api.pages.{p}") loadPage(rootpath) diff --git a/api/pages/account.py b/kibble/api/pages/account.py similarity index 100% rename from api/pages/account.py rename to kibble/api/pages/account.py diff --git a/api/pages/bio/bio.py b/kibble/api/pages/bio/bio.py similarity index 100% rename from api/pages/bio/bio.py rename to kibble/api/pages/bio/bio.py diff --git a/api/pages/bio/newtimers.py b/kibble/api/pages/bio/newtimers.py similarity index 100% rename from api/pages/bio/newtimers.py rename to kibble/api/pages/bio/newtimers.py diff --git a/api/pages/bio/trends.py b/kibble/api/pages/bio/trends.py similarity index 100% rename from api/pages/bio/trends.py rename to kibble/api/pages/bio/trends.py diff --git a/api/pages/ci/queue.py b/kibble/api/pages/ci/queue.py similarity index 100% rename from api/pages/ci/queue.py rename to kibble/api/pages/ci/queue.py diff --git a/api/pages/ci/status.py b/kibble/api/pages/ci/status.py similarity index 100% rename from api/pages/ci/status.py rename to kibble/api/pages/ci/status.py diff --git a/api/pages/ci/top-buildcount.py b/kibble/api/pages/ci/top-buildcount.py similarity index 100% rename from api/pages/ci/top-buildcount.py rename to kibble/api/pages/ci/top-buildcount.py diff --git a/api/pages/ci/top-buildtime.py b/kibble/api/pages/ci/top-buildtime.py similarity index 100% rename from api/pages/ci/top-buildtime.py rename to kibble/api/pages/ci/top-buildtime.py diff --git a/api/pages/code/changes.py b/kibble/api/pages/code/changes.py similarity index 100% rename from api/pages/code/changes.py rename to kibble/api/pages/code/changes.py diff --git a/api/pages/code/commits.py b/kibble/api/pages/code/commits.py similarity index 100% rename from api/pages/code/commits.py rename to kibble/api/pages/code/commits.py diff --git a/api/pages/code/committers.py b/kibble/api/pages/code/committers.py similarity index 100% rename from api/pages/code/committers.py rename to kibble/api/pages/code/committers.py diff --git a/api/pages/code/evolution.py b/kibble/api/pages/code/evolution.py similarity index 100% rename from api/pages/code/evolution.py rename to kibble/api/pages/code/evolution.py diff --git a/api/pages/code/pony-timeseries.py b/kibble/api/pages/code/pony-timeseries.py similarity index 100% rename from api/pages/code/pony-timeseries.py rename to kibble/api/pages/code/pony-timeseries.py diff --git a/api/pages/code/pony.py b/kibble/api/pages/code/pony.py similarity index 100% rename from api/pages/code/pony.py rename to kibble/api/pages/code/pony.py diff --git a/api/pages/code/punchcard.py b/kibble/api/pages/code/punchcard.py similarity index 100% rename from api/pages/code/punchcard.py rename to kibble/api/pages/code/punchcard.py diff --git a/api/pages/code/relationships.py b/kibble/api/pages/code/relationships.py similarity index 100% rename from api/pages/code/relationships.py rename to kibble/api/pages/code/relationships.py diff --git a/api/pages/code/retention.py b/kibble/api/pages/code/retention.py similarity index 100% rename from api/pages/code/retention.py rename to kibble/api/pages/code/retention.py diff --git a/api/pages/code/sloc.py b/kibble/api/pages/code/sloc.py similarity index 100% rename from api/pages/code/sloc.py rename to kibble/api/pages/code/sloc.py diff --git a/api/pages/code/top-commits.py b/kibble/api/pages/code/top-commits.py similarity index 100% rename from api/pages/code/top-commits.py rename to kibble/api/pages/code/top-commits.py diff --git a/api/pages/code/top-sloc.py b/kibble/api/pages/code/top-sloc.py similarity index 100% rename from api/pages/code/top-sloc.py rename to kibble/api/pages/code/top-sloc.py diff --git a/api/pages/code/trends.py b/kibble/api/pages/code/trends.py similarity index 100% rename from api/pages/code/trends.py rename to kibble/api/pages/code/trends.py diff --git a/api/pages/filters.py b/kibble/api/pages/filters.py similarity index 100% rename from api/pages/filters.py rename to kibble/api/pages/filters.py diff --git a/api/pages/forum/actors.py b/kibble/api/pages/forum/actors.py similarity index 100% rename from api/pages/forum/actors.py rename to kibble/api/pages/forum/actors.py diff --git a/api/pages/forum/creators.py b/kibble/api/pages/forum/creators.py similarity index 100% rename from api/pages/forum/creators.py rename to kibble/api/pages/forum/creators.py diff --git a/api/pages/forum/issues.py b/kibble/api/pages/forum/issues.py similarity index 100% rename from api/pages/forum/issues.py rename to kibble/api/pages/forum/issues.py diff --git a/api/pages/forum/responders.py b/kibble/api/pages/forum/responders.py similarity index 100% rename from api/pages/forum/responders.py rename to kibble/api/pages/forum/responders.py diff --git a/api/pages/forum/top-count.py b/kibble/api/pages/forum/top-count.py similarity index 100% rename from api/pages/forum/top-count.py rename to kibble/api/pages/forum/top-count.py diff --git a/api/pages/forum/top.py b/kibble/api/pages/forum/top.py similarity index 100% rename from api/pages/forum/top.py rename to kibble/api/pages/forum/top.py diff --git a/api/pages/forum/trends.py b/kibble/api/pages/forum/trends.py similarity index 100% rename from api/pages/forum/trends.py rename to kibble/api/pages/forum/trends.py diff --git a/api/pages/issue/actors.py b/kibble/api/pages/issue/actors.py similarity index 100% rename from api/pages/issue/actors.py rename to kibble/api/pages/issue/actors.py diff --git a/api/pages/issue/age.py b/kibble/api/pages/issue/age.py similarity index 100% rename from api/pages/issue/age.py rename to kibble/api/pages/issue/age.py diff --git a/api/pages/issue/closers.py b/kibble/api/pages/issue/closers.py similarity index 100% rename from api/pages/issue/closers.py rename to kibble/api/pages/issue/closers.py diff --git a/api/pages/issue/issues.py b/kibble/api/pages/issue/issues.py similarity index 100% rename from api/pages/issue/issues.py rename to kibble/api/pages/issue/issues.py diff --git a/api/pages/issue/openers.py b/kibble/api/pages/issue/openers.py similarity index 100% rename from api/pages/issue/openers.py rename to kibble/api/pages/issue/openers.py diff --git a/api/pages/issue/pony-timeseries.py b/kibble/api/pages/issue/pony-timeseries.py similarity index 100% rename from api/pages/issue/pony-timeseries.py rename to kibble/api/pages/issue/pony-timeseries.py diff --git a/api/pages/issue/relationships.py b/kibble/api/pages/issue/relationships.py similarity index 100% rename from api/pages/issue/relationships.py rename to kibble/api/pages/issue/relationships.py diff --git a/api/pages/issue/retention.py b/kibble/api/pages/issue/retention.py similarity index 100% rename from api/pages/issue/retention.py rename to kibble/api/pages/issue/retention.py diff --git a/api/pages/issue/top-count.py b/kibble/api/pages/issue/top-count.py similarity index 100% rename from api/pages/issue/top-count.py rename to kibble/api/pages/issue/top-count.py diff --git a/api/pages/issue/top.py b/kibble/api/pages/issue/top.py similarity index 100% rename from api/pages/issue/top.py rename to kibble/api/pages/issue/top.py diff --git a/api/pages/issue/trends.py b/kibble/api/pages/issue/trends.py similarity index 100% rename from api/pages/issue/trends.py rename to kibble/api/pages/issue/trends.py diff --git a/api/pages/mail/keyphrases.py b/kibble/api/pages/mail/keyphrases.py similarity index 100% rename from api/pages/mail/keyphrases.py rename to kibble/api/pages/mail/keyphrases.py diff --git a/api/pages/mail/map.py b/kibble/api/pages/mail/map.py similarity index 100% rename from api/pages/mail/map.py rename to kibble/api/pages/mail/map.py diff --git a/api/pages/mail/mood-timeseries.py b/kibble/api/pages/mail/mood-timeseries.py similarity index 100% rename from api/pages/mail/mood-timeseries.py rename to kibble/api/pages/mail/mood-timeseries.py diff --git a/api/pages/mail/mood.py b/kibble/api/pages/mail/mood.py similarity index 100% rename from api/pages/mail/mood.py rename to kibble/api/pages/mail/mood.py diff --git a/api/pages/mail/pony-timeseries.py b/kibble/api/pages/mail/pony-timeseries.py similarity index 100% rename from api/pages/mail/pony-timeseries.py rename to kibble/api/pages/mail/pony-timeseries.py diff --git a/api/pages/mail/relationships.py b/kibble/api/pages/mail/relationships.py similarity index 100% rename from api/pages/mail/relationships.py rename to kibble/api/pages/mail/relationships.py diff --git a/api/pages/mail/retention.py b/kibble/api/pages/mail/retention.py similarity index 100% rename from api/pages/mail/retention.py rename to kibble/api/pages/mail/retention.py diff --git a/api/pages/mail/timeseries-single.py b/kibble/api/pages/mail/timeseries-single.py similarity index 100% rename from api/pages/mail/timeseries-single.py rename to kibble/api/pages/mail/timeseries-single.py diff --git a/api/pages/mail/timeseries.py b/kibble/api/pages/mail/timeseries.py similarity index 100% rename from api/pages/mail/timeseries.py rename to kibble/api/pages/mail/timeseries.py diff --git a/api/pages/mail/top-authors.py b/kibble/api/pages/mail/top-authors.py similarity index 100% rename from api/pages/mail/top-authors.py rename to kibble/api/pages/mail/top-authors.py diff --git a/api/pages/mail/top-topics.py b/kibble/api/pages/mail/top-topics.py similarity index 100% rename from api/pages/mail/top-topics.py rename to kibble/api/pages/mail/top-topics.py diff --git a/api/pages/mail/trends.py b/kibble/api/pages/mail/trends.py similarity index 100% rename from api/pages/mail/trends.py rename to kibble/api/pages/mail/trends.py diff --git a/api/pages/org/contributors.py b/kibble/api/pages/org/contributors.py similarity index 100% rename from api/pages/org/contributors.py rename to kibble/api/pages/org/contributors.py diff --git a/api/pages/org/list.py b/kibble/api/pages/org/list.py similarity index 100% rename from api/pages/org/list.py rename to kibble/api/pages/org/list.py diff --git a/api/pages/org/members.py b/kibble/api/pages/org/members.py similarity index 100% rename from api/pages/org/members.py rename to kibble/api/pages/org/members.py diff --git a/api/pages/org/sourcetypes.py b/kibble/api/pages/org/sourcetypes.py similarity index 93% rename from api/pages/org/sourcetypes.py rename to kibble/api/pages/org/sourcetypes.py index 8c41b007..005f3c87 100644 --- a/api/pages/org/sourcetypes.py +++ b/kibble/api/pages/org/sourcetypes.py @@ -68,12 +68,16 @@ """ This is the source types handler for Kibble """ +import os import yaml import json -def run(API, environ, indata, session): +from kibble.settings import YAML_DIRECTORY + - types = yaml.load(open("yaml/sourcetypes.yaml")) +def run(API, environ, indata, session): + with open(os.path.join(YAML_DIRECTORY, "sourcetypes.yaml")) as f: + types = yaml.load(f) yield json.dumps(types) diff --git a/api/pages/org/trends.py b/kibble/api/pages/org/trends.py similarity index 100% rename from api/pages/org/trends.py rename to kibble/api/pages/org/trends.py diff --git a/api/pages/session.py b/kibble/api/pages/session.py similarity index 100% rename from api/pages/session.py rename to kibble/api/pages/session.py diff --git a/api/pages/sources.py b/kibble/api/pages/sources.py similarity index 98% rename from api/pages/sources.py rename to kibble/api/pages/sources.py index 86626847..49f9fec6 100644 --- a/api/pages/sources.py +++ b/kibble/api/pages/sources.py @@ -128,11 +128,15 @@ """ import json +import os import re import time import hashlib import yaml +from kibble.settings import YAML_DIRECTORY + + def canModifySource(session): """ Determine if the user can edit sources in this org """ @@ -224,7 +228,8 @@ def run(API, environ, indata, session): if canModifySource(session): new = 0 old = 0 - stypes = yaml.load(open("yaml/sourcetypes.yaml")) + with open(os.path.join(YAML_DIRECTORY, "sourcetypes.yaml")) as f: + stypes = yaml.load(f) for source in indata.get('sources', []): sourceURL = source['sourceURL'] sourceType = source['type'] diff --git a/api/pages/verify.py b/kibble/api/pages/verify.py similarity index 100% rename from api/pages/verify.py rename to kibble/api/pages/verify.py diff --git a/api/pages/views.py b/kibble/api/pages/views.py similarity index 100% rename from api/pages/views.py rename to kibble/api/pages/views.py diff --git a/api/pages/widgets.py b/kibble/api/pages/widgets.py similarity index 93% rename from api/pages/widgets.py rename to kibble/api/pages/widgets.py index db3f5fdf..6b101e21 100644 --- a/api/pages/widgets.py +++ b/kibble/api/pages/widgets.py @@ -46,16 +46,21 @@ """ This is the widget design handler for Kibble """ +import os import yaml import json +from kibble.settings import YAML_DIRECTORY + + def run(API, environ, indata, session): if not session.user: raise API.exception(403, "You must be logged in to use this API endpoint! %s") - widgets = yaml.load(open("yaml/widgets.yaml")) + with open(os.path.join(YAML_DIRECTORY, "widgets.yaml")) as f: + widgets = yaml.load(f) page = indata['pageid'] if not page or page == '0': diff --git a/api/plugins/database.py b/kibble/api/plugins/database.py similarity index 100% rename from api/plugins/database.py rename to kibble/api/plugins/database.py diff --git a/api/plugins/openapi.py b/kibble/api/plugins/openapi.py similarity index 100% rename from api/plugins/openapi.py rename to kibble/api/plugins/openapi.py diff --git a/api/plugins/session.py b/kibble/api/plugins/session.py similarity index 100% rename from api/plugins/session.py rename to kibble/api/plugins/session.py diff --git a/api/yaml/openapi.yaml b/kibble/api/yaml/openapi.yaml similarity index 100% rename from api/yaml/openapi.yaml rename to kibble/api/yaml/openapi.yaml diff --git a/api/yaml/openapi/combine.py b/kibble/api/yaml/openapi/combine.py similarity index 96% rename from api/yaml/openapi/combine.py rename to kibble/api/yaml/openapi/combine.py index 689a0f2f..962021ca 100644 --- a/api/yaml/openapi/combine.py +++ b/kibble/api/yaml/openapi/combine.py @@ -20,6 +20,8 @@ import sys import re +from kibble.settings import YAML_DIRECTORY + baseyaml = """ # THIS IS PULLED FROM SCRIPTS AND AUTOGENERATED! # Please use openapi/combine.py to regenerate! @@ -106,7 +108,8 @@ def construct(): if fname.endswith(".py"): fpath = "%s/%s" % (apidir, fname) print("Scanning %s" % fpath) - contents = open(fpath, "r").read() + with open(fpath, "r") as f: + contents = f.read() m = re.search(r"OPENAPI-URI: (\S+)\n##+\n([\s\S]+?)##+", contents) if m: apath = m.group(1) @@ -128,7 +131,7 @@ def construct(): print("Scanning %s" % fpath) defs = yaml.load(open(fpath)) yml['components'][d][fname.replace(".yaml", "")] = defs - ypath = os.path.abspath("%s/../openapi.yaml" % bpath) + ypath = os.path.join(YAML_DIRECTORY, "openapi.yaml") with open(ypath, "w") as f: f.write(baseyaml) f.write(yaml.dump(yml, default_flow_style=False)) diff --git a/api/yaml/openapi/components/schemas/ActionCompleted.yaml b/kibble/api/yaml/openapi/components/schemas/ActionCompleted.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/ActionCompleted.yaml rename to kibble/api/yaml/openapi/components/schemas/ActionCompleted.yaml diff --git a/api/yaml/openapi/components/schemas/Biography.yaml b/kibble/api/yaml/openapi/components/schemas/Biography.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/Biography.yaml rename to kibble/api/yaml/openapi/components/schemas/Biography.yaml diff --git a/api/yaml/openapi/components/schemas/CommitterList.yaml b/kibble/api/yaml/openapi/components/schemas/CommitterList.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/CommitterList.yaml rename to kibble/api/yaml/openapi/components/schemas/CommitterList.yaml diff --git a/api/yaml/openapi/components/schemas/Empty.yaml b/kibble/api/yaml/openapi/components/schemas/Empty.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/Empty.yaml rename to kibble/api/yaml/openapi/components/schemas/Empty.yaml diff --git a/api/yaml/openapi/components/schemas/Error.yaml b/kibble/api/yaml/openapi/components/schemas/Error.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/Error.yaml rename to kibble/api/yaml/openapi/components/schemas/Error.yaml diff --git a/api/yaml/openapi/components/schemas/Factor.yaml b/kibble/api/yaml/openapi/components/schemas/Factor.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/Factor.yaml rename to kibble/api/yaml/openapi/components/schemas/Factor.yaml diff --git a/api/yaml/openapi/components/schemas/NewOrg.yaml b/kibble/api/yaml/openapi/components/schemas/NewOrg.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/NewOrg.yaml rename to kibble/api/yaml/openapi/components/schemas/NewOrg.yaml diff --git a/api/yaml/openapi/components/schemas/OrgMembers.yaml b/kibble/api/yaml/openapi/components/schemas/OrgMembers.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/OrgMembers.yaml rename to kibble/api/yaml/openapi/components/schemas/OrgMembers.yaml diff --git a/api/yaml/openapi/components/schemas/Organisation.yaml b/kibble/api/yaml/openapi/components/schemas/Organisation.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/Organisation.yaml rename to kibble/api/yaml/openapi/components/schemas/Organisation.yaml diff --git a/api/yaml/openapi/components/schemas/Phrase.yaml b/kibble/api/yaml/openapi/components/schemas/Phrase.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/Phrase.yaml rename to kibble/api/yaml/openapi/components/schemas/Phrase.yaml diff --git a/api/yaml/openapi/components/schemas/PhraseList.yaml b/kibble/api/yaml/openapi/components/schemas/PhraseList.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/PhraseList.yaml rename to kibble/api/yaml/openapi/components/schemas/PhraseList.yaml diff --git a/api/yaml/openapi/components/schemas/Sloc.yaml b/kibble/api/yaml/openapi/components/schemas/Sloc.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/Sloc.yaml rename to kibble/api/yaml/openapi/components/schemas/Sloc.yaml diff --git a/api/yaml/openapi/components/schemas/Source.yaml b/kibble/api/yaml/openapi/components/schemas/Source.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/Source.yaml rename to kibble/api/yaml/openapi/components/schemas/Source.yaml diff --git a/api/yaml/openapi/components/schemas/SourceID.yaml b/kibble/api/yaml/openapi/components/schemas/SourceID.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/SourceID.yaml rename to kibble/api/yaml/openapi/components/schemas/SourceID.yaml diff --git a/api/yaml/openapi/components/schemas/SourceList.yaml b/kibble/api/yaml/openapi/components/schemas/SourceList.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/SourceList.yaml rename to kibble/api/yaml/openapi/components/schemas/SourceList.yaml diff --git a/api/yaml/openapi/components/schemas/SourceListAdd.yaml b/kibble/api/yaml/openapi/components/schemas/SourceListAdd.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/SourceListAdd.yaml rename to kibble/api/yaml/openapi/components/schemas/SourceListAdd.yaml diff --git a/api/yaml/openapi/components/schemas/SourceType.yaml b/kibble/api/yaml/openapi/components/schemas/SourceType.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/SourceType.yaml rename to kibble/api/yaml/openapi/components/schemas/SourceType.yaml diff --git a/api/yaml/openapi/components/schemas/SourceTypes.yaml b/kibble/api/yaml/openapi/components/schemas/SourceTypes.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/SourceTypes.yaml rename to kibble/api/yaml/openapi/components/schemas/SourceTypes.yaml diff --git a/api/yaml/openapi/components/schemas/Timeseries.yaml b/kibble/api/yaml/openapi/components/schemas/Timeseries.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/Timeseries.yaml rename to kibble/api/yaml/openapi/components/schemas/Timeseries.yaml diff --git a/api/yaml/openapi/components/schemas/TimeseriesObject.yaml b/kibble/api/yaml/openapi/components/schemas/TimeseriesObject.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/TimeseriesObject.yaml rename to kibble/api/yaml/openapi/components/schemas/TimeseriesObject.yaml diff --git a/api/yaml/openapi/components/schemas/TopList.yaml b/kibble/api/yaml/openapi/components/schemas/TopList.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/TopList.yaml rename to kibble/api/yaml/openapi/components/schemas/TopList.yaml diff --git a/api/yaml/openapi/components/schemas/Trend.yaml b/kibble/api/yaml/openapi/components/schemas/Trend.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/Trend.yaml rename to kibble/api/yaml/openapi/components/schemas/Trend.yaml diff --git a/api/yaml/openapi/components/schemas/UserAccount.yaml b/kibble/api/yaml/openapi/components/schemas/UserAccount.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/UserAccount.yaml rename to kibble/api/yaml/openapi/components/schemas/UserAccount.yaml diff --git a/api/yaml/openapi/components/schemas/UserAccountEdit.yaml b/kibble/api/yaml/openapi/components/schemas/UserAccountEdit.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/UserAccountEdit.yaml rename to kibble/api/yaml/openapi/components/schemas/UserAccountEdit.yaml diff --git a/api/yaml/openapi/components/schemas/UserCredentials.yaml b/kibble/api/yaml/openapi/components/schemas/UserCredentials.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/UserCredentials.yaml rename to kibble/api/yaml/openapi/components/schemas/UserCredentials.yaml diff --git a/api/yaml/openapi/components/schemas/UserData.yaml b/kibble/api/yaml/openapi/components/schemas/UserData.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/UserData.yaml rename to kibble/api/yaml/openapi/components/schemas/UserData.yaml diff --git a/api/yaml/openapi/components/schemas/UserName.yaml b/kibble/api/yaml/openapi/components/schemas/UserName.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/UserName.yaml rename to kibble/api/yaml/openapi/components/schemas/UserName.yaml diff --git a/api/yaml/openapi/components/schemas/View.yaml b/kibble/api/yaml/openapi/components/schemas/View.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/View.yaml rename to kibble/api/yaml/openapi/components/schemas/View.yaml diff --git a/api/yaml/openapi/components/schemas/ViewList.yaml b/kibble/api/yaml/openapi/components/schemas/ViewList.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/ViewList.yaml rename to kibble/api/yaml/openapi/components/schemas/ViewList.yaml diff --git a/api/yaml/openapi/components/schemas/WidgetApp.yaml b/kibble/api/yaml/openapi/components/schemas/WidgetApp.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/WidgetApp.yaml rename to kibble/api/yaml/openapi/components/schemas/WidgetApp.yaml diff --git a/api/yaml/openapi/components/schemas/WidgetDesign.yaml b/kibble/api/yaml/openapi/components/schemas/WidgetDesign.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/WidgetDesign.yaml rename to kibble/api/yaml/openapi/components/schemas/WidgetDesign.yaml diff --git a/api/yaml/openapi/components/schemas/WidgetRow.yaml b/kibble/api/yaml/openapi/components/schemas/WidgetRow.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/WidgetRow.yaml rename to kibble/api/yaml/openapi/components/schemas/WidgetRow.yaml diff --git a/api/yaml/openapi/components/schemas/defaultWidgetArgs.yaml b/kibble/api/yaml/openapi/components/schemas/defaultWidgetArgs.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/defaultWidgetArgs.yaml rename to kibble/api/yaml/openapi/components/schemas/defaultWidgetArgs.yaml diff --git a/api/yaml/openapi/components/schemas/editView.yaml b/kibble/api/yaml/openapi/components/schemas/editView.yaml similarity index 100% rename from api/yaml/openapi/components/schemas/editView.yaml rename to kibble/api/yaml/openapi/components/schemas/editView.yaml diff --git a/api/yaml/openapi/components/securitySchemes/cookieAuth.yaml b/kibble/api/yaml/openapi/components/securitySchemes/cookieAuth.yaml similarity index 100% rename from api/yaml/openapi/components/securitySchemes/cookieAuth.yaml rename to kibble/api/yaml/openapi/components/securitySchemes/cookieAuth.yaml diff --git a/api/yaml/sourcetypes.yaml b/kibble/api/yaml/sourcetypes.yaml similarity index 100% rename from api/yaml/sourcetypes.yaml rename to kibble/api/yaml/sourcetypes.yaml diff --git a/api/yaml/widgets.yaml b/kibble/api/yaml/widgets.yaml similarity index 100% rename from api/yaml/widgets.yaml rename to kibble/api/yaml/widgets.yaml diff --git a/kibble/settings.py b/kibble/settings.py new file mode 100644 index 00000000..db2c1bc8 --- /dev/null +++ b/kibble/settings.py @@ -0,0 +1,25 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import os + +YAML_DIRECTORY = os.path.join( + os.path.dirname(os.path.realpath(__file__)), + "api", + "yaml", +) +KIBBLE_YAML = os.path.join(YAML_DIRECTORY, "kibble.yaml") diff --git a/setup/kibble.yaml.sample b/kibble/setup/kibble.yaml.sample similarity index 100% rename from setup/kibble.yaml.sample rename to kibble/setup/kibble.yaml.sample diff --git a/setup/makeaccount.py b/kibble/setup/makeaccount.py similarity index 96% rename from setup/makeaccount.py rename to kibble/setup/makeaccount.py index 64015bb6..1f169d37 100644 --- a/setup/makeaccount.py +++ b/kibble/setup/makeaccount.py @@ -21,6 +21,9 @@ import yaml import bcrypt +from kibble.settings import YAML_DIRECTORY, KIBBLE_YAML + + class KibbleDatabase(object): def __init__(self, config): self.config = config @@ -49,7 +52,8 @@ def __init__(self, config): args = arg_parser.parse_args() # Load Kibble master configuration -config = yaml.load(open("../api/yaml/kibble.yaml")) +with open(KIBBLE_YAML) as f: + config = yaml.load(f) DB = KibbleDatabase(config) diff --git a/setup/mappings.json b/kibble/setup/mappings.json similarity index 100% rename from setup/mappings.json rename to kibble/setup/mappings.json diff --git a/setup/setup.py b/kibble/setup/setup.py similarity index 98% rename from setup/setup.py rename to kibble/setup/setup.py index 689a2971..c204457b 100644 --- a/setup/setup.py +++ b/kibble/setup/setup.py @@ -29,6 +29,8 @@ import json from elasticsearch import Elasticsearch +from kibble.settings import KIBBLE_YAML + KIBBLE_VERSION = '0.1.0' # ABI/API compat demarcation. KIBBLE_DB_VERSION = 2 # Second database revision @@ -219,13 +221,7 @@ def create_es_index( def get_kibble_yaml() -> str: """Resolve path to kibble config yaml""" - kibble_yaml = os.path.join( - os.path.dirname(os.path.realpath(__file__)), - os.pardir, - "api", - "yaml", - "kibble.yaml" - ) + kibble_yaml = KIBBLE_YAML if os.path.exists(kibble_yaml): print(f"{kibble_yaml} already exists! Writing to {kibble_yaml}.tmp instead") kibble_yaml = kibble_yaml + ".tmp" diff --git a/kibble/version.py b/kibble/version.py new file mode 100644 index 00000000..a913b5ac --- /dev/null +++ b/kibble/version.py @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +version = "1.0.0dev" diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 00000000..b3135bb3 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,36 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +[metadata] +name = Kibble +summary = Apache Kibble is a tool to collect, aggregate and visualize data about any software project that uses commonly known tools. +description-file = README.md +author = Apache Kibble +author-email = dev@kibble.apache.org +license = Apache License, Version 2.0 +license_files = + LICENSE + NOTICE + +[bdist_wheel] +python-tag=py3 + + +[files] +packages = kibble + +[easy_install] diff --git a/setup.py b/setup.py new file mode 100644 index 00000000..4208d68e --- /dev/null +++ b/setup.py @@ -0,0 +1,111 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import os +from importlib import util + +from setuptools import find_packages, setup + +# Kept manually in sync with kibble.version +spec = util.spec_from_file_location("kibble.version", os.path.join('kibble', 'version.py')) # noqa +mod = util.module_from_spec(spec) +spec.loader.exec_module(mod) # type: ignore +version = mod.version # type: ignore + +DEVEL_REQUIREMENTS = [ + "pre-commit==2.7.1", +] + +INSTALL_REQUIREMENTS = [ + "bcrypt==3.2.0", + "certifi==2020.6.20", + "elasticsearch==7.9.1", + "gunicorn==20.0.4", + "python-dateutil==2.8.1", + "PyYAML==5.3.1", + "tenacity==6.2.0", +] + +EXTRAS_REQUIREMENTS = { + "devel": DEVEL_REQUIREMENTS +} + + +def get_long_description(): + description = "" + try: + with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), 'README.md'), encoding='utf-8') as f: + description = f.read() + except FileNotFoundError: + pass + return description + + +def do_setup(): + """Perform the Kibble package setup.""" + setup( + name='apache-kibble', + description="Apache Kibble is a tool to collect, aggregate and visualize data about any software project.", + long_description=get_long_description(), + long_description_content_type='text/markdown', + license='Apache License 2.0', + version=version, + packages=find_packages(include=['kibble*']), + package_data={ + 'kibble': ['py.typed'], + 'kibble.api.yaml': ['*.yaml'], + }, + include_package_data=True, + zip_safe=False, + entry_points={ + "console_scripts": [ + "kibble = kibble.__main__:main", + ], + }, + install_requires=INSTALL_REQUIREMENTS, + setup_requires=[ + 'docutils', + 'gitpython', + 'setuptools', + 'wheel', + ], + extras_require=EXTRAS_REQUIREMENTS, + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Environment :: Console', + 'Environment :: Web Environment', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'License :: OSI Approved :: Apache Software License', + 'Programming Language :: Python :: 3.8', + ], + author='Apache Software Foundation', + author_email='dev@kibble.apache.org', + url='http://kibble.apache.org/', + download_url=f'https://archive.apache.org/dist/kibble/{version}', + test_suite='setup.kibble_test_suite', + python_requires='~=3.8', + project_urls={ + 'Documentation': 'https://kibble.apache.org/docs/', + 'Bug Tracker': 'https://github.com/apache/kibble/issues', + 'Source Code': 'https://github.com/apache/kibble', + }, + ) + + +if __name__ == "__main__": + do_setup() diff --git a/setup/requirements.txt b/setup/requirements.txt deleted file mode 100644 index 6a2d1f3a..00000000 --- a/setup/requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -bcrypt==3.2.0 -certifi==2020.6.20 -elasticsearch==7.9.1 -gunicorn==20.0.4 -pre-commit==2.7.1 -python-dateutil==2.8.1 -PyYAML==5.3.1 -tenacity==6.2.0