Skip to content

Commit

Permalink
Have setup.py read version in from __init__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
taleinat committed Jun 25, 2024
1 parent c6c9a28 commit ab154cd
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import re
import sys
from pathlib import Path

from setuptools import setup, Extension
from setuptools.command.build_ext import build_ext
Expand All @@ -24,6 +26,15 @@ def readfile(file_path):
history = readfile('HISTORY.rst').replace('.. :changelog:', '')


def get_version():
file_path = Path(__file__).parent / 'src' / 'fuzzysearch' / '__init__.py'
src = file_path.read_text()
pattern = r'^__version__\s*=\s*([\'"])(.{1,}?)\1\s*$'
return re.search(pattern, src, re.M).group(2)

version = get_version()


# Fail-safe compilation based on markupsafe's, which in turn was shamelessly
# stolen from the simplejson setup.py file. Original author: Bob Ippolito

Expand Down Expand Up @@ -108,7 +119,7 @@ def run_setup(with_binary=True):

setup(
name='fuzzysearch',
version='0.7.3',
version=version,
description='fuzzysearch is useful for finding approximate subsequence matches',
long_description=readme + '\n\n' + history,
author='Tal Einat',
Expand Down

0 comments on commit ab154cd

Please sign in to comment.