Verified Commit 748534c9 authored by Max Rees's avatar Max Rees

Make it packageable

parent b7183f21
# vi: noet
PREFIX = usr
SYSCONFDIR = etc/apkvitrine
WEBAPPDIR = $(PREFIX)/share/webapps/apkvitrine
PYTHON = python3
DESTDIR = target
-include config.mk
PYLINT = pylint
SETUP.PY = $(PYTHON) src/setup.py
# These are needed by setup.py
export SYSCONFDIR WEBAPPDIR
PYLINT_TARGETS = \
apkvitrine
CLEAN_TARGETS = \
MANIFEST \
apkvitrine.egg-info \
build \
dist \
target
CGI.PY = site-packages/apkvitrine/cgi.py
BUILD_DB.PY = site-packages/apkvitrine/build_db.py
.PHONY: all
all:
$(SETUP.PY) build
.PHONY: paths
paths:
@printf 'CONF: SYSCONFDIR = "%s"\n' '$(SYSCONFDIR)'
@sed -i \
-e '/^SYSCONFDIR = /s@= .*@= Path("/$(SYSCONFDIR)")@' \
apkvitrine/__init__.py
.PHONY: install
install: paths all
$(SETUP.PY) install \
--root="$(DESTDIR)" \
--prefix="/$(PREFIX)"
mv "$(DESTDIR)/$(PREFIX)/bin/apkvitrine.cgi" \
"$(DESTDIR)/$(WEBAPPDIR)"
.PHONY: clean
clean:
rm -rf $(CLEAN_TARGETS)
#
# Maintainer targets:
#
.PHONY: dist
dist: clean
$(SETUP.PY) sdist -u root -g root -t src/MANIFEST.in
.PHONY: pylint
pylint:
-$(PYLINT) --rcfile src/pylintrc $(PYLINT_TARGETS)
.PHONY: lint
lint: pylint
.PHONY: setup
setup:
@$(SETUP.PY) $(SETUP_ARGS)
......@@ -5,9 +5,12 @@ import collections # defaultdict
import configparser # ConfigParser
from pathlib import Path
VERSION = "0.1"
BUILDERS = "@builders"
DEFAULT = "@default"
SYSCONFDIR = Path(__file__).parent.parent
def _config_map(s):
d = {}
for i in s.strip().splitlines():
......@@ -43,8 +46,7 @@ def _ConfigParser(**kwargs):
def config(version=None):
config = _ConfigParser()
files = sorted(Path("/etc/apkvitrine").glob("*.ini"))
files.append(Path(__file__).parent.parent / "config.ini")
files = sorted(SYSCONFDIR.glob("*.ini"))
config.read(files)
if version:
return config[version]
......
#!/usr/bin/env python3
# SPDX-License-Identifier: NCSA
# Copyright (c) 2020 Max Rees
# See LICENSE for more information.
......@@ -7,6 +6,7 @@ import collections # defaultdict
import datetime # datetime
import json # load
import logging
import pkgutil # get_data
import sqlite3 # connect
import urllib.parse # urlencode
import urllib.request # Request, urlopen
......@@ -26,7 +26,7 @@ def init_db(name):
Path(name).unlink()
except FileNotFoundError:
pass
schema = Path("schema.sql").read_text().strip()
schema = pkgutil.get_data("apkvitrine", "data/schema.sql").decode("utf-8")
db = sqlite3.connect(str(name))
db.executescript(schema)
return db
......
#!/usr/bin/env python3
# SPDX-License-Identifier: NCSA
# Copyright (c) 2020 Max Rees
# See LICENSE for more information.
......@@ -13,6 +12,7 @@ from pathlib import Path
import flup.server.fcgi as flup # WSGIServer
import jinja2 # Environment, FileSystemBytecodeCache, Markup, PackageLoader
# environmentfilter
import apkvitrine # BUILDERS, config, DEFAULT
import apkvitrine.models # build_search, Pkg
......@@ -317,7 +317,7 @@ class APKVitrineApp: # pylint: disable=too-many-instance-attributes
def __init__(self):
self.jinja = jinja2.Environment(
loader=jinja2.PackageLoader("apkvitrine", "templates"),
loader=jinja2.PackageLoader("apkvitrine", "data"),
autoescape=True,
trim_blocks=True,
bytecode_cache=jinja2.FileSystemBytecodeCache(),
......@@ -429,6 +429,9 @@ class APKVitrineApp: # pylint: disable=too-many-instance-attributes
)
return []
if __name__ == "__main__":
def main():
app = APKVitrineApp()
flup.WSGIServer(app.handle).run()
if __name__ == "__main__":
main()
graft src
include LICENSE
include Makefile
include README.rst
This diff is collapsed.
#!/usr/bin/env python3
import distutils.core # setup
import glob # glob
import os # environ
import sys # path
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent))
import apkvitrine # VERSION
def get_path(name):
return Path("/" + os.environ[name].strip("/"))
sysconfdir = get_path("SYSCONFDIR")
webdir = get_path("WEBAPPDIR")
distutils.core.setup(
name="apkvitrine",
version=apkvitrine.VERSION,
url="https://code.foxkit.us/sroracle/apkvitrine",
author="Max Rees",
author_email="maxcrees@me.com",
classifiers=[
"Development Status :: 4 - Beta",
"Environment :: Console",
"Environment :: Web Environment",
"License :: OSI Approved :: University of Illinois/NCSA Open Source License",
"Natural Language :: English",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Topic :: Database :: Front-Ends",
"Topic :: Internet :: WWW/HTTP :: WSGI :: Application",
"Topic :: System :: Software Distribution",
],
license="NCSA",
description="Package tracker and analyzer for APK repositories",
long_description=Path("README.rst").read_text(),
script_name="src/setup.py",
packages=["apkvitrine"],
package_data={"apkvitrine": [
"data/*",
]},
scripts=["webapp/apkvitrine.cgi"],
data_files=[
(
str(sysconfdir),
["config.ini.in"],
),
(
str(webdir),
glob.glob("webapp/style.css"),
),
],
)
#!/usr/bin/env python3
# SPDX-License-Identifier: NCSA
# Copyright (c) 2020 Max Rees
# See LICENSE for more information.
import apkvitrine.cgi
apkvitrine.cgi.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment