[pypy-commit] pypy default: add script to create PyPI package from cppyy and stripped-down ROOT/Cling sources

2017-06-23 Thread wlav
Author: Wim Lavrijsen 
Branch: 
Changeset: r91641:a4013f68eff6
Date: 2017-06-23 15:42 -0700
http://bitbucket.org/pypy/pypy/changeset/a4013f68eff6/

Log:add script to create PyPI package from cppyy and stripped-down
ROOT/Cling sources

diff --git a/pypy/module/cppyy/backend/create_cppyy_package.py 
b/pypy/module/cppyy/backend/create_cppyy_package.py
new file mode 100755
--- /dev/null
+++ b/pypy/module/cppyy/backend/create_cppyy_package.py
@@ -0,0 +1,649 @@
+#!/usr/bin/env python
+from __future__ import print_function
+
+import os, sys
+import argparse, re, shutil, tarfile, urllib2
+
+
+DEBUG_TESTBUILD = False
+
+TARBALL_CACHE_DIR = 'releases'
+
+ROOT_KEEP = ['build', 'cmake', 'config', 'core', 'etc', 'interpreter',
+ 'io', 'LICENSE', 'net', 'Makefile', 'CMakeLists.txt', 'math',
+ 'main'] # main only needed in more recent root b/c of rootcling
+ROOT_CORE_KEEP = ['CMakeLists.txt', 'base', 'clib', 'clingutils', 'cont',
+  'dictgen', 'foundation', 'lzma', 'macosx', 'meta',
+  'metacling', 'metautils', 'rootcling_stage1', 'textinput',
+  'thread', 'unix', 'utils', 'winnt', 'zip']
+ROOT_IO_KEEP = ['CMakeLists.txt', 'io', 'rootpcm']
+ROOT_NET_KEEP = ['CMakeLists.txt', 'net']
+ROOT_MATH_KEEP = ['CMakeLists.txt', 'mathcore']
+ROOT_ETC_KEEP = ['Makefile.arch', 'class.rules', 'cmake', 'dictpch',
+ 'gdb-backtrace.sh', 'gitinfo.txt', 'helgrind-root.supp',
+ 'hostcert.conf', 'system.plugins-ios',
+ 'valgrind-root-python.supp', 'valgrind-root.supp', 'vmc']
+
+ROOT_EXPLICIT_REMOVE = ['core/base/v7', 'math/mathcore/v7', 'io/io/v7']
+
+
+ERR_RELEASE_NOT_FOUND = 2
+
+
+#
+## CLI arguments
+#
+class ReleaseValidation(argparse.Action):
+def __call__(self, parser, namespace, value, option_string=None):
+if not re.match(r'6\.\d\d\.\d\d', value):
+raise argparse.ArgumentTypeError(
+"release number should of the form '6.dd.dd'")
+setattr(namespace, self.dest, value)
+return value
+
+parser = argparse.ArgumentParser(
+description='Build PyPi package for cppyy containing the minimum of ROOT')
+parser.add_argument('-r', '--release', type=str, nargs='?',
+action=ReleaseValidation, help='ROOT release to use')
+
+args = parser.parse_args()
+
+
+#
+## ROOT source pull and cleansing
+#
+def clean_directory(directory, keeplist, trim_cmake=True):
+removed_entries = []
+for entry in os.listdir(directory):
+if entry[0] == '.' or entry in keeplist:
+continue
+removed_entries.append(entry)
+entry = os.path.join(directory, entry)
+print('now removing', entry)
+if os.path.isdir(entry):
+shutil.rmtree(entry)
+else:
+os.remove(entry)
+
+if not trim_cmake:
+return
+
+# now take the removed entries out of the CMakeLists.txt
+if removed_entries:
+inp = os.path.join(directory, 'CMakeLists.txt')
+print('trimming', inp)
+outp = inp+'.new'
+new_cml = open(outp, 'w')
+for line in open(inp).readlines():
+if ('add_subdirectory' in line) or\
+   ('COMMAND' in line and 'copy' in line) or\
+   ('ROOT_ADD_TEST_SUBDIRECTORY' in line) or\
+   ('install(DIRECTORY' in line):
+for sub in removed_entries:
+if sub in line:
+line = '#'+line
+break
+new_cml.write(line)
+new_cml.close()
+os.rename(outp, inp)
+else:
+print('reusing existing %s/CMakeLists.txt' % (directory,))
+ 
+
+class ReleaseValidation(argparse.Action):
+def __call__(self, parser, namespace, value, option_string=None):
+if not re.match(r'6\.\d\d\.\d\d', value):
+raise argparse.ArgumentTypeError(
+"release number should of the form '6.dd.dd'")
+setattr(namespace, self.dest, value)
+return value
+
+parser = argparse.ArgumentParser(
+description='Build PyPi package for cppyy containing the minimum of ROOT')
+parser.add_argument('-r', '--release', type=str, nargs='?',
+action=ReleaseValidation, help='ROOT release to use')
+
+args = parser.parse_args()
+
+if not os.path.exists(TARBALL_CACHE_DIR):
+os.mkdir(TARBALL_CACHE_DIR)
+
+if args.release:
+  # use provided release
+fn = 'root_v%s.source.tar.gz' % args.release
+addr = 'https://root.cern.ch/download/'+fn
+if not os.path.exists(os.path.join(TARBALL_CACHE_DIR, fn)):
+try:
+print('retrieving', fn)
+resp = urllib2.urlopen(addr, fn)
+out = open(os.path.join(TARBALL_CACHE_DIR, fn), 'wb')
+out.write(resp.read())
+out.close()
+except urllib2.HTTPError:
+print('release %s not found' % args.release)
+

[pypy-commit] pypy.org extradoc: update the values

2017-06-23 Thread arigo
Author: Armin Rigo 
Branch: extradoc
Changeset: r893:99c987848217
Date: 2017-06-24 00:27 +0200
http://bitbucket.org/pypy/pypy.org/changeset/99c987848217/

Log:update the values

diff --git a/don1.html b/don1.html
--- a/don1.html
+++ b/don1.html
@@ -9,13 +9,13 @@
 
   $(function() {
 $("#progressbar").progressbar({
-  value: 63.7
+  value: 63.8
});
   });
 
 

-   $66891 of $105000 (63.7%)
+   $67020 of $105000 (63.8%)


 
@@ -23,7 +23,7 @@
   
   This donation goes towards supporting Python 3 in 
PyPy.
   Current status:
-we have $2688 left
+we have $2804 left
   in the account. Read proposal
   
   
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] cffi default: Expand this paragraph

2017-06-23 Thread arigo
Author: Armin Rigo 
Branch: 
Changeset: r2990:0c3756872e68
Date: 2017-06-23 19:57 +0200
http://bitbucket.org/cffi/cffi/changeset/0c3756872e68/

Log:Expand this paragraph

diff --git a/doc/source/cdef.rst b/doc/source/cdef.rst
--- a/doc/source/cdef.rst
+++ b/doc/source/cdef.rst
@@ -510,16 +510,26 @@
``static char *const FOO;``).
 
 Currently, it is not supported to find automatically which of the
