Skip to content

Commit 5d9c61d

Browse files
committed
[FIX] setup.py: remove future and configparse deps
When installing with pip install -e ., these needed to be already installed.
1 parent 287e7e5 commit 5d9c61d

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

setup.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,12 @@
1313
"""
1414
# Build helper
1515
from __future__ import print_function
16-
from builtins import str, bytes, open
17-
1816
import os
1917
from os.path import join as pjoin
2018
import sys
21-
from configparser import ConfigParser
22-
2319
from glob import glob
2420
from functools import partial
21+
from io import open
2522

2623
# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly
2724
# update it when the contents of directories change.
@@ -46,6 +43,11 @@
4643

4744
PY3 = sys.version_info[0] >= 3
4845

46+
if PY3:
47+
string_types = (str, bytes)
48+
else:
49+
string_types = (basestring, str, unicode)
50+
4951
def get_comrec_build(pkg_dir, build_cmd=build_py):
5052
""" Return extended build command class for recording commit
5153
@@ -84,15 +86,21 @@ def get_comrec_build(pkg_dir, build_cmd=build_py):
8486
class MyBuildPy(build_cmd):
8587
''' Subclass to write commit data into installation tree '''
8688
def run(self):
87-
build_cmd.run(self)
8889
import subprocess
90+
try:
91+
from configparser import ConfigParser
92+
except ImportError:
93+
from ConfigParser import ConfigParser
94+
95+
build_cmd.run(self)
96+
8997
proc = subprocess.Popen('git rev-parse --short HEAD',
9098
stdout=subprocess.PIPE,
9199
stderr=subprocess.PIPE,
92100
shell=True)
93101
repo_commit, _ = proc.communicate()
94102
# Fix for python 3
95-
repo_commit = str(repo_commit)
103+
repo_commit = '{}'.format(repo_commit)
96104
# We write the installation commit even if it's empty
97105
cfg_parser = ConfigParser()
98106
cfg_parser.read(pjoin(pkg_dir, 'COMMIT_INFO.txt'))
@@ -112,7 +120,7 @@ def _add_append_key(in_dict, key, value):
112120
# Append value to in_dict[key] list
113121
if key not in in_dict:
114122
in_dict[key] = []
115-
elif isinstance(in_dict[key], (str, bytes)):
123+
elif isinstance(in_dict[key], string_types):
116124
in_dict[key] = [in_dict[key]]
117125
in_dict[key].append(value)
118126

@@ -209,7 +217,7 @@ def version_getter(pkg_name):
209217
msgs['opt suffix'])
210218
return
211219
# setuptools mode
212-
if optional_tf and not isinstance(optional, (str, bytes)):
220+
if optional_tf and not isinstance(optional, string_types):
213221
raise RuntimeError('Not-False optional arg should be string')
214222
dependency = pkg_name
215223
if version:

setup_egg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# vi: set ft=python sts=4 ts=4 sw=4 et:
44
"""Wrapper to run setup.py using setuptools."""
55
from __future__ import print_function, division, unicode_literals, absolute_import
6-
from builtins import open
6+
from io import open
77
import os.path
88

99
################################################################################

0 commit comments

Comments
 (0)