@@ -226,18 +226,33 @@ def run(self, options, args):
226
226
options .src_dir = os .path .abspath (options .src_dir )
227
227
install_options = options .install_options or []
228
228
if options .use_user_site :
229
+ explicit_opt = self .parser .provided_options
230
+ if "--user" not in explicit_opt :
231
+ # user option was implicit, so allow it to be disabled
232
+ # by explicit options
233
+ if options .prefix_path and "--prefix" in explicit_opt :
234
+ options .use_user_site = False
235
+ if options .target_dir and "--target" in explicit_opt :
236
+ options .use_user_site = False
237
+ if options .use_user_site :
238
+ if options .prefix_path :
239
+ raise CommandError (
240
+ "Can not combine '--user' and '--prefix' as they imply "
241
+ "different installation locations"
242
+ )
243
+ if options .target_dir :
244
+ raise CommandError (
245
+ "Can not combine '--user' and '--target' as they imply "
246
+ "different installation locations"
247
+ )
248
+ if virtualenv_no_global ():
249
+ raise InstallationError (
250
+ "Can not perform a '--user' install. User site-packages "
251
+ "are not visible in this virtualenv."
252
+ )
253
+ install_options .append ('--user' )
229
254
if options .prefix_path :
230
- raise CommandError (
231
- "Can not combine '--user' and '--prefix' as they imply "
232
- "different installation locations"
233
- )
234
- if virtualenv_no_global ():
235
- raise InstallationError (
236
- "Can not perform a '--user' install. User site-packages "
237
- "are not visible in this virtualenv."
238
- )
239
- install_options .append ('--user' )
240
- install_options .append ('--prefix=' )
255
+ install_options .append ('--prefix=' )
241
256
242
257
target_temp_dir = TempDirectory (kind = "target" )
243
258
if options .target_dir :
0 commit comments