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

Commit

Permalink
fix(build,#119,#155): use setuptools-entry-points instead of
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ankostis committed Jun 8, 2018
1 parent a1029a4 commit 3af878c
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 21 deletions.
28 changes: 8 additions & 20 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
language:
- python
language: python

python:
- "2.7"
- "3.3"
- "3.4"
- "3.5"
- "3.6"
- "3.7-dev"
- "pypy"
# pytest does not support python 3.5
# https://bitbucket.org/pytest-dev/pytest/pull-request/296/astcall-signature-changed-on-35
# - "nightly"

matrix:
allow_failures:
- python:
- "pypy"
- '3.7-dev' # Due to PyYAML (from `coveralls`)
- python:
- "nigthly"
- 2.7
- 3.3
- 3.4
- 3.5
- 3.6
#- 3.7-dev
- pypy

env:
global:
Expand Down
30 changes: 30 additions & 0 deletions pycallgraph/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env python
"""
pycallgraph
This script is the command line interface to the pycallgraph Python library.
See http://pycallgraph.slowchop.com/ for more information.
"""


def main():
import pycallgraph

config = pycallgraph.Config()
config.parse_args()
config.strip_argv()

globals()['__file__'] = config.command

file_content = open(config.command).read()

with pycallgraph.PyCallGraph(config=config):
exec(file_content)


if __name__ == '__main__':
# Pep366 must always be the 1st thing to run.
if not globals().get('__package__'):
__package__ = "polyversion" # noqa: A001 F841 @ReservedAssignment

main()
8 changes: 8 additions & 0 deletions scripts/pycallgraph
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ pycallgraph
This script is the command line interface to the pycallgraph Python library.
See http://pycallgraph.slowchop.com/ for more information.
.. deprecated:: > 1.0.1
Code here moved to :func:`pycallgraph.__main__.main()`
and now using setuptools console-script entry-points,
to properly install on Windows.
- See https://github.com/gak/pycallgraph/issues/119
- See https://github.com/gak/pycallgraph/issues/155
"""
import sys
import os
Expand Down
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from setuptools import setup
from setuptools.command.test import test as TestCommand

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


Expand Down Expand Up @@ -41,7 +43,8 @@ def run_tests(self):
license=open('LICENSE').read(),
url=pycallgraph.__url__,
packages=['pycallgraph', 'pycallgraph.output'],
scripts=['scripts/pycallgraph'],
entry_points={
'console_scripts': ['pycallgraph = pycallgraph.__main__:main']},
data_files=data_files,
use_2to3=True,

Expand Down

0 comments on commit 3af878c

Please sign in to comment.