@@ -114,6 +114,16 @@ def _is_upgrade_allowed(self, req):
114
114
assert self .upgrade_strategy == "only-if-needed"
115
115
return req .is_direct
116
116
117
+ def _set_req_to_reinstall (self , req ):
118
+ """
119
+ Set a requirement to be installed.
120
+ """
121
+ # Don't uninstall the conflict if doing a user install and the
122
+ # conflict is not a user install.
123
+ if not self .use_user_site or dist_in_usersite (req .satisfied_by ):
124
+ req .conflicts_with = req .satisfied_by
125
+ req .satisfied_by = None
126
+
117
127
# XXX: Stop passing requirement_set for options
118
128
def _check_skip_installed (self , req_to_install ):
119
129
"""Check if req_to_install should be skipped.
@@ -133,55 +143,36 @@ def _check_skip_installed(self, req_to_install):
133
143
134
144
:return: A text reason for why it was skipped, or None.
135
145
"""
136
- # Check whether to upgrade/reinstall this req or not.
137
- req_to_install .check_if_exists ()
138
- if req_to_install .satisfied_by :
139
- upgrade_allowed = self ._is_upgrade_allowed (req_to_install )
140
-
141
- # Is the best version is installed.
142
- best_installed = False
143
-
144
- if upgrade_allowed :
145
- # For link based requirements we have to pull the
146
- # tree down and inspect to assess the version #, so
147
- # its handled way down.
148
- should_check_possibility_for_upgrade = not (
149
- self .force_reinstall or req_to_install .link
150
- )
151
- if should_check_possibility_for_upgrade :
152
- try :
153
- self .finder .find_requirement (
154
- req_to_install , upgrade_allowed )
155
- except BestVersionAlreadyInstalled :
156
- best_installed = True
157
- except DistributionNotFound :
158
- # No distribution found, so we squash the
159
- # error - it will be raised later when we
160
- # re-try later to do the install.
161
- # Why don't we just raise here?
162
- pass
163
-
164
- if not best_installed :
165
- # don't uninstall conflict if user install and
166
- # conflict is not user install
167
- if not (self .use_user_site and not
168
- dist_in_usersite (req_to_install .satisfied_by )):
169
- req_to_install .conflicts_with = \
170
- req_to_install .satisfied_by
171
- req_to_install .satisfied_by = None
172
-
173
- # Figure out a nice message to say why we're skipping this.
174
- if best_installed :
175
- skip_reason = 'already up-to-date'
176
- elif self .upgrade_strategy == "only-if-needed" :
177
- skip_reason = 'not upgraded as not directly required'
178
- else :
179
- skip_reason = 'already satisfied'
146
+ if self .ignore_installed :
147
+ return None
180
148
181
- return skip_reason
182
- else :
149
+ req_to_install . check_if_exists ()
150
+ if not req_to_install . satisfied_by :
183
151
return None
184
152
153
+ if not self ._is_upgrade_allowed (req_to_install ):
154
+ if self .upgrade_strategy == "only-if-needed" :
155
+ return 'not upgraded as not directly required'
156
+ return 'already satisfied'
157
+
158
+ # Check for the possibility of an upgrade. For link-based
159
+ # requirements we have to pull the tree down and inspect to assess
160
+ # the version #, so it's handled way down.
161
+ if not (self .force_reinstall or req_to_install .link ):
162
+ try :
163
+ self .finder .find_requirement (req_to_install , upgrade = True )
164
+ except BestVersionAlreadyInstalled :
165
+ # Then the best version is installed.
166
+ return 'already up-to-date'
167
+ except DistributionNotFound :
168
+ # No distribution found, so we squash the error. It will
169
+ # be raised later when we re-try later to do the install.
170
+ # Why don't we just raise here?
171
+ pass
172
+
173
+ self ._set_req_to_reinstall (req_to_install )
174
+ return None
175
+
185
176
def _resolve_one (self , requirement_set , req_to_install ):
186
177
"""Prepare a single requirements file.
187
178
0 commit comments