-various integer or float types you need at which place.
-If a type is named, and an integer type, then use ``typedef
-int... the_type_name;``.  In the case of
-function arguments or return type, when it is a simple integer/float
-type, it may be misdeclared (if you misdeclare a function ``void
-f(long)`` as ``void f(int)``, it still works, but you have to call it
-with arguments that fit an int).  But it doesn't work any longer for
-more complex types (e.g. you cannot misdeclare a ``int *`` argument as
-``long *``) or in other locations (e.g. a global array ``int a[5];``
-must not be misdeclared ``long a[5];``).  CFFI considers `all types listed
+various integer or float types you need at which place---except in the
+following case: if such a type is explicitly named.  For an integer
+type, use ``typedef int... the_type_name;``, or another type like
+``typedef unsigned long... the_type_name;``.  Both are equivalent and
+replaced by the real C type, which must be an integer type.
+Similarly, for floating-point types, use ``typedef float...
+the_type_name;`` or equivalently ``typedef double...  the_type_name;``.
+Note that ``long double`` cannot be detected this way.
+
+In the case of function arguments or return types, when it is a simple
+integer/float type, you can simply misdeclare it.  If you misdeclare a
+function ``void f(long)`` as ``void f(int)``, it still works (but you
+have to call it with arguments that fit an int).  It works because the C
+compiler will do the casting for us.  This C-level casting of arguments
+and return types only works for regular function, and not for function
+pointer types; currently, it also does not work for variadic functions.
+
+For more complex types, you have no choice but be precise.  For example,
+you cannot misdeclare a ``int *`` argument as ``long *``, or a global
+array ``int a[5];`` as ``long a[5];``.  CFFI considers `all types listed
 above`_ as primitive (so ``long long a[5];`` and ``int64_t a[5]`` are
 different declarations).  The reason for that is detailed in `a comment
 about an issue.`__
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Use correct implementation for Decimal.compare_total{, _mag}(). Fixes #2586 and #2587

2017-06-23 Thread rlamy
Author: Ronan Lamy 
Branch: py3.5
Changeset: r91640:f2b370578863
Date: 2017-06-23 18:49 +0100
http://bitbucket.org/pypy/pypy/changeset/f2b370578863/

Log:Use correct implementation for Decimal.compare_total{,_mag}(). Fixes
#2586 and #2587

diff --git a/extra_tests/test_decimal.py b/extra_tests/test_decimal.py
--- a/extra_tests/test_decimal.py
+++ b/extra_tests/test_decimal.py
@@ -1,3 +1,5 @@
+import pytest
+
 import pickle
 import sys
 
@@ -8,6 +10,11 @@
 # import _decimal as C
 # import _pydecimal as P
 
+@pytest.yield_fixture(params=[C, P], ids=['_decimal', '_pydecimal'])
+def module(request):
+yield request.param
+
+
 def test_C():
 sys.modules["decimal"] = C
 import decimal
@@ -54,3 +61,10 @@
 r = pickle.loads(p)
 assert isinstance(r, P.DecimalTuple)
 assert r == pdt
+
+def test_compare_total(module):
+assert module.Decimal('12').compare_total(module.Decimal('12.0')) == 1
+assert module.Decimal('4367').compare_total(module.Decimal('NaN')) == -1
+
+def test_compare_total_mag(module):
+assert module.Decimal(1).compare_total_mag(-2) == -1
diff --git a/lib_pypy/_decimal.py b/lib_pypy/_decimal.py
--- a/lib_pypy/_decimal.py
+++ b/lib_pypy/_decimal.py
@@ -719,8 +719,8 @@
 
 compare = _make_binary_operation('compare')
 compare_signal = _make_binary_operation('compare_signal')
-compare_total = _make_binary_operation('compare')
-compare_total_mag = _make_binary_operation('compare')
+compare_total = _make_binary_operation('compare_total')
+compare_total_mag = _make_binary_operation('compare_total_mag')
 logical_and = _make_binary_operation('logical_and')
 logical_or = _make_binary_operation('logical_or')
 logical_xor = _make_binary_operation('logical_xor')
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: remove unittest cruft

2017-06-23 Thread rlamy
Author: Ronan Lamy 
Branch: py3.5
Changeset: r91639:51cd15a0c2d6
Date: 2017-06-23 18:25 +0100
http://bitbucket.org/pypy/pypy/changeset/51cd15a0c2d6/

Log:remove unittest cruft

diff --git a/extra_tests/test_decimal.py b/extra_tests/test_decimal.py
--- a/extra_tests/test_decimal.py
+++ b/extra_tests/test_decimal.py
@@ -8,52 +8,49 @@
 # import _decimal as C
 # import _pydecimal as P
 
+def test_C():
+sys.modules["decimal"] = C
+import decimal
+d = decimal.Decimal('1')
+assert isinstance(d, C.Decimal)
+assert isinstance(d, decimal.Decimal)
+assert isinstance(d.as_tuple(), C.DecimalTuple)
 
-class TestPythonAPI:
+assert d == C.Decimal('1')
 
-def check_equal(self, val, proto):
-d = C.Decimal(val)
-p = pickle.dumps(d, proto)
-assert d == pickle.loads(p)
+def check_round_trip(val, proto):
+d = C.Decimal(val)
+p = pickle.dumps(d, proto)
+assert d == pickle.loads(p)
 
-def test_C(self):
+def test_pickle():
+v = '-3.123e81723'
+for proto in range(pickle.HIGHEST_PROTOCOL + 1):
 sys.modules["decimal"] = C
-import decimal
-d = decimal.Decimal('1')
-assert isinstance(d, C.Decimal)
-assert isinstance(d, decimal.Decimal)
-assert isinstance(d.as_tuple(), C.DecimalTuple)
+check_round_trip('-3.14159', proto)
+check_round_trip(v, proto)
 
-assert d == C.Decimal('1')
+cd = C.Decimal(v)
+pd = P.Decimal(v)
+cdt = cd.as_tuple()
+pdt = pd.as_tuple()
+assert cdt.__module__ == pdt.__module__
 
-def test_pickle(self):
-v = '-3.123e81723'
-for proto in range(pickle.HIGHEST_PROTOCOL + 1):
-sys.modules["decimal"] = C
-self.check_equal('-3.14159', proto)
-self.check_equal(v, proto)
+p = pickle.dumps(cdt, proto)
+r = pickle.loads(p)
+assert isinstance(r, C.DecimalTuple)
+assert cdt == r
 
-cd = C.Decimal(v)
-pd = P.Decimal(v)
-cdt = cd.as_tuple()
-pdt = pd.as_tuple()
-assert cdt.__module__ == pdt.__module__
+sys.modules["decimal"] = C
+p = pickle.dumps(cd, proto)
+sys.modules["decimal"] = P
+r = pickle.loads(p)
+assert isinstance(r, P.Decimal)
+assert r == pd
 
-p = pickle.dumps(cdt, proto)
-r = pickle.loads(p)
-assert isinstance(r, C.DecimalTuple)
-assert cdt == r
-
-sys.modules["decimal"] = C
-p = pickle.dumps(cd, proto)
-sys.modules["decimal"] = P
-r = pickle.loads(p)
-assert isinstance(r, P.Decimal)
-assert r == pd
-
-sys.modules["decimal"] = C
-p = pickle.dumps(cdt, proto)
-sys.modules["decimal"] = P
-r = pickle.loads(p)
-assert isinstance(r, P.DecimalTuple)
-assert r == pdt
+sys.modules["decimal"] = C
+p = pickle.dumps(cdt, proto)
+sys.modules["decimal"] = P
+r = pickle.loads(p)
+assert isinstance(r, P.DecimalTuple)
+assert r == pdt
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit


[pypy-commit] pypy py3.5: Make slices of array memoryviews usable as writable buffers if contiguous.

2017-06-23 Thread rlamy
Author: Ronan Lamy 
Branch: py3.5
Changeset: r91638:9068d4152e3f
Date: 2017-06-23 17:13 +0100
http://bitbucket.org/pypy/pypy/changeset/9068d4152e3f/

Log:Make slices of array memoryviews usable as writable buffers if
contiguous.

diff --git a/pypy/module/array/interp_array.py 
b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -1,5 +1,5 @@
 from rpython.rlib import jit, rgc
-from rpython.rlib.buffer import RawBuffer
+from rpython.rlib.buffer import RawBuffer, SubBuffer
 from rpython.rlib.objectmodel import keepalive_until_here
 from rpython.rlib.rarithmetic import ovfcheck, widen
 from rpython.rlib.unroll import unrolling_iterable
@@ -930,6 +930,14 @@
 assert not self.readonly
 return self.data
 
+def new_slice(self, start, step, slicelength):
+if step == 1:
+n = self.itemsize
+newbuf = SubBuffer(self.data, start * n, slicelength * n)
+return ArrayView(newbuf, self.fmt, self.itemsize, self.readonly)
+else:
+return BufferView.new_slice(self, start, step, slicelength)
+
 
 unpack_driver = jit.JitDriver(name='unpack_array',
   greens=['selfclass', 'tp'],
diff --git a/pypy/module/array/test/test_array.py 
b/pypy/module/array/test/test_array.py
--- a/pypy/module/array/test/test_array.py
+++ b/pypy/module/array/test/test_array.py
@@ -1062,6 +1062,13 @@
 def test_fresh_array_buffer_bytes(self):
 assert bytes(memoryview(self.array('i'))) == b''
 
+def test_mview_slice_aswritebuf(self):
+import struct
+a = self.array('B', b'abcdef')
+view = memoryview(a)[1:5]
+struct.pack_into('>H', view, 1, 0x1234)
+assert a.tobytes() == b'ab\x12\x34ef'
+
 
 class AppTestArrayReconstructor:
 spaceconfig = dict(usemodules=('array', 'struct'))
___
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit