Skip to content

Commit 8a457eb

Browse files
committed
Find version from git tag
1 parent 4221fec commit 8a457eb

2 files changed

Lines changed: 28 additions & 6 deletions

File tree

conda/meta.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
{% set version = "1.5.0" %}
2-
{% set revision = "11961b2cc93534057df2bd668c2277267222916b" %}
1+
{% set version = environ.get('GIT_DESCRIBE_TAG', '1.5.0').lstrip('v') %}
2+
{% set revision = environ.get('GIT_FULL_HASH', '11961b2cc93534057df2bd668c2277267222916b') %}
33

44
package:
55
name: longreadsum
66
version: {{ version }}
77

88
source:
9-
git_url: https://github.com/WGLab/LongReadSum.git
10-
git_rev: {{ revision }}
11-
# path: ../
9+
path: ../
10+
git_lfs: false
11+
# git_url: https://github.com/WGLab/LongReadSum.git
12+
# git_rev: {{ revision }}
1213

1314
channels:
1415
- conda-forge

setup.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,32 @@
55

66
import os
77
import glob
8+
import subprocess
89
import setuptools
910
from setuptools import setup, Extension
1011

1112
print("Running setup.py...")
1213

14+
def get_git_version():
15+
"""Get version from git tag, fallback to default if not available."""
16+
try:
17+
# Get the latest git tag
18+
result = subprocess.run(['git', 'describe', '--tags', '--abbrev=0'],
19+
capture_output=True, text=True, check=True)
20+
version = result.stdout.strip()
21+
# Remove 'v' prefix if present
22+
if version.startswith('v'):
23+
version = version[1:]
24+
return version
25+
except (subprocess.CalledProcessError, FileNotFoundError):
26+
# Fallback to default version if git is not available or no tags exist
27+
print("Warning: Could not get version from git tag, using default version")
28+
return '1.5.0'
29+
30+
# Set the version
31+
version = get_git_version()
32+
print(f"Setting version to: {version}")
33+
1334
# Get the project dependencies
1435
src_files = []
1536
project_dir = 'src/'
@@ -29,7 +50,7 @@
2950

3051
# Set up the module
3152
setup(name="longreadsum",
32-
version='1.5.0',
53+
version=version,
3354
author="WGLab",
3455
description="""A fast and flexible QC tool for long read sequencing data""",
3556
ext_modules=[lrst_mod],

0 commit comments

Comments
 (0)