Skip to content

Commit 984ae98

Browse files
committed
Force removal of the old build dir in setup.py
Ideally this wouldn't be necessary, but it avoids the nasty scenario of breaking a user's Py3 installation if the user happens to run: python2 setup.py build python3 setup.py install We may be able to get around this by using the package_dir option in setuptools.setup()
1 parent 9d5c210 commit 984ae98

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

setup.py

100644100755
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@
8383
'discover_tests.py',
8484
'check_rst.sh',
8585
'TESTING.txt',
86-
]}
86+
],
87+
}
88+
8789
REQUIRES = []
8890
TEST_REQUIRES = []
8991
if sys.version_info[:2] == (2, 6):
@@ -113,6 +115,19 @@
113115
setup_kwds = {}
114116

115117

118+
# * Important *
119+
# We forcibly remove the build folder to avoid breaking the
120+
# user's Py3 installation if they run "python2 setup.py
121+
# build" and then "python3 setup.py install".
122+
123+
import distutils.dir_util
124+
print('removing old build dir')
125+
try:
126+
distutils.dir_util.remove_tree('build')
127+
except OSError:
128+
pass
129+
130+
116131
setup(name=NAME,
117132
version=VERSION,
118133
author=AUTHOR,

0 commit comments

Comments
 (0)