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

Install Requirements Fails, bad pbr version #246

Closed
Ricky-N opened this issue Sep 2, 2018 · 3 comments
Closed

Install Requirements Fails, bad pbr version #246

Ricky-N opened this issue Sep 2, 2018 · 3 comments

Comments

@Ricky-N
Copy link
Contributor

Ricky-N commented Sep 2, 2018

Hello! I've been trying to get pygradle to work, but I'm having a rough time with a bad PBR version buried somewhere in the dependency chain. Here's the output I'm getting:

> Task :installTestRequirements FAILED
Error installing package using `[/mnt/c/Users/rniem/home/github.com/niemi-online/test/build/venv/bin/python, /mnt/c/Users/rniem/home/github.com/niemi-online/test/build/venv/bin/pip, install, --disable-pip-version-check, --no-deps, /home/ricky/.gradle/caches/modules-2/files-2.1/pypi/pbr/0.11.0/72801e9ffd52e7f438422a3e08b578e906cd270a/pbr-0.11.0.tar.gz]`
Processing /home/ricky/.gradle/caches/modules-2/files-2.1/pypi/pbr/0.11.0/72801e9ffd52e7f438422a3e08b578e906cd270a/pbr-0.11.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-gaxyldtn-build/setup.py", line 22, in <module>
        **util.cfg_to_args())
      File "/tmp/pip-gaxyldtn-build/pbr/util.py", line 261, in cfg_to_args
        wrap_commands(kwargs)
      File "/tmp/pip-gaxyldtn-build/pbr/util.py", line 482, in wrap_commands
        for cmd, _ in dist.get_command_list():
      File "/mnt/c/Users/rniem/home/github.com/niemi-online/test/build/venv/lib/python3.6/site-packages/setuptools/dist.py", line 496, in get_command_list
        cmdclass = ep.resolve()
      File "/mnt/c/Users/rniem/home/github.com/niemi-online/test/build/venv/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2297, in resolve
        module = __import__(self.module_name, fromlist=['__name__'], level=0)
      File "/tmp/pip-gaxyldtn-build/pbr/testr_command.py", line 47, in <module>
        from testrepository import commands
    ModuleNotFoundError: No module named 'testrepository'

Everything I can find online points to this version of pbr having a bug that leads to this. Here's a stack overflow post w/ relevant excerpt: There is a bug with pbr 0.11.0, ... use pbr version 0.11.1 instead.

I'm not actually familiar enough w/ the python toolchain to know how to go track this down though (I looked through setuptools and couldn't find the explicit dependency). Could anyone here help track down what change is actually required here?

Thanks!

@Auguronomics
Copy link

Hi, I got the same error, testrepository have to be installed before pbr

@zvezdan
Copy link
Member

zvezdan commented Oct 12, 2018

This is not pygradle issue, but we know from experience that pbr can cause issues for people. For example we pin it in our pipeline. This is actually a well known issue with setup_requires being processed directly by setuptools and not by pip (or even Gradle in our case) because they are not recorded in either Python or Ivy metadata. See these parts of pip documentation for details:

In pygradle we provide ways to customize both of these. The customization can be applied in build.gradle for a single project, or in a plugin that applies pygradle main python plugin and then adapts the settings for all your projects. That's what we do internally. For example, to use a pbr version that works for you, you can add this in your build.gradle:

dependencies {
    setupRequires 'pypi:pbr:1.8.0'
}

That will ensure that pbr is processed by Gradle and pip before the package that needs it is installed, so there will be no need for setuptools to go and fetch it during build.

To do the same in your plugin code for every project you could do:

pythonExtension.forceVersion('pypi', 'pbr', '1.8.0')
project.dependencies.add(CONFIGURATION_SETUP_REQS.getValue(), pythonExtension.forcedVersions['pbr'])

Notice that you can call forceVersion method inside python { ... } extension closure to force the dependencies that are transitively getting an unwanted version. However, remember that does not apply to setup_requires, so you'll have to add it to your dependencies anyway.

Similarly to configure how your setup_requires are handled by setuptools (other than pbr) you can define:

public static final String DISTUTILS_CFG = "..."  // your config
project.afterEvaluate {
    project.tasks.withType(InstallVirtualEnvironmentTask) { InstallVirtualEnvironmentTask task ->
        task.distutilsCfg = DISTUTILS_CFG
    }
}

or the equivalent setting in your build.gradle

@zvezdan zvezdan closed this as completed Oct 12, 2018
@jggomezt
Copy link

This does not work for me. Could ypu help me?

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

4 participants