* [gentoo-commits] repo/gentoo:master commit in: dev-python/line_profiler/files/, dev-python/line_profiler/
@ 2016-08-25 9:04 David Seifert
0 siblings, 0 replies; 2+ messages in thread
From: David Seifert @ 2016-08-25 9:04 UTC (permalink / raw
To: gentoo-commits
commit: f03bc7da70ad8ba36fb23416c1f6ebc7705b9801
Author: Marius Brehler <marbre <AT> linux <DOT> sungazer <DOT> de>
AuthorDate: Wed Aug 24 12:53:44 2016 +0000
Commit: David Seifert <soap <AT> gentoo <DOT> org>
CommitDate: Thu Aug 25 09:03:39 2016 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f03bc7da
dev-python/line_profiler: Bump to 1.0-r1 (including patches); Bump to EAPI=6
Package-Manager: portage-2.2.28
Closes: https://github.com/gentoo/gentoo/pull/2136
Signed-off-by: David Seifert <soap <AT> gentoo.org>
...line_profiler-1.0-fix-name-from-copypasta.patch | 25 ++
...ne_profiler-1.0-ipython-5.0-compatibility.patch | 299 +++++++++++++++++++++
.../line_profiler/line_profiler-1.0-r1.ebuild | 33 +++
3 files changed, 357 insertions(+)
diff --git a/dev-python/line_profiler/files/line_profiler-1.0-fix-name-from-copypasta.patch b/dev-python/line_profiler/files/line_profiler-1.0-fix-name-from-copypasta.patch
new file mode 100644
index 00000000..e51a24f
--- /dev/null
+++ b/dev-python/line_profiler/files/line_profiler-1.0-fix-name-from-copypasta.patch
@@ -0,0 +1,25 @@
+From 717df8c2088087ea4bce870400a2c99b36b0e53d Mon Sep 17 00:00:00 2001
+From: Robert Kern <rkern@enthought.com>
+Date: Mon, 21 Dec 2015 19:25:51 +0000
+Subject: [PATCH] BUG: fix name from copypasta.
+
+Fixes #43
+
+Thanks, @anntzer!
+---
+ line_profiler.py | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/line_profiler.py b/line_profiler.py
+index 4480c7b..aac01c8 100755
+--- a/line_profiler.py
++++ b/line_profiler.py
+@@ -303,7 +303,7 @@ def magic_lprun(self, parameter_s=''):
+ mod = __import__(modname, fromlist=[''])
+ profile.add_module(mod)
+ except Exception as e:
+- raise UsageError('Could not find module %r.\n%s: %s' % (name,
++ raise UsageError('Could not find module %r.\n%s: %s' % (modname,
+ e.__class__.__name__, e))
+
+ # Add the profiler to the builtins for @profile.
diff --git a/dev-python/line_profiler/files/line_profiler-1.0-ipython-5.0-compatibility.patch b/dev-python/line_profiler/files/line_profiler-1.0-ipython-5.0-compatibility.patch
new file mode 100644
index 00000000..04caa8c
--- /dev/null
+++ b/dev-python/line_profiler/files/line_profiler-1.0-ipython-5.0-compatibility.patch
@@ -0,0 +1,299 @@
+https://github.com/rkern/line_profiler/pull/65
+
+From 677a43104dd537b515c06eaeffa77f8dcfa5a76e Mon Sep 17 00:00:00 2001
+From: Brett Olsen <brett.olsen@invitae.com>
+Date: Tue, 12 Jul 2016 10:18:28 -0700
+Subject: [PATCH 1] Update for compatibility with IPython 5.0
+
+Also tested with IPython 4.1.1. Replaces the depreciated ip.define_magic() method with ip.register_magics() and some modifications to handle the different API required.
+---
+ line_profiler.py | 245 ++++++++++++++++++++++++++++---------------------------
+ 1 file changed, 125 insertions(+), 120 deletions(-)
+
+diff --git a/line_profiler.py b/line_profiler.py
+index aac01c8..7645997 100755
+--- a/line_profiler.py
++++ b/line_profiler.py
+@@ -17,6 +17,8 @@
+ import os
+ import sys
+
++from IPython.core.magic import (Magics, magics_class, line_magic)
++
+ from _line_profiler import LineProfiler as CLineProfiler
+
+ # Python 2/3 compatibility utils
+@@ -226,150 +228,153 @@ def show_text(stats, unit, stream=None, stripzeros=False):
+ for (fn, lineno, name), timings in sorted(stats.items()):
+ show_func(fn, lineno, name, stats[fn, lineno, name], unit, stream=stream, stripzeros=stripzeros)
+
+-# A %lprun magic for IPython.
+-def magic_lprun(self, parameter_s=''):
+- """ Execute a statement under the line-by-line profiler from the
+- line_profiler module.
++@magics_class
++class LineProfilerMagics(Magics):
+
+- Usage:
+- %lprun -f func1 -f func2 <statement>
++ @line_magic
++ def lprun(self, parameter_s=''):
++ """ Execute a statement under the line-by-line profiler from the
++ line_profiler module.
+
+- The given statement (which doesn't require quote marks) is run via the
+- LineProfiler. Profiling is enabled for the functions specified by the -f
+- options. The statistics will be shown side-by-side with the code through the
+- pager once the statement has completed.
++ Usage:
++ %lprun -f func1 -f func2 <statement>
+
+- Options:
++ The given statement (which doesn't require quote marks) is run via the
++ LineProfiler. Profiling is enabled for the functions specified by the -f
++ options. The statistics will be shown side-by-side with the code through the
++ pager once the statement has completed.
+
+- -f <function>: LineProfiler only profiles functions and methods it is told
+- to profile. This option tells the profiler about these functions. Multiple
+- -f options may be used. The argument may be any expression that gives
+- a Python function or method object. However, one must be careful to avoid
+- spaces that may confuse the option parser. Additionally, functions defined
+- in the interpreter at the In[] prompt or via %run currently cannot be
+- displayed. Write these functions out to a separate file and import them.
++ Options:
+
+- -m <module>: Get all the functions/methods in a module
++ -f <function>: LineProfiler only profiles functions and methods it is told
++ to profile. This option tells the profiler about these functions. Multiple
++ -f options may be used. The argument may be any expression that gives
++ a Python function or method object. However, one must be careful to avoid
++ spaces that may confuse the option parser. Additionally, functions defined
++ in the interpreter at the In[] prompt or via %run currently cannot be
++ displayed. Write these functions out to a separate file and import them.
+
+- One or more -f or -m options are required to get any useful results.
++ -m <module>: Get all the functions/methods in a module
+
+- -D <filename>: dump the raw statistics out to a pickle file on disk. The
+- usual extension for this is ".lprof". These statistics may be viewed later
+- by running line_profiler.py as a script.
++ One or more -f or -m options are required to get any useful results.
+
+- -T <filename>: dump the text-formatted statistics with the code side-by-side
+- out to a text file.
++ -D <filename>: dump the raw statistics out to a pickle file on disk. The
++ usual extension for this is ".lprof". These statistics may be viewed later
++ by running line_profiler.py as a script.
+
+- -r: return the LineProfiler object after it has completed profiling.
++ -T <filename>: dump the text-formatted statistics with the code side-by-side
++ out to a text file.
+
+- -s: strip out all entries from the print-out that have zeros.
+- """
+- # Local imports to avoid hard dependency.
+- from distutils.version import LooseVersion
+- import IPython
+- ipython_version = LooseVersion(IPython.__version__)
+- if ipython_version < '0.11':
+- from IPython.genutils import page
+- from IPython.ipstruct import Struct
+- from IPython.ipapi import UsageError
+- else:
+- from IPython.core.page import page
+- from IPython.utils.ipstruct import Struct
+- from IPython.core.error import UsageError
+-
+- # Escape quote markers.
+- opts_def = Struct(D=[''], T=[''], f=[], m=[])
+- parameter_s = parameter_s.replace('"', r'\"').replace("'", r"\'")
+- opts, arg_str = self.parse_options(parameter_s, 'rsf:m:D:T:', list_all=True)
+- opts.merge(opts_def)
+-
+- global_ns = self.shell.user_global_ns
+- local_ns = self.shell.user_ns
+-
+- # Get the requested functions.
+- funcs = []
+- for name in opts.f:
+- try:
+- funcs.append(eval(name, global_ns, local_ns))
+- except Exception as e:
+- raise UsageError('Could not find function %r.\n%s: %s' % (name,
+- e.__class__.__name__, e))
++ -r: return the LineProfiler object after it has completed profiling.
+
+- profile = LineProfiler(*funcs)
++ -s: strip out all entries from the print-out that have zeros.
++ """
++ # Local imports to avoid hard dependency.
++ from distutils.version import LooseVersion
++ import IPython
++ ipython_version = LooseVersion(IPython.__version__)
++ if ipython_version < '0.11':
++ from IPython.genutils import page
++ from IPython.ipstruct import Struct
++ from IPython.ipapi import UsageError
++ else:
++ from IPython.core.page import page
++ from IPython.utils.ipstruct import Struct
++ from IPython.core.error import UsageError
++
++ # Escape quote markers.
++ opts_def = Struct(D=[''], T=[''], f=[], m=[])
++ parameter_s = parameter_s.replace('"', r'\"').replace("'", r"\'")
++ opts, arg_str = self.parse_options(parameter_s, 'rsf:m:D:T:', list_all=True)
++ opts.merge(opts_def)
++
++ global_ns = self.shell.user_global_ns
++ local_ns = self.shell.user_ns
++
++ # Get the requested functions.
++ funcs = []
++ for name in opts.f:
++ try:
++ funcs.append(eval(name, global_ns, local_ns))
++ except Exception as e:
++ raise UsageError('Could not find function %r.\n%s: %s' % (name,
++ e.__class__.__name__, e))
+
+- # Get the modules, too
+- for modname in opts.m:
+- try:
+- mod = __import__(modname, fromlist=[''])
+- profile.add_module(mod)
+- except Exception as e:
+- raise UsageError('Could not find module %r.\n%s: %s' % (modname,
+- e.__class__.__name__, e))
+-
+- # Add the profiler to the builtins for @profile.
+- if PY3:
+- import builtins
+- else:
+- import __builtin__ as builtins
++ profile = LineProfiler(*funcs)
+
+- if 'profile' in builtins.__dict__:
+- had_profile = True
+- old_profile = builtins.__dict__['profile']
+- else:
+- had_profile = False
+- old_profile = None
+- builtins.__dict__['profile'] = profile
++ # Get the modules, too
++ for modname in opts.m:
++ try:
++ mod = __import__(modname, fromlist=[''])
++ profile.add_module(mod)
++ except Exception as e:
++ raise UsageError('Could not find module %r.\n%s: %s' % (modname,
++ e.__class__.__name__, e))
++
++ # Add the profiler to the builtins for @profile.
++ if PY3:
++ import builtins
++ else:
++ import __builtin__ as builtins
++
++ if 'profile' in builtins.__dict__:
++ had_profile = True
++ old_profile = builtins.__dict__['profile']
++ else:
++ had_profile = False
++ old_profile = None
++ builtins.__dict__['profile'] = profile
+
+- try:
+ try:
+- profile.runctx(arg_str, global_ns, local_ns)
+- message = ''
+- except SystemExit:
+- message = """*** SystemExit exception caught in code being profiled."""
+- except KeyboardInterrupt:
+- message = ("*** KeyboardInterrupt exception caught in code being "
+- "profiled.")
+- finally:
+- if had_profile:
+- builtins.__dict__['profile'] = old_profile
+-
+- # Trap text output.
+- stdout_trap = StringIO()
+- profile.print_stats(stdout_trap, stripzeros='s' in opts)
+- output = stdout_trap.getvalue()
+- output = output.rstrip()
+-
+- if ipython_version < '0.11':
+- page(output, screen_lines=self.shell.rc.screen_length)
+- else:
+- page(output)
+- print(message, end="")
++ try:
++ profile.runctx(arg_str, global_ns, local_ns)
++ message = ''
++ except SystemExit:
++ message = """*** SystemExit exception caught in code being profiled."""
++ except KeyboardInterrupt:
++ message = ("*** KeyboardInterrupt exception caught in code being "
++ "profiled.")
++ finally:
++ if had_profile:
++ builtins.__dict__['profile'] = old_profile
++
++ # Trap text output.
++ stdout_trap = StringIO()
++ profile.print_stats(stdout_trap, stripzeros='s' in opts)
++ output = stdout_trap.getvalue()
++ output = output.rstrip()
++
++ if ipython_version < '0.11':
++ page(output, screen_lines=self.shell.rc.screen_length)
++ else:
++ page(output)
++ print(message, end="")
+
+- dump_file = opts.D[0]
+- if dump_file:
+- profile.dump_stats(dump_file)
+- print('\n*** Profile stats pickled to file %r. %s' % (
+- dump_file, message))
++ dump_file = opts.D[0]
++ if dump_file:
++ profile.dump_stats(dump_file)
++ print('\n*** Profile stats pickled to file %r. %s' % (
++ dump_file, message))
+
+- text_file = opts.T[0]
+- if text_file:
+- pfile = open(text_file, 'w')
+- pfile.write(output)
+- pfile.close()
+- print('\n*** Profile printout saved to text file %r. %s' % (
+- text_file, message))
++ text_file = opts.T[0]
++ if text_file:
++ pfile = open(text_file, 'w')
++ pfile.write(output)
++ pfile.close()
++ print('\n*** Profile printout saved to text file %r. %s' % (
++ text_file, message))
+
+- return_value = None
+- if 'r' in opts:
+- return_value = profile
++ return_value = None
++ if 'r' in opts:
++ return_value = profile
+
+- return return_value
++ return return_value
+
+
+ def load_ipython_extension(ip):
+ """ API for IPython to recognize this module as an IPython extension.
+ """
+- ip.define_magic('lprun', magic_lprun)
++ ip.register_magics(LineProfilerMagics)
+
+
+ def load_stats(filename):
diff --git a/dev-python/line_profiler/line_profiler-1.0-r1.ebuild b/dev-python/line_profiler/line_profiler-1.0-r1.ebuild
new file mode 100644
index 00000000..00e1e86
--- /dev/null
+++ b/dev-python/line_profiler/line_profiler-1.0-r1.ebuild
@@ -0,0 +1,33 @@
+# Copyright 1999-2016 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+EAPI=6
+
+PYTHON_COMPAT=( python2_7 python3_{4,5} )
+
+inherit distutils-r1
+
+DESCRIPTION="Line-by-line profiler"
+HOMEPAGE="https://github.com/rkern/line_profiler"
+SRC_URI="mirror://pypi/${PN:0:1}/${PN}/${P}.tar.gz"
+KEYWORDS="~amd64"
+
+SLOT="0"
+LICENSE="BSD"
+KEYWORDS="~amd64 ~x86"
+IUSE="test"
+
+DEPEND="
+ test? ( dev-python/pytest[${PYTHON_USEDEP}] )
+ "
+
+PATCHES=(
+ "${FILESDIR}/${P}-fix-name-from-copypasta.patch"
+ "${FILESDIR}/${P}-ipython-5.0-compatibility.patch"
+)
+
+python_test() {
+ "${PYTHON}" -m unittest discover -v "${S}"/tests/ \
+ || die "Tests failed with ${EPYTHON}"
+}
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [gentoo-commits] repo/gentoo:master commit in: dev-python/line_profiler/files/, dev-python/line_profiler/
@ 2020-11-18 18:58 David Seifert
0 siblings, 0 replies; 2+ messages in thread
From: David Seifert @ 2020-11-18 18:58 UTC (permalink / raw
To: gentoo-commits
commit: 87bc53fbc14cc579a8a58a4a65c72e7a99870fd4
Author: Jakov Smolic <jakov.smolic <AT> sartura <DOT> hr>
AuthorDate: Wed Nov 18 18:57:49 2020 +0000
Commit: David Seifert <soap <AT> gentoo <DOT> org>
CommitDate: Wed Nov 18 18:57:49 2020 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=87bc53fb
dev-python/line_profiler: add python3_9
Closes: https://github.com/gentoo/gentoo/pull/18312
Package-Manager: Portage-3.0.8, Repoman-3.0.1
Signed-off-by: Jakov Smolic <jakov.smolic <AT> sartura.hr>
Signed-off-by: David Seifert <soap <AT> gentoo.org>
.../files/line_profiler-3.0.2-python3_9.patch | 35 ++++++++++++++++++++++
.../line_profiler/line_profiler-3.0.2.ebuild | 6 +++-
2 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/dev-python/line_profiler/files/line_profiler-3.0.2-python3_9.patch b/dev-python/line_profiler/files/line_profiler-3.0.2-python3_9.patch
new file mode 100644
index 00000000000..74b0677bc70
--- /dev/null
+++ b/dev-python/line_profiler/files/line_profiler-3.0.2-python3_9.patch
@@ -0,0 +1,35 @@
+From f40a6e102d3c4808155af601ddba7733e597e604 Mon Sep 17 00:00:00 2001
+From: Stefano Rivera <stefano@rivera.za.net>
+Date: Thu, 15 Oct 2020 22:44:50 -0700
+Subject: [PATCH] Python 3.9 dropped gettimeofday configure checks
+
+Upstream status: Accepted [https://github.com/pyutils/line_profiler/pull/31}
+Signed-off-by: Jakov Smolic <jakov.smolic@sartura.hr>
+
+diff --git a/line_profiler/timers.c b/line_profiler/timers.c
+index ae01060..e8ee6c6 100644
+--- a/line_profiler/timers.c
++++ b/line_profiler/timers.c
+@@ -32,10 +32,6 @@ hpTimerUnit(void)
+
+ #else /* !MS_WINDOWS */
+
+-#ifndef HAVE_GETTIMEOFDAY
+-#error "This module requires gettimeofday() on non-Windows platforms!"
+-#endif
+-
+ #if (defined(PYOS_OS2) && defined(PYCC_GCC))
+ #include <sys/time.h>
+ #else
+@@ -48,11 +44,7 @@ hpTimer(void)
+ {
+ struct timeval tv;
+ PY_LONG_LONG ret;
+-#ifdef GETTIMEOFDAY_NO_TZ
+- gettimeofday(&tv);
+-#else
+ gettimeofday(&tv, (struct timezone *)NULL);
+-#endif
+ ret = tv.tv_sec;
+ ret = ret * 1000000 + tv.tv_usec;
+ return ret;
diff --git a/dev-python/line_profiler/line_profiler-3.0.2.ebuild b/dev-python/line_profiler/line_profiler-3.0.2.ebuild
index a48003e8777..5c557811592 100644
--- a/dev-python/line_profiler/line_profiler-3.0.2.ebuild
+++ b/dev-python/line_profiler/line_profiler-3.0.2.ebuild
@@ -3,7 +3,7 @@
EAPI=7
-PYTHON_COMPAT=( python3_{6,7,8} )
+PYTHON_COMPAT=( python3_{6..9} )
DISTUTILS_USE_SETUPTOOLS=rdepend
@@ -26,6 +26,10 @@ DEPEND="test? (
dev-python/coverage[${PYTHON_USEDEP}]
dev-python/ubelt[${PYTHON_USEDEP}] )"
+PATCHES=(
+ "${FILESDIR}"/${P}-python3_9.patch
+)
+
distutils_enable_tests pytest
python_test() {
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-18 18:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-18 18:58 [gentoo-commits] repo/gentoo:master commit in: dev-python/line_profiler/files/, dev-python/line_profiler/ David Seifert
-- strict thread matches above, loose matches on Subject: below --
2016-08-25 9:04 David Seifert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox