forked from sovrin-foundation/old-sovrin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-dev.py
100 lines (88 loc) · 3.69 KB
/
setup-dev.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import glob
import os
import shutil
import sys
from shutil import copyfile
from setuptools import setup, find_packages, __version__
import data
import sample
v = sys.version_info
if sys.version_info < (3, 5):
msg = "FAIL: Requires Python 3.5 or later, " \
"but setup.py was run using {}.{}.{}"
v = sys.version_info
print(msg.format(v.major, v.minor, v.micro))
print("NOTE: Installation failed. Run setup.py using python3")
sys.exit(1)
# Change to ioflo's source directory prior to running any command
try:
SETUP_DIRNAME = os.path.dirname(__file__)
except NameError:
# We're probably being frozen, and __file__ triggered this NameError
# Work around this
SETUP_DIRNAME = os.path.dirname(sys.argv[0])
if SETUP_DIRNAME != '':
os.chdir(SETUP_DIRNAME)
SETUP_DIRNAME = os.path.abspath(SETUP_DIRNAME)
METADATA = os.path.join(SETUP_DIRNAME, 'sovrin', '__metadata__.py')
# Load the metadata using exec() so we don't trigger an import of ioflo.__init__
exec(compile(open(METADATA).read(), METADATA, 'exec'))
BASE_DIR = os.path.join(os.path.expanduser("~"), ".sovrin")
CONFIG_FILE = os.path.join(BASE_DIR, "sovrin_config.py")
POOL_TXN_FILE = os.path.join(BASE_DIR, "pool_transactions_sandbox")
POOL_TXN_LOCAL_FILE = os.path.join(BASE_DIR, "pool_transactions_local")
IDENTITY_TXN_FILE = os.path.join(BASE_DIR, "transactions_sandbox")
IDENTITY_TXN_LOCAL_FILE = os.path.join(BASE_DIR, "transactions_local")
if not os.path.exists(BASE_DIR):
os.makedirs(BASE_DIR)
setup(
name='sovrin-dev',
version=__version__,
description='Sovrin Identity',
long_description='Sovrin Identity',
url='https://github.com/evernym/sovrin-priv',
author=__author__,
author_email='[email protected]',
license=__license__,
keywords='Sovrin identity plenum',
packages=find_packages(exclude=['test', 'test.*', 'docs', 'docs*']) + [
'data', 'sample'],
package_data={
'': ['*.txt', '*.md', '*.rst', '*.json', '*.conf', '*.html',
'*.css', '*.ico', '*.png', 'LICENSE', 'LEGAL', '*.sovrin']},
include_package_data=True,
data_files=[(
(BASE_DIR, ['data/pool_transactions_sandbox',
'data/pool_transactions_local',
'data/transactions_sandbox',
'data/transactions_local',
])
)],
install_requires=['base58', 'pyorient', 'plenum-dev', 'ledger-dev',
'semver', 'anoncreds-dev'],
setup_requires=['pytest-runner'],
tests_require=['pytest'],
scripts=['scripts/sovrin', 'scripts/init_sovrin_raet_keep',
'scripts/start_sovrin_node',
'scripts/generate_sovrin_pool_transactions', 'scripts/get_keys']
)
if not os.path.exists(CONFIG_FILE):
with open(CONFIG_FILE, 'w') as f:
msg = "# Here you can create config entries according to your " \
"needs.\n " \
"# For help, refer config.py in the sovrin package.\n " \
"# Any entry you add here would override that from config " \
"example\n"
f.write(msg)
DATA_DIR = os.path.dirname(data.__file__)
copyfile(os.path.join(DATA_DIR, "pool_transactions_sandbox"), POOL_TXN_FILE)
copyfile(os.path.join(DATA_DIR, "pool_transactions_local"), POOL_TXN_LOCAL_FILE)
copyfile(os.path.join(DATA_DIR, "transactions_sandbox"), IDENTITY_TXN_FILE)
copyfile(os.path.join(DATA_DIR, "transactions_local"), IDENTITY_TXN_LOCAL_FILE)
SAMPLE_INVITATIONS_DIR = os.path.dirname(sample.__file__)
INVITATION_DIR = os.path.join(BASE_DIR, "sample")
os.makedirs(INVITATION_DIR, exist_ok=True)
files = glob.iglob(os.path.join(SAMPLE_INVITATIONS_DIR, "*.sovrin"))
for file in files:
if os.path.isfile(file):
shutil.copy2(file, INVITATION_DIR)