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

Commit 3af878c

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 a1029a4 commit 3af878c

File tree

4 files changed

+50
-21
lines changed

4 files changed

+50
-21
lines changed

.travis.yml

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,13 @@
1-
language:
2-
- python
1+
language: python
32

43
python:
5-
- "2.7"
6-
- "3.3"
7-
- "3.4"
8-
- "3.5"
9-
- "3.6"
10-
- "3.7-dev"
11-
- "pypy"
12-
# pytest does not support python 3.5
13-
# https://bitbucket.org/pytest-dev/pytest/pull-request/296/astcall-signature-changed-on-35
14-
# - "nightly"
15-
16-
matrix:
17-
allow_failures:
18-
- python:
19-
- "pypy"
20-
- '3.7-dev' # Due to PyYAML (from `coveralls`)
21-
- python:
22-
- "nigthly"
4+
- 2.7
5+
- 3.3
6+
- 3.4
7+
- 3.5
8+
- 3.6
9+
#- 3.7-dev
10+
- pypy
2311

2412
env:
2513
global:

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)