hub.sr.ht/setup.py
Eli Schwartz 23e980fc74 setup.py: use importlib.resources from python 3.7 to find core.sr.ht Makefile
importlib.resources will guarantee to find any importable module, and
check that the resource ('Makefile') can be found within it.

This lets us get rid of the current getsitepackages() hack and
environment variable fallback, which is both verbose and badly handles
some edge cases when installing modules, and instead use the recommended
way to find data files shipped with a python module.
2020-05-11 09:36:29 -04:00

47 lines
1.1 KiB
Python
Executable file

#!/usr/bin/env python3
from distutils.core import setup
import subprocess
import os
import sys
import importlib.resources
with importlib.resources.path('srht', 'Makefile') as f:
srht_path = f.parent.as_posix()
make = os.environ.get("MAKE", "make")
subp = subprocess.run([make, "SRHT_PATH=" + srht_path])
if subp.returncode != 0:
sys.exit(subp.returncode)
ver = os.environ.get("PKGVER") or subprocess.run(['git', 'describe', '--tags'],
stdout=subprocess.PIPE).stdout.decode().strip()
setup(
name = 'hubsrht',
packages = [
'hubsrht',
'hubsrht.alembic',
'hubsrht.alembic.versions',
'hubsrht.blueprints',
'hubsrht.types',
],
version = ver,
description = 'hub.sr.ht website',
author = 'Drew DeVault',
author_email = 'sir@cmpwn.com',
url = 'https://git.sr.ht/~sircmpwn/hub.sr.ht',
install_requires = ['srht'],
license = 'AGPL-3.0',
package_data={
'hubsrht': [
'templates/*.html',
'static/*',
'static/icons/*',
]
},
scripts = [
'hubsrht-initdb',
'hubsrht-migrate',
]
)