Opened 6 years ago

Closed 6 years ago

#58004 closed defect (fixed)

py-backports and py-backports.weakref conflict

Reported by: mfacorcoran Owned by: reneeotten <reneeotten@…>
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: stromnov (Andrey Stromnov), emcrisostomo (Enrico Maria Crisostomo)
Port: py-backports py-backports.weakref

Description

I just upgraded python version 2 to python27@2.7.15_1+universal and I get an error importing matplotlib (I've got py27-matplotlib @2.2.3_0+cairo+tkinter+webagg active)

Python 2.7.15 (default, Sep 14 2018, 17:22:47)
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.10.25.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/__init__.py", line 130, in <module>
    from matplotlib.rcsetup import defaultParams, validate_backend, cycler
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/rcsetup.py", line 29, in <module>
    from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib/fontconfig_pattern.py", line 28, in <module>
    from backports.functools_lru_cache import lru_cache
ImportError: No module named backports.functools_lru_cache

Change History (9)

comment:1 Changed 6 years ago by reneeotten (Renee Otten)

that is strange... because py27-backports-functools_lru_cache is correctly listed as a dependency. Can you make sure you actually have it installed? Please post the output of port installed -v py27-backports-functools_lru_cache here?

comment:2 Changed 6 years ago by mfacorcoran

here's what I get:

% port installed -v py27-backports-functools_lru_cache
The following ports are currently installed:
  py27-backports-functools_lru_cache @1.2.1_0
  py27-backports-functools_lru_cache @1.5_0
  py27-backports-functools_lru_cache @1.5_1 (active)

comment:3 Changed 6 years ago by mfacorcoran

An odd thing is that the backports package seems to be missing an __init__.py file:

In [10]: cd backports
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/backports

In [11]: ls -l
total 16
-rw-r--r--+ 1 root  wheel   155 Sep 27  2017 __init__.py.mp_1531165935
-rw-r--r--+ 1 root  wheel   298 Sep 29  2017 __init__.pyc.mp_1531165935
drwxr-xr-x+ 6 root  wheel   192 Feb  1 16:25 configparser/
-rw-r--r--+ 1 root  wheel  7317 Feb  4  2018 functools_lru_cache.py
-rw-r--r--+ 1 root  wheel  7506 Jul 13  2018 functools_lru_cache.pyc
drwxr-xr-x+ 6 root  wheel   192 Jan 22  2018 shutil_get_terminal_size/
drwxr-xr-x+ 4 root  wheel   128 Jan 14 15:30 ssl_match_hostname/
Last edited 6 years ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:4 Changed 6 years ago by ryandesign (Ryan Carsten Schmidt)

The -v flag (and all other single-dash flags) have no effect unless placed right after the word port, before the command verb.

comment:5 in reply to:  3 Changed 6 years ago by ryandesign (Ryan Carsten Schmidt)

Replying to mfacorcoran:

An odd thing is that the backports package seems to be missing an __init__.py file:

In [10]: cd backports
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/backports

In [11]: ls -l
total 16
-rw-r--r--+ 1 root  wheel   155 Sep 27  2017 __init__.py.mp_1531165935
-rw-r--r--+ 1 root  wheel   298 Sep 29  2017 __init__.pyc.mp_1531165935
drwxr-xr-x+ 6 root  wheel   192 Feb  1 16:25 configparser/
-rw-r--r--+ 1 root  wheel  7317 Feb  4  2018 functools_lru_cache.py
-rw-r--r--+ 1 root  wheel  7506 Jul 13  2018 functools_lru_cache.pyc
drwxr-xr-x+ 6 root  wheel   192 Jan 22  2018 shutil_get_terminal_size/
drwxr-xr-x+ 4 root  wheel   128 Jan 14 15:30 ssl_match_hostname/

Looks like you forced the activation of another port that conflicted with this one, which caused MacPorts to rename the conflicting files of this port (apparently including __init__.py and __init__.pyc). Uninstall this port, and the other conflicting one, then reinstall this port. And in the future, refrain from forcing the activation of ports unless you want to encounter problems like this again.

comment:6 Changed 6 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: stromnov emcrisostomo added
Port: py-backports py-backports.weakref added
Priority: HighNormal
Summary: python27 @2.7.15_1+universal issue with importing matplotlibpy-backports and py-backports.weakref conflict

Looks like the conflict is between pyXY-backports and pyXY-backports.weakref. They both claim the file /opt/local/Library/Frameworks/Python.framework/Versions/X.Y/lib/pythonX.Y/site-packages/backports/__init__.py.

--->  Computing dependencies for py27-backports.weakref
--->  Fetching archive for py27-backports.weakref
--->  Attempting to fetch py27-backports.weakref-1.0.post1_0.darwin_17.noarch.tbz2 from https://packages.macports.org/py27-backports.weakref
--->  Attempting to fetch py27-backports.weakref-1.0.post1_0.darwin_17.noarch.tbz2.rmd160 from https://packages.macports.org/py27-backports.weakref
--->  Installing py27-backports.weakref @1.0.post1_0
--->  Activating py27-backports.weakref @1.0.post1_0
Error: Failed to activate py27-backports.weakref: Image error: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/backports/__init__.py is being used by the active py27-backports port.  Please deactivate this port first, or use 'port -f activate py27-backports.weakref' to force the activation.

Those ports should either declare that they conflict or the conflict should be resolved somehow.

comment:7 Changed 6 years ago by reneeotten (Renee Otten)

yes, all py-backports-* port should probably have the code like this:

    depends_lib-append \
                    port:py${python.version}-backports

    post-destroot {
        foreach f {__init__.py __init__.pyc __init__.pyo __pycache__} {
            set fp "${destroot}${python.pkgd}/backports/$f"
            if {[file exists ${fp}]} {
                file delete -force ${fp}
            }
        }

which is present in most of them, but indeed not in py-backports.weakref, py-backports.csv and py-backports_abc. It's probably good to see whether these ports are indeed affected by this, and make this change when needed.

comment:8 Changed 6 years ago by reneeotten (Renee Otten)

I checked all py-backports-* ports and only py-backports.weakref has this issue. Should be fixed with PR3574.

comment:9 Changed 6 years ago by reneeotten <reneeotten@…>

Owner: set to reneeotten <reneeotten@…>
Resolution: fixed
Status: newclosed

In fd46f1b5af8005bff0b344df922da4c68e16e3e7/macports-ports (master):

py-backports.weakref: fix destroot issues

  • remove py35/py36 subports (functionality was introduced in PY34)
  • only dependents of these subports are py-tensorflow, but that

dependency is incorrect.

Closes: #58004

Note: See TracTickets for help on using tickets.