Automatically install setuptools-scm in script called from Makefile

This commit is contained in:
Shane McDonald
2022-07-22 12:22:39 -04:00
parent 1bcfc8f28e
commit 0d097964be
6 changed files with 31 additions and 9 deletions

View File

@@ -5,15 +5,16 @@
tasks:
- name: Get version from SCM if not explicitly provided
shell: |
python3 -m setuptools_scm | cut -d + -f -1
make print-VERSION | cut -d + -f -1
args:
chdir: '../../'
register: setup_py_version
register: scm_version
failed_when: not scm_version.stdout
when: awx_version is not defined
- name: Set awx_version
set_fact:
awx_version: "{{ setup_py_version.stdout }}"
awx_version: "{{ scm_version.stdout }}"
when: awx_version is not defined
- include_role:

View File

@@ -43,7 +43,7 @@ RUN dnf -y update && dnf install -y 'dnf-command(config-manager)' && \
xmlsec1-devel \
xmlsec1-openssl-devel
RUN pip3 install virtualenv setuptools_scm build
RUN pip3 install virtualenv build
# Install & build requirements

View File

@@ -1,4 +1,18 @@
from setuptools_scm import get_version
import os
import sys
import subprocess
import traceback
try:
from setuptools_scm import get_version
except ModuleNotFoundError:
sys.stderr.write("Unable to import setuptools-scm, attempting to install now...\n")
os.environ['PIP_DISABLE_PIP_VERSION_CHECK'] = '1'
subprocess.check_output([sys.executable, '-m', 'ensurepip'])
subprocess.check_output([sys.executable, '-m', 'pip', 'install', 'setuptools-scm'])
from setuptools_scm import get_version
version = get_version(root='../..', relative_to=__file__)
print(version)