File tree Expand file tree Collapse file tree 1 file changed +34
-5
lines changed
Expand file tree Collapse file tree 1 file changed +34
-5
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env python
22
3- from __future__ import absolute_import
3+ from __future__ import absolute_import , print_function
44
55import os
66import os .path
120120# user's Py3 installation if they run "python2 setup.py
121121# build" and then "python3 setup.py install".
122122
123- import distutils .dir_util
124- print ('removing old build dir' )
125123try :
126- distutils .dir_util .remove_tree ('build' )
124+ # If the user happens to run:
125+ # python2 setup.py build
126+ # python3 setup.py install
127+ # then folders like "configparser" will be in build/lib.
128+ # If so, we CANNOT let the user install this, because
129+ # this may break his/her Python 3 install, depending on the folder order in
130+ # sys.path. (Running "import configparser" etc. may pick up our Py2
131+ # substitute packages, instead of the intended system stdlib modules.)
132+ SYSTEM_MODULES = set ([
133+ '_dummy_thread' ,
134+ '_markupbase' ,
135+ '_thread' ,
136+ 'builtins' ,
137+ 'configparser' ,
138+ 'copyreg' ,
139+ 'html' ,
140+ 'http' ,
141+ 'queue' ,
142+ 'reprlib' ,
143+ 'socketserver' ,
144+ 'tkinter' ,
145+ 'winreg' ,
146+ 'xmlrpc'
147+ ])
148+
149+ if sys .version_info [0 ] >= 3 :
150+ # Do any of the above folders exist in build/lib?
151+ files = os .listdir (os .path .join ('build' , 'lib' ))
152+ if len (set (files ) & set (SYSTEM_MODULES )) > 0 :
153+ print ('ERROR: Your build folder is in an inconsistent state for '
154+ 'a Python 3.x install. Please remove it manually and run '
155+ 'setup.py again.' , file = sys .stderr )
156+ sys .exit (1 )
127157except OSError :
128158 pass
129159
130-
131160setup (name = NAME ,
132161 version = VERSION ,
133162 author = AUTHOR ,
You can’t perform that action at this time.
0 commit comments