Closed rjbrown99 closed 9 years ago
Hi, can you try latest version?
I've just added proper dependency on libxml2. This formula needs libxml2 --with-python
option installed and properly linked, ie. when you run python and do import libxml2mod
it shouldn't give you any error. Libxml2 package will tell you how to do that when installing, depending on your python version and other bits, one way that might work for you is echo /opt/boxen/homebrew/opt/libxml2/lib/python2.7/site-packages >> /opt/boxen/homebrew/lib/python2.7/site-packages/libxml2.pth
.
Thanks, I uninstalled createrepo and libxml2. I noticed that a reinstall of libxml2 was still using "--without-python" so next I followed this instruction: http://stackoverflow.com/questions/11054972/homebrew-install-libxml2-with-python-modules
Basically, brew edit libxml2 and change --without-python to --with-python. I reinstalled libxml2 and now I assume I have python support.
After reinstalling createrepo and also echoing to libxml2.pth (which did not previously exist), I still get the same error.
Note that python at the command line seems to be able to import libxml2 with no errors -
$ python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import libxml2mod
>>>
Same for rpm -
$ python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import rpm
>>>
OK, so here's what worked.
Step 1 - show my current Python path. The dir you included above was not in my path.
$ python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path
['', '/Library/Python/2.7/site-packages/pip-6.0.8-py2.7.egg', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC', '/Library/Python/2.7/site-packages', '/usr/local/opt/rpm4/lib/python2.7/site-packages', '/usr/local/opt/libxml2/lib/python2.7/site-packages']
>>>
Step 2 - Create a .pth file in an existing dir. I used /Library/Python/2.7/site-packages:
sudo vim /Library/Python/2.7/site-packages/libxml2.pth
/usr/local/opt/rpm4/lib/python2.7/site-packages
/usr/local/opt/libxml2/lib/python2.7/site-packages
Note that I had to add both paths to that file.
Now it works! Thanks, hope that helps.
Hi Robert, thanks. I're realised that the paths I've posted wouldn't work for you, as I'm using homebrew installed through boxen.
a) I believe there's no need to edit libxml2 (at least for me it worked fine). The message from configure is a bit misleading, cause it will deal with with python bindings in next separate step by calling setup.py.
b) Can you give me output from these commands from your system?
brew --prefix
which python
ls -al $(brew --prefix)/lib/python2.7/site-packages/rpm*
that's where I would expect my rpm4 module python bindings to beMy guess is that you're using system python, as opposed to me (using homebrew one). There seems to be quite a few possible combinations and ways to install things regarding homebrew & python, so it's a bit tricky to debug and test. But I'm currently looking into setting up a vagrant box with mac os x to be able to run some test on vanilla system.
Thanks! Here's what you asked for -
$ brew --prefix
/usr/local
$ which python
/usr/bin/python
$ ls -al $(brew --prefix)/lib/python2.7/site-packages/rpm*
total 20K
drwxr-xr-x 7 root wheel 238 Mar 22 11:40 ./
drwxr-xr-x 7 root wheel 238 Mar 22 15:36 ../
lrwxr-xr-x 1 root wheel 76 Mar 22 11:40 __init__.py -> ../../../../Cellar/rpm4/4.12.0.1/lib/python2.7/site-packages/rpm/__init__.py
lrwxr-xr-x 1 root wheel 72 Mar 22 11:40 _rpm.so -> ../../../../Cellar/rpm4/4.12.0.1/lib/python2.7/site-packages/rpm/_rpm.so
lrwxr-xr-x 1 root wheel 73 Mar 22 11:40 _rpmb.so -> ../../../../Cellar/rpm4/4.12.0.1/lib/python2.7/site-packages/rpm/_rpmb.so
lrwxr-xr-x 1 root wheel 73 Mar 22 11:40 _rpms.so -> ../../../../Cellar/rpm4/4.12.0.1/lib/python2.7/site-packages/rpm/_rpms.so
lrwxr-xr-x 1 root wheel 79 Mar 22 11:40 transaction.py -> ../../../../Cellar/rpm4/4.12.0.1/lib/python2.7/site-packages/rpm/transaction.py*
...and yes I am using the system-supplied python.
Closing this, I have tested this with vanilla OS X Yosemite and system python and as long as you properly add homebrew python site-packages to system python:
mkdir -p /Users/$(whoami)/Library/Python/2.7/lib/python/site-packages
echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> /Users/$(whoami)/Library/Python/2.7/lib/python/site-packages/homebrew.pth
and link libxml2:echo /usr/local/opt/libxml2/lib/python2.7/site-packages >> /usr/local/lib/python2.7/site-packages/libxml2.pth
all the packages work fine.I know this is closed, but I just wanted to comment that I just found your page while looking for createrepo, installed it with homebrew, and ran into this exact problem.
Is it possible to add a message to your createrepo output which states the same thing you said above after the install has finished? It wasn't obvious to me either.
Hi, thanks for suggestion.
Do you suggest to add it to "Caveats" section - output that homebrew will print when you install the package?
Currently there's this (might be slightly different depending on your system paths) output when you install createrepo:
==> Caveats
Please make sure python can find libxml2 module.
There's couple of ways to achieve that, libxml2 module should give you
relevant hint when installing. One of the ways that might work for you:
echo /opt/boxen/homebrew/opt/libxml2/lib/python2.7/site-packages >> /opt/boxen/homebrew/lib/python2.7/site-packages/libxml2.pth
I saw that information when I did my install, but seeing as the line that failed while trying to run createrepo was
File "/usr/local/share/createrepo/genpkgmetadata.py", line 26, in
import rpm
ImportError: No module named rpm
I had assumed it could find libxml2, but couldn't find the rpm module. I scrolled up to see if there was a similar caveat given during the rpm module install, but didn't see one.
@stepanstipl I know this is closed (and old), but I'm new to homebrew on a Mac, and I'm kind of stuck here.
My ultimate goal is to get the rpm-python package installed on high sierra, and it looks like from @rjbrown99's comments above, I'll be able to "import rpm" if I follow the steps above.
I'm running into an issue though trying to 'brew install rpm4' after running 'brew tap stepanstipl/noop'. Seeing the following error:
~/Downloads - $ brew install rpm4
==> Installing rpm4 from stepanstipl/noop
==> Downloading http://github.com/rpm-software-management/rpm/releases/download/rpm-4.13.0-release/rpm-4.13.0.tar.bz2
==> Downloading from https://github.com/rpm-software-management/rpm/releases/download/rpm-4.13.0-release/rpm-4.13.0.tar.bz2
curl: (22) The requested URL returned error: 404 Not Found
Error: Failed to download resource "rpm4"
Download failed: http://github.com/rpm-software-management/rpm/releases/download/rpm-4.13.0-release/rpm-4.13.0.tar.bz2
At which point, I attempted to 'brew edit rpm4' to point to the following rpm4 file: https://github.com/rpm-software-management/rpm/archive/rpm-4.14.0-release.tar.gz. After this change, I'm seeing different errors:
~/Downloads - $ brew install rpm4
==> Installing rpm4 from stepanstipl/noop
==> Downloading https://github.com/rpm-software-management/rpm/archive/rpm-4.14.0-release.tar.gz
Already downloaded: /Users/dranck/Library/Caches/Homebrew/rpm4-4.14.0.tar.gz
Error: uninitialized constant Formulary::FormulaNamespace171d56fc778e84099490aee30093565c::Rpm4::DATA
Did you mean? Data
Date
Going down a rabbit hole here trying to debug, so I figured I'd reach out and ask for some help. :) Any advice?
Hi @dmranck, thanks for reporting this. I don't really maintain this, as I've moved my workflows to docker (you can start with my image stepanstipl/centos7-rpm-devtools
which has all the rpm tools installed), but I have updated the repo to 4.14.1 version.
So run brew update
and try brew install rpm4
. You might need to reset local changes, if you did any modifications using brew edit
. You can do that by
cd /usr/local/Homebrew/Library/Taps/stepanstipl/homebrew-noop/
git reset --hard HEAD
The rabbit hole goes deeper than I thought, you can see there were more changes required:
The file to use is the one from rpm.org (GitHub one is not really a release, so the content is different).
url 'http://ftp.rpm.org/releases/rpm-4.14.x/rpm-4.14.1.tar.bz2'
sha256 '43f40e2ccc3ca65bd3238f8c9f8399d4957be0878c2e83cba2746d2d0d96793b' .
Then I started getting the error that you mention, which could be fixed by changing
DATA
to :DATA
.
At this point, the build will start failing when applying all the patches. After going through each of those, it looked like all (maybe but one) could be removed, as they have been merged to the main code, so there I went and removed the
def patches
DATA
end
and the section with the actual patched at the end of the file.
There was one more issue, this time Homebrew itself, to fix it I had to change the CPPFLAGS include lines to:
ENV.append 'CPPFLAGS', "-I#{Formula['nss'].include}"
ENV.append 'CPPFLAGS', "-I#{Formula['nspr'].include}"
The result is that the rpm4
formula will build and install rpm
command. I haven't really tested this any further, but rpm
seems to work:
$rpm -qlp zlib-1.2.7-17.el7.x86_64.rpm
warning: zlib-1.2.7-17.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
/usr/lib64/libz.so.1
/usr/lib64/libz.so.1.2.7
/usr/share/doc/zlib-1.2.7
/usr/share/doc/zlib-1.2.7/ChangeLog
/usr/share/doc/zlib-1.2.7/FAQ
/usr/share/doc/zlib-1.2.7/README
createrepo
;), and ran into:
Error: undefined method `undent' for #<String:0x00000001011f0b88> .
whcih was fixed by removing .undef
call in the formula.
I've also updated the libxml2 message.
Hope it helps :).
Hey @stepanstipl, thanks for getting back to me on this. The steps above worked and I now have rpm installed on my system. :)
One more question, and I'm hoping it's an easy one... I can successfully "import rpm" in python from /usr/local/bin/python, which appears to be using rpm from /usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages as can be seen from the following command when run from a /usr/local/bin/python shell:
>>> print(site.getsitepackages())
['/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages', '/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/site-python']
I have some other conda environments that I'd like to use the rpm module in - specifically a Python 3.5 environment. How would you recommend getting this installed in other python envs? I tried copying the rpm folder from one site_packages dir to another, and am getting some python errors, so I'm assuming that's not the best route to take.
I also followed the steps in your README in the section "If you're using system Python, make sure Homebrew's site-packages are added to your Python sys.path", but pointed to my conda env's path instead, but this didn't appear to work.
Any help would be appreciated! Thanks again.
Hi @dmranck, I'm pretty sure you can't just import python2 modules in python3. I think you would have to rebuild the Formula with Python3, I quickly tried but I'm afraid it would require a bit more effort than just changing python@2
to python
.
Probably best to check out one of the existing python formulas as a starting point, but I'm not very sure. Basically, you would need to make sure that Python 3 gets called in all the python
and python-config
calls, but also that the make process sees correct python (3).
@stepanstipl, thanks for the tips. I have rpm installed in one python env on my system at least, so thanks for all the help!
Trying this on Yosemite.
brew tap stepanstipl/noop brew install createrepo
All works fine. Trying to run createrepo gives me this -
Traceback (most recent call last): File "/usr/local/share/createrepo/genpkgmetadata.py", line 26, in
import rpm
ImportError: No module named rpm
Have not spent time to troubleshoot it yet, just thought I'd start by posting here in the event this is a known issue with a quick fix.