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

Installation fails on pkgconfig AttributeError #158

Closed
raymondEhlers opened this issue Dec 10, 2018 · 4 comments
Closed

Installation fails on pkgconfig AttributeError #158

raymondEhlers opened this issue Dec 10, 2018 · 4 comments

Comments

@raymondEhlers
Copy link
Contributor

When installing lz4 via pip with python 3.6, I received the following AttributeError related to pkgconfig:

test@e75e445ebc4d:/opt/test$ pip install --user lz4
Collecting lz4
  Downloading https://files.pythonhosted.org/packages/f1/4f/878f1827042c5b6828bc23d160f31e242ec820810b8bd04b30b631029952/lz4-2.1.2.tar.gz (128kB)
    100% |████████████████████████████████| 133kB 2.6MB/s
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-842vmqmd/lz4/setup.py", line 34, in <module>
        liblz4_found = pkgconfig_installed('liblz4', LZ4_REQUIRED_VERSION, default=False)
      File "/tmp/pip-install-842vmqmd/lz4/setup.py", line 24, in pkgconfig_installed
        installed = pkgconfig.installed(lib, required_version)
    AttributeError: module 'pkgconfig' has no attribute 'installed'

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-842vmqmd/lz4/

In trying to reproduce it, I found the issue is caused by some third party software which sets the PYTHONPATH to a directory which includes an empty pkgconfig directory... I realize that this is a bit of a silly issue, and is mostly unrelated to lz4 (I will try to get the third party software to fix it), but I imagine that other software could also cause this same issue.

So I would argue that it's worth addressing. I think it can be addressed with a small modification of the lz4 setup.py by adding around line 25:

 try:
   installed = pkgconfig.installed(lib, required_version
except AttributeError:
  # Problem with pkgconfig package
  pass
...

I'm happy to open a PR if you'd like. Please let me know what you think. Thanks!

@jonathanunderwood
Copy link
Member

Thanks for the report. My initial thoughts are:

  • Working around horribly broken unrelated software is not really in scope - that problem really needs fixing, it's pretty bad to override PYTHONPATH and break packages like that.
  • Simply passing on the exception isn't the right fix, as we're using pkgconfig to determine if there's a suitable system installed lz4 library.

On the otherhand, this is perhaps another valid case for falling back to building against the bundled lz4, so I'm not entirely opposed.

@jonathanunderwood
Copy link
Member

A better fix would be to change the import around line 16 to import the pkgconfig.installed function there (rather than just the package), and then use that. So something like:

try:
    import pkgconfig.installed as pkgconfig_installed
except ImportError:
    # pkgconfig is not installed. It will be installed by setup_requires.
    pass
...

I won't get chance to add a commit for this until the weekend, so if you had time to make a PR, that would be cool :)

@raymondEhlers
Copy link
Contributor Author

Thanks for bearing with me on this out of scope issue - I very much agree that the other software is breaking things in a really bad way (I've reported it, so I hope that they'll fix it). But I also really appreciate you considering a fall back here :-)

You're right that my solution wasn't really the best way to go about fixing it - I'll open a PR that implements your suggestion

raymondEhlers added a commit to raymondEhlers/python-lz4 that referenced this issue Dec 12, 2018
raymondEhlers added a commit to raymondEhlers/python-lz4 that referenced this issue Dec 12, 2018
raymondEhlers added a commit to raymondEhlers/python-lz4 that referenced this issue Dec 12, 2018
raymondEhlers added a commit to raymondEhlers/python-lz4 that referenced this issue Dec 12, 2018
@raymondEhlers
Copy link
Contributor Author

Addressed in #160

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants