dcantrell / pyparted

Python bindings for GNU parted (libparted)
GNU General Public License v2.0
86 stars 43 forks source link

pyparted in virtualenv #60

Closed sean-smith closed 5 years ago

sean-smith commented 5 years ago

I'm trying to get pyparted to install within a virtualenv. I've been able to use the following

yum install -y pyparted
python
> import parted

However when I attempt to install pyparted with pip in the virtualenv, I get:

STDOUT: Collecting pyparted (from -r /root/requirements.txt (line 1))
  Using cached https://files.pythonhosted.org/packages/3e/93/20a17af6a934b6375b2f3b15f8b8c7ea557a1f2fb093a2e201eb034b725c/pyparted-3.11.2.tar.gz
    Complete output from command python setup.py egg_info:
    Package libparted was not found in the pkg-config search path.
    Perhaps you should add the directory containing `libparted.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'libparted' found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-52lxHL/pyparted/setup.py", line 60, in <module>
        check_mod_version('libparted', need_libparted_version)
      File "/tmp/pip-install-52lxHL/pyparted/setup.py", line 54, in check_mod_version
        modversion = subprocess.check_output(["pkg-config", "--modversion", module]).decode('utf-8').split()[0]
      File "/usr/lib64/python2.7/subprocess.py", line 223, in check_output
        raise CalledProcessError(retcode, cmd, output=output)
    subprocess.CalledProcessError: Command '['pkg-config', '--modversion', 'libparted']' returned non-zero exit status 1

Any help is appreciated!

dcantrell commented 5 years ago

pyparted requires libparted and its headers in order to build. When you installed it via yum, you got the precompiled package and the necessary runtime dependencies. But when installing in virtualenv, it wants to build from source so you need the build requirements for pyparted.

sean-smith commented 5 years ago

thanks, is there any other way to get this working inside a virtualenv?

dcantrell commented 5 years ago

Did you try "yum install parted-devel" and then try the virtualenv thing again?

sean-smith commented 5 years ago

yes, error is:

ERROR: Complete output from command python setup.py egg_info:
    ERROR: *** Minimum required libparted version: 2.3, found: 2.1
    ----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-lpPon9/pyparted/

Looks like the yum package isn't up to date enough.

sean-smith commented 5 years ago

I've removed my dependency on pyparted so this isn't an issue any longer

dcantrell commented 5 years ago

If you're building pyparted from source, you'll need to meet the build requirements. I'm not sure what distribution you're on, but it obviously has an older libparted. You can upgrade that package in order to build pyparted from source. There's really no way around that when building things from source.

MatthiasLohr commented 5 years ago

But how to install pyparted not building from source?

dcantrell commented 5 years ago

If your distribution provides pyparted as an installable package, use their tool to install it. For example, on a Fedora or RHEL system you can do:

yum install pyparted

MatthiasLohr commented 5 years ago

Is there any chance to pack the binary parts directly into the pip package so you can install it with pip install?

chaim1221 commented 3 years ago

Yeah I'm not really sure what it is after here. I am working in an OL7 container, I installed parted-devel and it still complains it can't find libparted.pc. I am working through a build system and venv and am not sure how to find the file to set the PKG_CONFIG_PATH variable it seems to be looking for.