Skip to content

Conversation

extraymond
Copy link
Contributor

@extraymond extraymond commented Apr 26, 2018

Pypy has evolved greatly, it might be a good idea to remove the import ban.

References to other Issues or PRs

Fixes #14658

Brief description of what is fixed or changed

Remove import ban under pypy

Other comments

Pypy has evolved greatly, it might be a good idea to remove the import ban.
@asmeurer
Copy link
Member

Can we get it tested on Travis? It looks like it isn't installed here (the header says "numpy: none" and there are a lot of skipped tests in the lambdify tests). Does NumPyPy come with PyPy or does it have to be installed separately?

@extraymond
Copy link
Contributor Author

Numpypy is deprecated for pypy, numpy is compatible with pypy now.

@asmeurer
Copy link
Member

In that case, we need to make sure numpy is installed in the pypy travis build.

@asmeurer
Copy link
Member

asmeurer commented May 3, 2018

Note to anyone reviewing this: you need to check the PyPy tests on Travis manually (they are in allowed_failures).

@extraymond
Copy link
Contributor Author

Hi! Is there anything I can do to help push this forward?

@asmeurer
Copy link
Member

Is it possible to get it tested on Travis?

@extraymond
Copy link
Contributor Author

@asmeurer I've never contributed to sympy before, can you show me how to get this tested on travis. Or more generally how one should know before trying to contribute to sympy? Thx.

@asmeurer
Copy link
Member

The Travis tests are configured in .travis.yml. You can see the build by clicking the "show all checks" button below (the PyPy builds are at the bottom, under "allowed failures"). You can see in the header of the tests that NumPy isn't installed (numpy: None). I don't know how to install NumPy in PyPy. Can it be pip installed? However it is done, it needs to be added to .travis.yml.

Also, I would recommend merging with the latest master, as it has some other fixes for the PyPy tests.

@extraymond
Copy link
Contributor Author

Thx for your reply!
I'm not familiar with travis but only played with gitlab-ci. So I'm not really sure how travis configured the test machine.
But Yes, numpy can be installed in pypy with:

pypy -m pip install numpy
or
pip install numpy

Is pypy3 included in the test matrix? It seems that pypy2 is used in the test matrix according to the output in the console log.

@asmeurer
Copy link
Member

Not right now. What is the status of pypy vs. pypy3? Ideally we would only support the one that is actively developed.

@extraymond
Copy link
Contributor Author

extraymond commented Jul 1, 2018

From what I gathered from pypy blog and their release note, after they've received grants from Mozilla, they have completed python 3.5 support (plus f-string) and are working toward a 3.6 release within 2018.

Besides the momentum toward 3.6, the one concerning point about whether to support pypy3 is that windows(32bit) binary is still in beta, while pypy2 has stable windows binary support.

I'm not a pypy dev so this is not official, however I hope this material helps people to like pypy more. I've been toying sympy with pypy3 for awhile and really likes the speed-up.


Reference:

  1. Mozilla grant for pypy to complete 3.5
  2. Stating 3.6 within 2018
  3. Stating windows binary in beta quality

@oscarbenjamin oscarbenjamin added the Alternate Python Related to an alternate Python implementation such as PyPy or Jython. label Jan 23, 2019
@czgdp1807
Copy link
Member

@asmeurer Does this PR still holds a chance of being merged?

@extraymond
Copy link
Contributor Author

Can anyone familiar with travis take a look at this.

I've tried the sympy test suite in a ubuntu 18.04 container with the required packages installed.
Here's the result:

If I run the test after commenting out the two lines for pypy3, the test suite failed on this particular test, others seems to pass just fine:

sympy/external/tests/test_autowrap.py[16] sssssss.ssss.sEs                      [FAIL]

The error traceback:

Traceback (most recent call last):
  File "/home/ubuntu/sympy/sympy/utilities/autowrap.py", line 169, in _process_files
    retoutput = check_output(command, stderr=STDOUT)
  File "/snap/pypy3/50/lib-python/3/subprocess.py", line 356, in check_output
    **kwargs).stdout
  File "/snap/pypy3/50/lib-python/3/subprocess.py", line 438, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/home/ubuntu/.venv/bin/python', 'setup.py', 'build_ext', '--inplace']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ubuntu/sympy/sympy/external/tests/test_autowrap.py", line 289, in test_autowrap_custom_printer
    func = autowrap(expr, backend='cython', tempdir=tmpdir, code_gen=gen)
  File "/home/ubuntu/sympy/sympy/core/cache.py", line 96, in wrapper
    retval = cfunc(*args, **kwargs)
  File "/snap/pypy3/50/lib-python/3/functools.py", line 543, in wrapper
    result = user_function(*args, **kwds)
  File "/home/ubuntu/sympy/sympy/utilities/autowrap.py", line 648, in autowrap
    return code_wrapper.wrap_code(routine, helpers=helps)
  File "/home/ubuntu/sympy/sympy/utilities/autowrap.py", line 150, in wrap_code
    self._process_files(routine)
  File "/home/ubuntu/sympy/sympy/utilities/autowrap.py", line 173, in _process_files
    " ".join(command), e.output.decode('utf-8')))
