2017-11-03 12:41:15 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2024-05-17 00:47:23 +02:00
|
|
|
import json
|
2017-11-03 12:34:47 +01:00
|
|
|
import os
|
2024-05-17 00:47:23 +02:00
|
|
|
|
2020-06-10 12:37:26 +02:00
|
|
|
from setuptools import setup, find_packages
|
2017-11-03 12:34:47 +01:00
|
|
|
|
2019-05-23 18:51:28 +02:00
|
|
|
|
2024-07-27 16:22:14 +02:00
|
|
|
def path(fname=''):
|
|
|
|
return os.path.abspath(os.path.join(os.path.dirname(__file__), fname))
|
|
|
|
|
|
|
|
|
|
|
|
def readfile(fname):
|
|
|
|
with open(path(fname)) as f:
|
|
|
|
return f.read()
|
|
|
|
|
|
|
|
|
2024-05-17 00:47:23 +02:00
|
|
|
def scan_manifests():
|
|
|
|
for root, _, files in os.walk('platypush'):
|
|
|
|
for file in files:
|
|
|
|
if file == 'manifest.json':
|
|
|
|
yield os.path.join(root, file)
|
|
|
|
|
|
|
|
|
|
|
|
def parse_deps(deps):
|
|
|
|
ret = []
|
|
|
|
for dep in deps:
|
|
|
|
if dep.startswith('git+'):
|
2024-07-27 15:12:19 +02:00
|
|
|
continue # Don't include git dependencies in pip, or Twine will complain
|
2024-05-17 00:47:23 +02:00
|
|
|
|
|
|
|
ret.append(dep)
|
|
|
|
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
|
|
|
def parse_manifest(manifest_file):
|
|
|
|
with open(manifest_file) as f:
|
|
|
|
manifest = json.load(f).get('manifest')
|
|
|
|
if not manifest:
|
|
|
|
return None, None
|
|
|
|
|
|
|
|
name = '.'.join(manifest['package'].split('.')[2:])
|
|
|
|
return name, parse_deps(manifest.get('install', {}).get('pip', []))
|
|
|
|
|
|
|
|
|
|
|
|
def parse_manifests():
|
|
|
|
ret = {}
|
|
|
|
for manifest_file in scan_manifests():
|
|
|
|
name, deps = parse_manifest(manifest_file)
|
|
|
|
if deps:
|
|
|
|
ret[name] = deps
|
|
|
|
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
2017-11-03 12:34:47 +01:00
|
|
|
setup(
|
2023-05-03 21:45:02 +02:00
|
|
|
packages=find_packages(exclude=['tests']),
|
2020-01-01 15:40:42 +01:00
|
|
|
include_package_data=True,
|
2024-05-17 00:47:23 +02:00
|
|
|
extras_require=parse_manifests(),
|
2024-07-27 16:22:14 +02:00
|
|
|
package_data={
|
|
|
|
'platypush': [
|
|
|
|
'migrations/alembic.ini',
|
|
|
|
'migrations/alembic/*',
|
|
|
|
'migrations/alembic/**/*',
|
|
|
|
'install/**',
|
|
|
|
'install/scripts/*',
|
|
|
|
'install/scripts/**/*',
|
|
|
|
'install/requirements/*',
|
|
|
|
'install/docker/*',
|
|
|
|
'components.json.gz',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
entry_points={
|
|
|
|
'console_scripts': [
|
|
|
|
'platypush=platypush:main',
|
|
|
|
'platydock=platypush.platydock:main',
|
|
|
|
'platyvenv=platypush.platyvenv:main',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
install_requires=[
|
|
|
|
line.split('#')[0].strip()
|
|
|
|
for line in readfile('requirements.txt').splitlines()
|
|
|
|
if line.strip().split('#')[0].strip()
|
|
|
|
],
|
2017-11-03 12:34:47 +01:00
|
|
|
)
|