forked from learningequality/kolibri
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
107 lines (94 loc) · 3.8 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
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from setuptools import setup
from setuptools.command.install_scripts import install_scripts
import kolibri
# Windows-specific .bat script template
WINDOWS_BATCH_TEMPLATE = r"""@echo off
set mypath=%~dp0
set pyscript="%mypath%{file_name}"
set /p line1=<%pyscript%
if "%line1:~0,2%" == "#!" (goto :goodstart)
echo First line of %pyscript% does not start with "#!"
exit /b 1
:goodstart
set py_exe=%line1:~2%
call %py_exe% %pyscript% %*
"""
# Generate Windows-specific .bat files
class gen_windows_batch_files(install_scripts):
def run(self):
# default behaviors
install_scripts.run(self)
# Nothing more to do if this is not Windows
if not os.name == "nt":
return
# For Windows, write batch scripts for all executable python files
for output_path in self.get_outputs():
# look for #! at the top
with open(output_path, "rt") as f:
first_line = f.readline()
# skip non-executbale python files
if not (first_line.startswith("#!") and "python" in first_line.lower()):
continue
path_name, file_name = os.path.split(output_path)
if self.dry_run:
continue
bat_file = os.path.join(path_name, os.path.splitext(file_name)[0] + ".bat")
with open(bat_file, "wt") as f:
f.write(WINDOWS_BATCH_TEMPLATE.format(file_name=file_name))
long_description = """
`Kolibri <https://learningequality.org/kolibri/>`_ is the offline learning platform
from `Learning Equality <https://learningequality.org/>`_.
This package can be installed by running ``pip install --user kolibri``. `See the download
page <https://learningequality.org/download/>`_ for other methods of installation.
- `View the documentation <https://kolibri.readthedocs.io/>`_ and the `community
forums <https://community.learningequality.org/>`_ for more guidance on setting up
and using Kolibri
- Visit the `Github project <https://github.com/learningequality/kolibri>`_ and the
`developer documentation <https://kolibri-dev.readthedocs.io/>`_ if you would like
to contribute to development
"""
setup(
name="kolibri",
version=kolibri.__version__,
description="Kolibri - the offline app for universal education",
long_description=long_description,
author="Learning Equality",
author_email="[email protected]",
url="https://github.com/learningequality/kolibri",
packages=[str("kolibri")], # https://github.com/pypa/setuptools/pull/597
entry_points={
"console_scripts": ["kolibri = kolibri.utils.cli:main"],
"kolibri.plugins": [
"{module_path} = {module_path}".format(module_path=module_path)
for module_path in kolibri.INTERNAL_PLUGINS
],
},
package_dir={"kolibri": "kolibri"},
include_package_data=True,
install_requires=[],
dependency_links=[],
tests_require=["pytest", "tox", "flake8"],
license="MIT",
zip_safe=False,
keywords=["education", "offline", "kolibri"],
classifiers=[
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Development Status :: 4 - Beta",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: Implementation :: PyPy",
],
cmdclass={"install_scripts": gen_windows_batch_files},
python_requires=">=3.6, <3.13",
)