sympy.utilities.autowrap.CodeWrapError: Error while executing command: /home/ubuntu/.venv/bin/python setup.py build_ext --inplace. Command output is:
Compiling wrapper_module_4.pyx because it changed.
[1/1] Cythonizing wrapper_module_4.pyx
running build_ext
building 'wrapper_module_4' extension
creating build
creating build/temp.linux-x86_64-3.6
gcc -pthread -DNDEBUG -O2 -fPIC -I/home/ubuntu/.venv/include -I/snap/pypy3/50/include -c wrapper_module_4.c -o build/temp.linux-x86_64-3.6/wrapper_module_4.o -std=c99
wrapper_module_4.c:506:0: warning: "PyObject_Unicode" redefined
   #define PyObject_Unicode             PyObject_Str

In file included from /snap/pypy3/50/include/Python.h:143:0,
                 from wrapper_module_4.c:23:
/snap/pypy3/50/include/pypy_decl.h:677:0: note: this is the location of the previous definition
 #define PyObject_Unicode PyPyObject_Unicode

gcc -pthread -DNDEBUG -O2 -fPIC -I/home/ubuntu/.venv/include -I/snap/pypy3/50/include -c wrapped_code_4.c -o build/temp.linux-x86_64-3.6/wrapped_code_4.o -std=c99
wrapped_code_4.c: In function ‘autofunc’:
wrapped_code_4.c:15:22: error: ‘S_PI’ undeclared (first use in this function); did you mean ‘__P’?
    autofunc_result = S_PI*a;
                      ^~~~
                      __P
wrapped_code_4.c:15:22: note: each undeclared identifier is reported only once for each function it appears in
/home/ubuntu/.venv/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File:
/tmp/tmpt0sybg3q/wrapper_module_4.pyx
  tree = Parsing.p_module(s, pxd, full_module_name)
error: command 'gcc' failed with exit status 1


============================ tests finished: 8715 passed, 340 skipped, 380 expected to fail, 4 expected to fail but passed, 1 exceptions, in 3209.44 seconds =============================

@asmeurer
Copy link
Member

It looks like autowrap has issues with pypy. Does it even work there? I'm curious how it is using Cython. Does Cython work with pypy?

@extraymond
Copy link
Contributor Author

It looks like autowrap has issues with pypy. Does it even work there? I'm curious how it is using Cython. Does Cython work with pypy?

Hi! I've tried the helloworld example from cython and it worked under pypy.
But it doesn't make much sense since pypy is kinda irrelevant if a user is using cython already.

Are there anything I can help to make this PR passed? It would be nice to allow sympy to import numpy under pypy. Thanks.

@eagleoflqj eagleoflqj closed this May 3, 2022
@eagleoflqj
Copy link
Member

The fork has been deleted so the PR cannot be reopened. I'd test it locally and if it works, make a new PR with your patch.

@asmeurer
Copy link
Member

asmeurer commented May 3, 2022

By the way, if someone deletes their fork, I take that to mean that they withdraw their contribution, so in my opinion, such PRs should not be merged unless the PR author gives explicit permission to do so. I mention this because it is technically possible to download the PR using https://gist.github.com/piscisaureus/3342247. So it's good to just close such PRs.

@eagleoflqj
Copy link
Member

I take that to mean that they withdraw their contribution

So that means, if I make a PR to remove the four lines as this PR did, I should use my name&email instead of this author's?

@asmeurer
Copy link
Member

asmeurer commented May 3, 2022

This particular PR is so simple that I don't think it really matters. If it were something adding new code that you wanted to use, it would be good to try to contact the person to see if they still are OK with contributing it, or else rewrite it yourself from scratch.

@extraymond
Copy link
Contributor Author

Hi! I vaguely remember this has been already merged years ago. Feel free to take the line and raise the PR again.

@asmeurer
Copy link
Member

asmeurer commented May 4, 2022

Just to be clear, my comments were intended to be generally about any PR where the fork has been deleted, not just this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Alternate Python Related to an alternate Python implementation such as PyPy or Jython. Needs Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lambdify with numpy failed on pypy
6 participants