Skip to content

Commit 141a146

Browse files
committed
refactor setup.py for good form
1 parent b782862 commit 141a146

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

setup.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,30 @@
1+
"""
2+
Configuration for setuptools.
3+
"""
14
import codecs
25
import os.path
36

47
from setuptools import find_packages, setup
58

6-
here = os.path.abspath(os.path.dirname(__file__))
9+
script_dir = os.path.abspath(os.path.dirname(__file__))
710

8-
with open(os.path.join(here, "README.md"), encoding="utf-8") as fh:
11+
with open(os.path.join(script_dir, "README.md"), encoding="utf-8") as fh:
912
long_description = fh.read()
1013

1114

12-
def read(rel_path):
13-
with codecs.open(os.path.join(here, rel_path), "r") as fp:
15+
def read(relative_path):
16+
"""
17+
Read a file and return its contents.
18+
"""
19+
with codecs.open(os.path.join(script_dir, relative_path), "r") as fp:
1420
return fp.read()
1521

1622

17-
def get_version(rel_path):
18-
for line in read(rel_path).splitlines():
23+
def get_version(relative_path):
24+
"""
25+
Extract the version number from a file without importing it.
26+
"""
27+
for line in read(relative_path).splitlines():
1928
if not line.startswith("__version__"):
2029
raise RuntimeError("Unable to find version string.")
2130
delim = '"' if '"' in line else "'"

0 commit comments

Comments
 (0)