Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Fix version detection error on pip installations
Browse files Browse the repository at this point in the history
Fix the following error when invoking `doozer --version` on an
installation without the source git repository:

```
LookupError: setuptools-scm was unable to detect version for /usr/local/lib/python3.11/site-packages.
```

Steps to reproduce:

```sh
pip install .

doozer --version
```

This can be solved by introducting setuptools_scm to write a file
containing the to-be-installed version.
  • Loading branch information
vfreex committed Mar 8, 2023
1 parent cc478d1 commit abcb312
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -28,3 +28,6 @@ cover
# Ignore ocp-build-dat
ocp-build-data/
tests_functional.log

# Ignore _version.py created by setuptools_scm
_version.py
16 changes: 7 additions & 9 deletions doozerlib/__init__.py
Expand Up @@ -3,15 +3,13 @@
if sys.version_info < (3, 8):
sys.exit('Sorry, Python < 3.8 is not supported.')

from setuptools_scm import get_version

from .runtime import Runtime
from .pushd import Dir
from doozerlib.runtime import Runtime


def version():
return get_version(
root=os.path.abspath(
os.path.join(os.path.dirname(__file__), '..')
)
)
try:
from ._version import version
except ImportError:
from setuptools_scm import get_version
version = get_version()
return version
4 changes: 2 additions & 2 deletions doozerlib/cli/__main__.py
Expand Up @@ -16,8 +16,8 @@
import pathlib

from future import standard_library
from doozerlib import Runtime, Dir, cli as cli_package
from doozerlib import state
from doozerlib import Runtime, state, cli as cli_package
from doozerlib.pushd import Dir
from doozerlib.model import Missing
from doozerlib.brew import get_watch_task_info_copy
from doozerlib import metadata
Expand Down
4 changes: 3 additions & 1 deletion setup.py
Expand Up @@ -12,7 +12,9 @@
name="rh-doozer",
author="AOS ART Team",
author_email="aos-team-art@redhat.com",
use_scm_version=True,
use_scm_version={
'write_to': 'doozerlib/_version.py',
},
setup_requires=['setuptools_scm'],
description="CLI tool for managing and automating Red Hat software releases",
long_description=open('README.md').read(),
Expand Down

0 comments on commit abcb312

Please sign in to comment.