-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
96 lines (84 loc) · 3.32 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#-*-*- encoding: utf-8 -*-*-
import os
import platform
import subprocess
from collections import OrderedDict
from setuptools import setup, Command, find_packages
from setuptools.command.sdist import sdist
from setuptools.command.install import install
classifiers=[
"Development Status :: 1 - Planning",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Affero General Public License v3",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Topic :: Education",
"Topic :: Internet :: WWW/HTTP",
]
cp_license="GNU AGPL v3"
with open("README.md", "r") as fh:
long_description = fh.read()
with open('requirements.txt') as f:
requirements = [line.strip() for line in f if not line.startswith('#') and line.strip() != '']
class NpmInstall(Command):
description = 'Install npm dependencies and build assets'
user_options = [
('force', None, 'Force npm install and flask assets build'),
]
def initialize_options(self):
self.force = False
def finalize_options(self):
pass
def run(self):
if self.force or not os.path.exists('labdiscoveryengine/static/node_modules') or not os.path.exists('labdiscoveryengine/static/gen'):
try:
subprocess.check_call(['npm', 'install'], cwd='labdiscoveryengine/static')
if platform.system() in ['Windows', 'Microsoft']:
subprocess.check_call("devrc & flask assets build", shell=True)
else:
subprocess.check_call('. ./devrc && flask assets build', shell=True)
except subprocess.CalledProcessError as e:
print(f"The command '{' '.join(e.cmd)}' failed with error code {e.returncode}")
raise
class CustomSDistCommand(sdist):
def run(self):
npm_install_cmd = self.distribution.get_command_obj('npm_install')
npm_install_cmd.force = True
self.run_command('npm_install')
super().run()
class CustomInstallCommand(install):
def run(self):
self.run_command('npm_install')
super().run()
setup(name='labdiscoveryengine',
version='0.6.0',
description="Remote Laboratory Management System for creating laboratories (replacement of WebLab-Deusto)",
long_description=long_description,
long_description_content_type="text/markdown",
project_urls=OrderedDict((
('Documentation', 'https://developers.labsland.com/labdiscoveryengine/en/stable/'),
('Code', 'https://github.com/labsland/labdiscoveryengine'),
('Issue tracker', 'https://github.com/labsland/labdiscoveryengine/issues'),
)),
classifiers=classifiers,
zip_safe=False,
author='LabsLand',
author_email='[email protected]',
url='https://developers.labsland.com/labdiscoveryengine/',
license=cp_license,
packages=find_packages(exclude=['tests**']),
install_requires=requirements,
include_package_data=True,
cmdclass={
'npm_install': NpmInstall,
'sdist': CustomSDistCommand,
'install': CustomInstallCommand,
},
entry_points='''
[console_scripts]
lde=labdiscoveryengine.cli:lde
'''
)