Skip to content

Commit 38318cd

Browse files
author
Charles Duffy
committed
Setuptoolize bpython
- Use the setuptools entry_points mechanism - Move the primary bpython script itself into the bpython module with invocation via the setuptools entry_points mechanism. - Fix setup.py whitespace to be consistant (4-spaces only) - Ignore setuptools-generated build products committer: Charles Duffy <cduffy@messageone.com>
1 parent 0a9df3f commit 38318cd

File tree

3 files changed

+39
-49
lines changed

3 files changed

+39
-49
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
*.pyc
2+
*.egg-info
3+
build
4+
dist

bpython.py renamed to bpython/cli.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,7 @@ def loadrc():
15311531

15321532
stdscr = None
15331533

1534-
def main( scr ):
1534+
def main_curses( scr ):
15351535
"""main function for the curses convenience wrapper
15361536
15371537
Initialise the two main objects: the interpreter
@@ -1568,10 +1568,10 @@ def main( scr ):
15681568
repl.repl()
15691569
return repl.getstdout()
15701570

1571-
if __name__ == '__main__':
1571+
def main():
15721572
tb = None
15731573
try:
1574-
o = curses.wrapper( main )
1574+
o = curses.wrapper( main_curses )
15751575
except:
15761576
tb = traceback.format_exc()
15771577
# I don't know why this is necessary; without it the wrapper doesn't always
@@ -1589,3 +1589,6 @@ def main( scr ):
15891589

15901590
sys.stdout.write( o ) # Fake stdout data so everything's still visible after exiting
15911591
sys.stdout.flush()
1592+
1593+
if __name__ == '__main__':
1594+
main()

setup.py

Lines changed: 30 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,41 @@
11
#!/usr/bin/env python
2-
from distutils.command.install_data import install_data
3-
from distutils.sysconfig import get_python_lib
4-
from distutils.core import setup, Extension
5-
from distutils.dep_util import newer
6-
from distutils.log import info
7-
from distutils import sysconfig
8-
import distutils.file_util
9-
import distutils.dir_util
2+
# -*- coding: utf-8 -*-
3+
4+
from setuptools import setup
105
import sys, os
116
import glob
127
import platform
138
import re
149

15-
# Make distutils copy bpython.py to bpython
16-
copy_file_orig = distutils.file_util.copy_file
17-
copy_tree_orig = distutils.dir_util.copy_tree
18-
def copy_file(src, dst, *args, **kwargs):
19-
if dst.endswith("bin/bpython.py"):
20-
dst = dst[:-3]
21-
return copy_file_orig(src, dst, *args, **kwargs)
22-
def copy_tree(*args, **kwargs):
23-
outputs = copy_tree_orig(*args, **kwargs)
24-
for i in range(len(outputs)):
25-
if outputs[i].endswith("bin/bpython.py"):
26-
outputs[i] = outputs[i][:-3]
27-
return outputs
28-
distutils.file_util.copy_file = copy_file
29-
distutils.dir_util.copy_tree = copy_tree
30-
31-
PYTHONLIB = os.path.join(get_python_lib(standard_lib=1, prefix=""),
32-
"site-packages")
33-
3410
if platform.system() == 'FreeBSD':
3511
man_dir = 'man'
3612
else:
3713
man_dir = 'share/man'
3814

39-
setup(name="bpython",
40-
version = "0.6.4",
41-
description = "Fancy Interface to the Python Interpreter",
42-
author = "Robert Anthony Farrell",
43-
author_email = "robertanthonyfarrell@gmail.com",
44-
license = "MIT/X",
45-
url = "http://www.noiseforfree.com/bpython/",
46-
long_description =
47-
"""\
48-
bpython is a fancy interface to the Python interpreter for Unix-like operating systems.
49-
""",
50-
packages = ["bpython"],
51-
scripts = ["bpython.py"],
52-
data_files = [
53-
(os.path.join(man_dir, 'man1'), ['doc/bpython.1']),
54-
(os.path.join(man_dir, 'man5'), ['doc/bpythonrc.5']),
55-
('share/applications', ['data/bpython.desktop'])
56-
]
57-
)
15+
setup(
16+
name="bpython",
17+
version = "0.6.4",
18+
author = "Robert Anthony Farrell",
19+
author_email = "robertanthonyfarrell@gmail.com",
20+
description = "Fancy Interface to the Python Interpreter",
21+
license = "MIT/X",
22+
url = "http://www.noiseforfree.com/bpython/",
23+
long_description = """bpython is a fancy interface to the Python interpreter for Unix-like operating systems.""",
24+
install_requires = [
25+
'pygments',
26+
'pyparsing',
27+
],
28+
packages = ["bpython"],
29+
data_files = [
30+
(os.path.join(man_dir, 'man1'), ['doc/bpython.1']),
31+
(os.path.join(man_dir, 'man5'), ['doc/bpythonrc.5']),
32+
('share/applications', ['data/bpython.desktop'])
33+
],
34+
entry_points = {
35+
'console_scripts': [
36+
'bpython = bpython.cli:main'
37+
],
38+
}
39+
)
40+
41+
# vim: encoding=utf-8 sw=4 ts=4 sts=4 ai et sta

0 commit comments

Comments
 (0)