-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
79 lines (74 loc) · 2.57 KB
/
setup.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
# import dependencies
from setuptools import setup, find_packages
import os
import requests
# get the user's home directory
HOME = os.path.expanduser('~')
# GitHub path
GH_PATH = 'github.com/tshanebuckley/GREENCap'
# raw version url
RAW = 'https://raw.' + GH_PATH
# GitHub url
URL = 'https://' + GH_PATH
# run setup
setup(name='greencap',
version='0.1',
description='GREENCap: Asynchronous requests and middleware API for REDCap.',
url=URL,
author='Maintainer: Shane Buckley',
author_email='[email protected]',
#license='MIT',
python_requires='>=3.6',
#package_dir={'': 'GREENCap/greencap'},
packages=['greencap', 'greencap/utils'],
include_package_data=True,
#packages=find_packages(),
install_requires=[
"pycap",
"fastapi",
"typer",
"uvicorn[standard]",
"pydantic",
"pyyaml",
"ijson",
"aiohttp",
"aiofiles",
"aiopath",
"tqdm",
"mergedeep",
"configparser",
"numpy",
"pandas",
"asgiref",
"multipart",
"dtale"
],
zip_safe=False
)
# function to download a file from GitHub and save it on the install machine
def github_copy_file(url, github_path, system_path):
# get the content of the file
file_content = requests.get(url + '/master/' + github_path).content
# get the file text
file_text = file_content.decode('utf-8')
# get the file name
file_name = os.path.basename(github_path)
# make the path to where the file should be saved
os.makedirs(system_path, exist_ok=True)
# get the system file path
system_file_path = system_path + '/' + file_name
# if the file does not already exist
if os.path.exists(system_file_path) == False:
# save the file
with open(system_file_path, 'w') as file:
# write the file
file.write(file_text)
# Downloading base config, shiny app, fastapi, and setup .greencap and other folders under the home directory
github_copy_file(RAW, 'greencap_config.yaml', HOME + '/.greencap')
github_copy_file(RAW, 'redcap_webapp.R', HOME + '/.greencap/shiny')
github_copy_file(RAW, 'open_dtale.py', HOME + '/.greencap/shiny')
github_copy_file(RAW, 'api.py', HOME + '/.greencap/api')
# Make directories for the user, groups, and projects
os.makedirs(HOME + '/.greencap/projects', exist_ok=True)
os.makedirs(HOME + '/.greencap/users', exist_ok=True)
os.makedirs(HOME + '/.greencap/groups', exist_ok=True)