PBR

pbr does not walk up the tree to find a .git

Bug #1777725 reported by termie
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
PBR
Invalid
Undecided
Unassigned

Bug Description

pbr seems to assume that the .git directory will be in the same directory as the base of the python package, however in the increasingly common case of a meta-repo containing generated code for multiple languages the python package may actually be a subdirectory, i.e.:

protobufproj/.git
protobufproj/go
protobufproj/java
protobufproj/python <-- building from here
protobufproj/python/setup.py
protobufproj/python/protobufproj

Ideally the solution would have the same semantics as `git rev-parse --show-toplevel`

The exception shown when this occurs is:
```Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's also possible that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo.```

termie (termie)
description: updated
Revision history for this message
termie (termie) wrote :

this actually may be something of a red-herring, digging into the code it looks like `git rev-parse --git-dir` _is_ being used https://git.openstack.org/cgit/openstack-dev/pbr/tree/pbr/git.py#n70

This error occurs probably when git is not installed, HOWEVER, by moving the .git directory into the protobufproj/python dir the problem is fixed because LocalEggInfo ( https://git.openstack.org/cgit/openstack-dev/pbr/tree/pbr/packaging.py#n510 ) has a specific callout for a .git which appears to short circuit some code that otherwise would call get_version.

I'm not exactly sure how that ends up happening, but that line in LocalEggInfo is the only place that seems to reference .git

summary: - pbr does not walk up the tree to find a .git directory
+ pbr does not walk up the tree to find a .git directory if git isn't
+ installed
summary: - pbr does not walk up the tree to find a .git directory if git isn't
- installed
+ pbr does not walk up the tree to find a .git
Revision history for this message
termie (termie) wrote :

Nope, not exactly that either, git is available on that system, here's some loggin:

{{{
Successfully installed flatbuffers-2015.12.22.1 pbr-4.0.4
+ /opt/python/cp35-cp35m/bin/pip wheel -w /io/wheelhouse /io
Processing /io
    Complete output from command python setup.py egg_info:
    ERROR:root:Error parsing
    Traceback (most recent call last):
      File "/opt/_internal/cpython-3.5.5/lib/python3.5/site-packages/pbr/core.py", line 96, in pbr
        attrs = util.cfg_to_args(path, dist.script_args)
      File "/opt/_internal/cpython-3.5.5/lib/python3.5/site-packages/pbr/util.py", line 258, in cfg_to_args
        pbr.hooks.setup_hook(config)
      File "/opt/_internal/cpython-3.5.5/lib/python3.5/site-packages/pbr/hooks/__init__.py", line 25, in setup_hook
        metadata_config.run()
      File "/opt/_internal/cpython-3.5.5/lib/python3.5/site-packages/pbr/hooks/base.py", line 27, in run
        self.hook()
      File "/opt/_internal/cpython-3.5.5/lib/python3.5/site-packages/pbr/hooks/metadata.py", line 26, in hook
        self.config['name'], self.config.get('version', None))
      File "/opt/_internal/cpython-3.5.5/lib/python3.5/site-packages/pbr/packaging.py", line 824, in get_version
        name=package_name))
    Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's also possible that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo. Project name XREDACTEDX was given, but was not able to be found.
}}}

Revision history for this message
termie (termie) wrote :

Aha! Figured it out, and is my fault. This build is happening inside docker and the parent directories of the package (that contain the git repo) are not mounted (we're doing a -v $PWD:/io and .git is at $PWD/../.git)

Changed in pbr:
status: New → Invalid
Revision history for this message
termie (termie) wrote :

The plot (re-)thickens! Git is there, and gives the correct answer for git rev-parse --git-dir now, but same error occurs (using distribute 0.7.3, pbr 4.0.4, pip 10.0.1, and setuptools 39.2.0)

Putting the .git directory in the package directory still fixes it, so... something is up

Successfully installed flatbuffers-2015.12.22.1 pbr-4.0.4
+ cd /io/python
+ git rev-parse --git-dir
/io/.git
+ /opt/python/cp35-cp35m/bin/pip wheel -w /io/python/wheelhouse .
Processing /io/python
    Complete output from command python setup.py egg_info:
    ERROR:root:Error parsing
    Traceback (most recent call last):
      File "/opt/_internal/cpython-3.5.5/lib/python3.5/site-packages/pbr/core.py", line 96, in pbr
        attrs = util.cfg_to_args(path, dist.script_args)
      File "/opt/_internal/cpython-3.5.5/lib/python3.5/site-packages/pbr/util.py", line 258, in cfg_to_args
        pbr.hooks.setup_hook(config)
      File "/opt/_internal/cpython-3.5.5/lib/python3.5/site-packages/pbr/hooks/__init__.py", line 25, in setup_hook
        metadata_config.run()
      File "/opt/_internal/cpython-3.5.5/lib/python3.5/site-packages/pbr/hooks/base.py", line 27, in run
        self.hook()
      File "/opt/_internal/cpython-3.5.5/lib/python3.5/site-packages/pbr/hooks/metadata.py", line 26, in hook
        self.config['name'], self.config.get('version', None))
      File "/opt/_internal/cpython-3.5.5/lib/python3.5/site-packages/pbr/packaging.py", line 824, in get_version
        name=package_name))
    Exception: Versioning for this project requires either an sdist tarball, or access to an upstream git repository. It's also possible that there is a mismatch between the package name in setup.cfg and the argument given to pbr.version.VersionInfo. Project name XREDACTEDX was given, but was not able to be found

Changed in pbr:
status: Invalid → New
Revision history for this message
termie (termie) wrote :

python setup.py egg_info works fine as well when run directly, so it now seems likely that wheel/pip is messing up my day by copying the directory and doing the build there:

+ /opt/python/cp35-cp35m/bin/pip wheel -w /io/python/wheelhouse .

Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-req-build-lzcdu9b5/

Changed in pbr:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.