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

Commit d1bb205

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 8ff211a commit d1bb205

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

pycallgraph/__main__.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
9+
10+
def main():
11+
import pycallgraph
12+
13+
config = pycallgraph.Config()
14+
config.parse_args()
15+
config.strip_argv()
16+
17+
globals()['__file__'] = config.command
18+
19+
file_content = open(config.command).read()
20+
21+
with pycallgraph.PyCallGraph(config=config):
22+
exec(file_content)
23+
24+
25+
if __name__ == '__main__':
26+
# Pep366 must always be the 1st thing to run.
27+
if not globals().get('__package__'):
28+
__package__ = "polyversion" # noqa: A001 F841 @ReservedAssignment
29+
30+
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
@@ -5,6 +5,8 @@
55
from setuptools import setup
66
from setuptools.command.test import test as TestCommand
77

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

1012

@@ -41,7 +43,8 @@ def run_tests(self):
4143
license=open('LICENSE').read(),
4244
url=pycallgraph.__url__,
4345
packages=['pycallgraph', 'pycallgraph.output'],
44-
scripts=['scripts/pycallgraph'],
46+
entry_points={
47+
'console_scripts': ['pycallgraph = pycallgraph.__main__:main']},
4548
data_files=data_files,
4649
use_2to3=True,
4750

0 commit comments

Comments
 (0)