Skip to content

Commit 52b8da8

Browse files
committed
Switch to setuptools.
Use console_scripts entry_point instead of manually built script.
1 parent 78c7b25 commit 52b8da8

File tree

3 files changed

+19
-86
lines changed

3 files changed

+19
-86
lines changed

MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
recursive-include bin *
21
recursive-include markdown *.py
32
recursive-include docs *
43
recursive-include tests *.txt *.html *.cfg *.py

bin/markdown_py

Lines changed: 0 additions & 34 deletions
This file was deleted.

setup.py

Lines changed: 19 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
#!/usr/bin/env python
22

3-
from __future__ import with_statement
4-
import sys
3+
from setuptools import setup
54
import os
6-
from distutils.core import setup
7-
from distutils.command.install_scripts import install_scripts
85
import imp
96

107

@@ -14,54 +11,23 @@ def get_version():
1411
fp, pathname, desc = imp.find_module('__version__', [path])
1512
try:
1613
v = imp.load_module('__version__', fp, pathname, desc)
17-
return v.version, v.version_info
1814
finally:
1915
fp.close()
2016

17+
dev_status_map = {
18+
'alpha': '3 - Alpha',
19+
'beta': '4 - Beta',
20+
'rc': '4 - Beta',
21+
'final': '5 - Production/Stable'
22+
}
23+
if v.version_info[3] == 'alpha' and v.version_info[4] == 0:
24+
status = '2 - Pre-Alpha'
25+
else:
26+
status = dev_status_map[v.version_info[3]]
27+
return v.version, v.version_info, status
2128

22-
version, version_info = get_version()
2329

24-
# Get development Status for classifiers
25-
dev_status_map = {
26-
'alpha': '3 - Alpha',
27-
'beta': '4 - Beta',
28-
'rc': '4 - Beta',
29-
'final': '5 - Production/Stable'
30-
}
31-
if version_info[3] == 'alpha' and version_info[4] == 0:
32-
DEVSTATUS = '2 - Pre-Alpha'
33-
else:
34-
DEVSTATUS = dev_status_map[version_info[3]]
35-
36-
# The command line script name. Currently set to "markdown_py" so as not to
37-
# conflict with the perl implimentation (which uses "markdown"). We can't use
38-
# "markdown.py" as the default config on some systems will cause the script to
39-
# try to import itself rather than the library which will raise an error.
40-
SCRIPT_NAME = 'markdown_py'
41-
42-
43-
class md_install_scripts(install_scripts):
44-
45-
""" Customized install_scripts. Create markdown_py.bat for win32. """
46-
47-
def run(self):
48-
install_scripts.run(self)
49-
50-
if sys.platform == 'win32':
51-
try:
52-
script_dir = os.path.join(sys.prefix, 'Scripts')
53-
script_path = os.path.join(script_dir, SCRIPT_NAME)
54-
bat_str = '@"%s" "%s" %%*' % (sys.executable, script_path)
55-
bat_path = os.path.join(
56-
self.install_dir, '%s.bat' % SCRIPT_NAME
57-
)
58-
f = open(bat_path, 'w')
59-
f.write(bat_str)
60-
f.close()
61-
print('Created: %s' % bat_path)
62-
except Exception:
63-
_, err, _ = sys.exc_info() # for both 2.x & 3.x compatability
64-
print('ERROR: Unable to create %s: %s' % (bat_path, err))
30+
version, version_info, DEVSTATUS = get_version()
6531

6632

6733
long_description = '''
@@ -72,7 +38,7 @@ def run(self):
7238
supported by the `Available Extensions`_.
7339
7440
.. _Markdown: http://daringfireball.net/projects/markdown/
75-
.. _Features: https://Python-Markdown.github.io#Features
41+
.. _Features: https://Python-Markdown.github.io#features
7642
.. _`Available Extensions`: https://Python-Markdown.github.io/extensions/
7743
7844
Support
@@ -85,6 +51,7 @@ def run(self):
8551
.. _`bug tracker`: http://github.com/Python-Markdown/markdown/issues
8652
'''
8753

54+
8855
setup(
8956
name='Markdown',
9057
version=version,
@@ -98,9 +65,10 @@ def run(self):
9865
maintainer_email='[email protected]',
9966
license='BSD License',
10067
packages=['markdown', 'markdown.extensions'],
101-
scripts=['bin/%s' % SCRIPT_NAME],
102-
cmdclass={
103-
'install_scripts': md_install_scripts
68+
entry_points={
69+
'console_scripts': [
70+
'markdown = markdown.__main__:run',
71+
]
10472
},
10573
classifiers=[
10674
'Development Status :: %s' % DEVSTATUS,

0 commit comments

Comments
 (0)