Skip to content

Commit d51b692

Browse files
committed
read version from init
1 parent e1473d6 commit d51b692

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

setup.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
1+
import codecs
2+
import os.path
13
from setuptools import setup, find_packages
2-
from maproulette import __version__
34

45
with open("README.md", "r") as readme:
56
long_description = readme.read()
67

8+
9+
def read(rel_path):
10+
here = os.path.abspath(os.path.dirname(__file__))
11+
with codecs.open(os.path.join(here, rel_path), 'r') as fp:
12+
return fp.read()
13+
14+
15+
def get_version(rel_path):
16+
for line in read(rel_path).splitlines():
17+
if line.startswith('__version__'):
18+
delim = '"' if '"' in line else "'"
19+
return line.split(delim)[1]
20+
else:
21+
raise RuntimeError("Unable to find version string.")
22+
23+
724
name = "maproulette"
8-
version = __version__
25+
version = get_version(f"{name}/__init__.py")
926
setup(name=name,
1027
version=version,
1128
description="A Python API wrapper for MapRoulette",

0 commit comments

Comments
 (0)