forked from leo-editor/leo-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
159 lines (154 loc) · 6.07 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# -*- coding: utf-8 -*-
#@+leo-ver=5-thin
#@+node:maphew.20180224170853.1: * @file ../../setup.py
#@@first
"""setup.py for leo"""
#@+others
#@+node:maphew.20180305124637.1: ** imports
from codecs import open # To use a consistent encoding
import os
import platform
# from shutil import rmtree
from setuptools import setup, find_packages # Always prefer setuptools over distutils
import sys
# Ensure setup.py's folder is in module search path else import leo fails
# required for pip >v10 and pyproject.toml
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
import leo.core.leoGlobals as g
import leo.core.leoVersion as leoVersion
#@+node:maphew.20181010203342.385: ** get_version & helper (setup.py)
def get_version(file, version=None):
"""Determine current Leo version. Use git if in checkout, else internal Leo"""
root = os.path.dirname(os.path.realpath(file))
if os.path.exists(os.path.join(root, '.git')):
version = git_version(file)
if not version:
version = get_semver(leoVersion.version)
return version
#@+node:maphew.20181010203342.386: *3* git_version
def git_version(file, version=None):
"""
Fetch from Git: {tag} {distance-from-tag} {current commit hash}
Return as semantic version string compliant with PEP440
"""
root = os.path.dirname(os.path.realpath(file))
try:
tag, distance, commit = g.gitDescribe(root)
# 5.6b2, 55, e1129da
ctag = clean_git_tag(tag)
#version = get_semver(ctag)
version = ctag
if int(distance) > 0:
version = '{}-dev{}'.format(version, distance)
except IndexError:
print('Attempt to `git describe` failed with IndexError')
except FileNotFoundError:
print('Attempt to `git describe` failed with FileNotFoundError')
return version
#@+node:maphew.20180224170257.1: *4* clean_git_tag
def clean_git_tag(tag):
"""Return only version number from tag name. Ignore unknown formats.
Is specific to tags in Leo's repository.
5.7b1 --> 5.7b1
Leo-4-4-8-b1 --> 4-4-8-b1
v5.3 --> 5.3
Fixed-bug-149 --> Fixed-bug-149
"""
if tag.lower().startswith('leo-'): tag = tag[4:]
if tag.lower().startswith('v'): tag = tag[1:]
return tag
#@+node:maphew.20180224170149.1: *3* get_semver
def get_semver(tag):
"""Return 'Semantic Version' from tag string"""
try:
import semantic_version
version = str(semantic_version.Version.coerce(tag, partial=True))
# tuple of major, minor, build, pre-release, patch
# 5.6b2 --> 5.6-b2
except(ImportError, ValueError) as err:
print('\n', err)
print(
f"*** Failed to parse Semantic Version from git tag '{tag}'.\n"
"Expecting tag name like '5.7b2', 'leo-4.9.12', 'v4.3' for releases.\n"
"This version can't be uploaded to PyPi.org.")
version = tag
return version
#@+node:maphew.20171006124415.1: ** Get description
with open('README.md') as f:
long_description = f.read()
#@+node:maphew.20141126230535.4: ** classifiers
classifiers = [
'Development Status :: 6 - Mature',
'Intended Audience :: End Users/Desktop',
'Intended Audience :: Developers',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Operating System :: MacOS',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3 :: Only',
'Topic :: Software Development',
'Topic :: Text Editors',
'Topic :: Text Processing',
]
#@+node:maphew.20180415195922.1: ** Setup requirements
setup_requires = []
# setup_requires no longer needed with PEP-518 and pip >v10
#@+node:maphew.20171120133429.1: ** User requirements
user_requires = [
'PyQt5 >= 5.12', # v5.12+ to close #1217
'PyQtWebEngine', # #1202 QtWebKit needs to be installed separately starting Qt 5.6
'asttokens', # abstract syntax tree text parsing
'docutils', # used by Sphinx, rST plugin
'flexx', # for LeoWapp browser gui
'meta', # for livecode.py plugin, which is enabled by default
'nbformat', # for Jupyter notebook integration
'pylint', 'pyflakes', 'black', # coding syntax standards
'pyshortcuts >= 1.7', # desktop integration (#1243)
'sphinx', # rST plugin
'windows-curses; platform_system=="Windows"', # for console mode on Windows
]
#@+node:maphew.20190207205714.1: ** define_entry_points
def define_entry_points(entry_points=None):
"""
Define scripts that get installed to PYTHONHOME/Scripts.
"""
print('Creating entry_points for [OS name - system]: {} - {}'.format(
platform.os.name, platform.system()))
entry_points = {'console_scripts': [
'leo-c = leo.core.runLeo:run_console',
'leo-console = leo.core.runLeo:run_console'],
'gui_scripts': ['leo = leo.core.runLeo:run']}
# Add leo-messages wrapper for windows platform
# (use python.exe instead of pythonw.exe in order to show console msgs)
if platform.system() == 'Windows':
x = entry_points['console_scripts']
x.append('leo-m = leo.core.runLeo:run')
x.append('leo-messages = leo.core.runLeo:run')
entry_points.update({'console_scripts': x})
return entry_points
#@-others
setup(
name='leo',
# version = leo.core.leoVersion.version,
version=get_version(__file__),
author='Edward K. Ream',
author_email='[email protected]',
url='http://leoeditor.com',
license='MIT License',
description='An IDE, PIM and Outliner', # becomes 'Summary' in pkg-info
long_description=long_description,
long_description_content_type="text/markdown", # PEP566
platforms=['Linux', 'Windows', 'MacOS'],
download_url='http://leoeditor.com/download.html',
classifiers=classifiers,
packages=find_packages(),
include_package_data=True, # also include MANIFEST files in wheels
setup_requires=setup_requires,
install_requires=user_requires,
entry_points=define_entry_points(),
python_requires='>=3.6',
)
#@@language python
#@@tabwidth -4
#@-leo