Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subversion's Python bindings fail in 1.13.0_3 or later for Python 2.7 and 3.8 #53193

Closed
3 of 4 tasks
rjollos opened this issue Apr 15, 2020 · 4 comments
Closed
3 of 4 tasks
Labels
outdated PR was locked due to age

Comments

@rjollos
Copy link

rjollos commented Apr 15, 2020

  • ran brew update and can still reproduce the problem?
  • ran brew doctor, fixed all issues and can still reproduce the problem?
  • ran brew gist-logs <formula> (where <formula> is the name of the formula that failed) and included the output link?
  • if brew gist-logs didn't work: ran brew config and brew doctor and included their output with your issue?

What you were trying to do (and why)

I'm trying to use the Subversion Python bindings installed with Brew, which I've successfully done for many years and many releases of Subversion provided by Homebrew, until recently. The Trac Project, for which I'm a developer, has some modules and a suite of tests that use the Subversion Python bindings.

Here is my gist-logs: https://gist.github.com/rjollos/9d21dc5316a6ab6e8650bd253cd9272a

What happened (include command output)

Using Subversion Python bindings works prior to e073d0b. In e073d0b the dependency was changed to from Python@2 to [email protected]. The Subversion bindings in 1.13 release are not compatible with Python 3. In Subversion 1.14 the bindings have been made compatible with Python 3 (see release notes). I've tested Subversion 1.14dev built from source on my OSX computer and the bindings work fine with 1.14dev. In fact the entire Test Suite for the Trac Project passes, as further proof.

So I think you can switch the dependency to [email protected] when 1.14 is released (looks like that will be soon), but for now I believe the brew formula needs to be switched back to have a dependency on Python@2. Details below.

Command output

I add the libraries into a Python 2.7 virtualenv created using pyenv:

svn_python=$(brew --prefix subversion)/lib/svn-python
site_packages=$(find $(pyenv prefix)/ -name "site-packages" -print)
ln -sf "$svn_python/svn" "$site_packages/"
ln -sf "$svn_python/libsvn" "$site_packages/"
echo "$svn_python/libsvn" > "$site_packages/svn.pth"

Using 1.13.0_3 (e073d0b) or later results in the following:

$ python --version
Python 2.7.17
$ python -c "from svn import core"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/rjollos/.pyenv/versions/trac-2.7/lib/python2.7/site-packages/svn/core.py", line 26, in <module>
    from libsvn.core import *
  File "/Users/rjollos/.pyenv/versions/trac-2.7/lib/python2.7/site-packages/libsvn/core.py", line 17, in <module>
    _core = swig_import_helper()
  File "/Users/rjollos/.pyenv/versions/trac-2.7/lib/python2.7/site-packages/libsvn/core.py", line 16, in swig_import_helper
    return importlib.import_module('_core')
  File "/Users/rjollos/.pyenv/versions/2.7.17/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
ImportError: dlopen(/usr/local/opt/subversion/lib/svn-python/libsvn/_core.so, 2): Symbol not found: _PyBytes_AsString
  Referenced from: /usr/local/Cellar/subversion/1.13.0_3/lib/libsvn_swig_py-1.0.dylib
  Expected in: flat namespace
 in /usr/local/Cellar/subversion/1.13.0_3/lib/libsvn_swig_py-1.0.dylib

Doing the same with a Python 3.8 virtualenv also fails:

trac-py382) trac-dev $ python --version
Python 3.8.2
(trac-py382) trac-dev $ python -c "from svn import core"
Traceback (most recent call last):
  File "/Users/rjollos/.pyenv/versions/3.8.2/envs/trac-py382/lib/python3.8/site-packages/libsvn/core.py", line 14, in swig_import_helper
    return importlib.import_module(mname)
  File "/Users/rjollos/.pyenv/versions/3.8.2/Python.framework/Versions/3.8/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 657, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 556, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1101, in create_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ImportError: dlopen(/Users/rjollos/.pyenv/versions/3.8.2/envs/trac-py382/lib/python3.8/site-packages/libsvn/_core.so, 2): Symbol not found: _PyFile_AsFile
  Referenced from: /usr/local/Cellar/subversion/1.13.0_3/lib/libsvn_swig_py-1.0.dylib
  Expected in: flat namespace
 in /usr/local/Cellar/subversion/1.13.0_3/lib/libsvn_swig_py-1.0.dylib

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Users/rjollos/.pyenv/versions/3.8.2/envs/trac-py382/lib/python3.8/site-packages/svn/core.py", line 26, in <module>
    from libsvn.core import *
  File "/Users/rjollos/.pyenv/versions/3.8.2/envs/trac-py382/lib/python3.8/site-packages/libsvn/core.py", line 17, in <module>
    _core = swig_import_helper()
  File "/Users/rjollos/.pyenv/versions/3.8.2/envs/trac-py382/lib/python3.8/site-packages/libsvn/core.py", line 16, in swig_import_helper
    return importlib.import_module('_core')
  File "/Users/rjollos/.pyenv/versions/3.8.2/Python.framework/Versions/3.8/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ImportError: dlopen(/usr/local/lib/svn-python/libsvn/_core.so, 2): Symbol not found: _PyFile_AsFile
  Referenced from: /usr/local/Cellar/subversion/1.13.0_3/lib/libsvn_swig_py-1.0.dylib
  Expected in: flat namespace
 in /usr/local/Cellar/subversion/1.13.0_3/lib/libsvn_swig_py-1.0.dylib

However, if I install the revision of the formulae that is the parent of e073d0b, which is b309c2e,

$ brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/b309c2efabeb977aa97288efb85d7ee5ad2808b0/Formula/subversion.rb
$ brew pin subversion

Then python -c "from svn import core" succeeds and the entire Trac Project test suite passes.

What you expected to happen

The following should product no errors:

$ python --version
Python 2.7.17
$ python -c "from svn import core"

Step-by-step reproduction instructions (by running brew install commands)

$ brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/b309c2efabeb977aa97288efb85d7ee5ad2808b0/Formula/subversion.rb

results in usable Subversion Python bindings.

However,

$ brew install subversion

at present installs 1.13.0_4, for which the Subversion Python bindings fail.

@SMillerDev
Copy link
Member

@iMichka @Bo98 ideas?

@iMichka
Copy link
Member

iMichka commented Apr 15, 2020

The easiest solution is to revert to system Python 2 on mac.

It's interesting because I thought I read that the current subversion version was supporting Python 3 somewhere, and the build did not complain ...

@rjollos
Copy link
Author

rjollos commented Apr 15, 2020

It's interesting because I thought I read that the current subversion version was supporting Python 3 somewhere, and the build did not complain ...

Looks like there was a lot of discussion about including the Py3 work in 1.13, but ultimately it did not happen.

iMichka added a commit to iMichka/homebrew-core that referenced this issue Apr 17, 2020
@rjollos
Copy link
Author

rjollos commented Apr 17, 2020

1.13.0_5 works well. Thanks!

@lock lock bot added the outdated PR was locked due to age label May 20, 2020
@lock lock bot locked as resolved and limited conversation to collaborators May 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants