Skip to content
This repository was archived by the owner on Apr 9, 2024. It is now read-only.

Commit e582642

Browse files
committed
fix(build,#119,#155): use setuptools-entry-points instead of console-script...
to fix launching on Windows. Also this is now the officially "blessed" way to generated executables: https://packaging.python.org/guides/distributing-packages-using-setuptools/#scripts
1 parent 13daf83 commit e582642

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

pycallgraph/__main__.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python
2+
"""
3+
pycallgraph
4+
This script is the command line interface to the pycallgraph Python library.
5+
6+
See http://pycallgraph.slowchop.com/ for more information.
7+
"""
8+
import sys
9+
import os
10+
11+
def main():
12+
import pycallgraph
13+
14+
config = pycallgraph.Config()
15+
config.parse_args()
16+
config.strip_argv()
17+
18+
globals()['__file__'] = config.command
19+
20+
file_content = open(config.command).read()
21+
22+
with pycallgraph.PyCallGraph(config=config):
23+
exec(file_content)
24+
25+
26+
if __name__ == '__main__':
27+
## Pep366 must always be the 1st thing to run.
28+
if not globals().get('__package__'):
29+
__package__ = "polyversion" # noqa: A001 F841 @ReservedAssignment
30+
31+
main()

scripts/pycallgraph

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ pycallgraph
44
This script is the command line interface to the pycallgraph Python library.
55
66
See http://pycallgraph.slowchop.com/ for more information.
7+
8+
.. deprecated:: > 1.0.1
9+
Code here moved to :func:`pycallgraph.__main__.main()`
10+
and now using setuptools console-script entry-points,
11+
to properly install on Windows.
12+
13+
- See https://github.com/gak/pycallgraph/issues/119
14+
- See https://github.com/gak/pycallgraph/issues/155
715
"""
816
import sys
917
import os

setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
from setuptools.command.test import test as TestCommand
88

9+
## FIXME: importing my-package may fail if dependent projects
10+
# from :mod:`./pycallgraph/__init__.py` are not installed yet at this stage!
911
import pycallgraph
1012

1113
# Only install the man page if the correct directory exists
@@ -40,7 +42,8 @@ def run_tests(self):
4042
license=open('LICENSE').read(),
4143
url=pycallgraph.__url__,
4244
packages=['pycallgraph', 'pycallgraph.output'],
43-
scripts=['scripts/pycallgraph'],
45+
entry_points={
46+
'console_scripts': ['pycallgraph = pycallgraph.__main__:main']},
4447
data_files=data_files,
4548
use_2to3=True,
4649

0 commit comments

Comments
 (0)