-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue 4371 incorrect dependencies when install dev packages #5234
Changes from 1 commit
6d1363c
192ad9e
79471df
30a6b1a
f09d653
7ab7b3d
23569fb
83813f9
1eb8d6d
11969be
0c098c8
c5cb0f0
d8ed209
beb8d3d
6b3f23b
b04442f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,10 +35,10 @@ | |
HackedPythonVersion, | ||
clean_pkg_version, | ||
convert_deps_to_pip, | ||
get_constraints_from_deps, | ||
get_vcs_deps, | ||
is_pinned_requirement, | ||
pep423_name, | ||
prepare_default_constraint_file, | ||
translate_markers, | ||
) | ||
from .indexes import parse_indexes, prepare_pip_source_args | ||
|
@@ -140,12 +140,15 @@ def __init__( | |
self.requires_python_markers = {} | ||
self._pip_args = None | ||
self._constraints = None | ||
self._default_constraints = None | ||
self._parsed_constraints = None | ||
self._parsed_default_constraints = None | ||
self._resolver = None | ||
self._finder = None | ||
self._ignore_compatibility_finder = None | ||
self._session = None | ||
self._constraint_file = None | ||
self._default_constraint_file = None | ||
self._pip_options = None | ||
self._pip_command = None | ||
self._retry_attempts = 0 | ||
|
@@ -560,26 +563,13 @@ def constraint_file(self): | |
self._constraint_file = self.prepare_constraint_file() | ||
return self._constraint_file | ||
|
||
def prepare_default_constraint_file(self): | ||
|
||
from pipenv.vendor.vistir.path import create_tracked_tempfile | ||
|
||
default_constraints_file = create_tracked_tempfile( | ||
mode="w", | ||
prefix="pipenv-", | ||
suffix="-default-constraints.txt", | ||
dir=self.req_dir, | ||
delete=False, | ||
) | ||
default_constraints = get_constraints_from_deps(self.project.packages) | ||
default_constraints_file.write("\n".join([c for c in default_constraints])) | ||
default_constraints_file.close() | ||
return default_constraints_file.name | ||
|
||
@property | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we make this a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I used There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Those tests also failed without There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the problem is you need to import There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The only tests that are expected could fail, and likely on mac OS right now is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ran with the main branch, but there are more failed tests on macOS other than There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dqkqd It is possible that the new version of setuptools that was released yesterday has affected things. I will re-run the main branch actions, but you can see the last time it ran upon merge ony those There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @matteius I updated as you said. Not sure why it passed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dqkqd It is a "flakey" test case, maybe I'll mark it as such and it won't fail the build as often. I haven't gotten to the bottom of why sometimes it behaves differently, it has failed on Mac OS most frequently, but I have seen it once in a while fail on other systems. |
||
@lru_cache() | ||
def default_constraint_file(self): | ||
return self.prepare_default_constraint_file() | ||
if self._default_constraint_file is None: | ||
self._default_constraint_file = prepare_default_constraint_file( | ||
self.project, dir=self.req_dir | ||
) | ||
return self._default_constraint_file | ||
|
||
@property | ||
def pip_options(self): | ||
|
@@ -660,38 +650,34 @@ def parsed_constraints(self): | |
return self._parsed_constraints | ||
|
||
@property | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Recommend also making this a @cached_property |
||
@lru_cache() | ||
def parsed_default_constraints(self): | ||
pip_options = self.pip_options | ||
pip_options.extra_index_urls = [] | ||
parsed_default_constraints = parse_requirements( | ||
self.default_constraint_file, | ||
constraint=True, | ||
finder=self.finder, | ||
session=self.session, | ||
options=pip_options, | ||
) | ||
return parsed_default_constraints | ||
if self._parsed_default_constraints is None: | ||
self._parsed_default_constraints = parse_requirements( | ||
self.default_constraint_file, | ||
constraint=True, | ||
finder=self.finder, | ||
session=self.session, | ||
options=pip_options, | ||
) | ||
return self._parsed_default_constraints | ||
|
||
@property | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And this one also I think would be better as a cached_property. |
||
@lru_cache() | ||
def default_constraints(self): | ||
default_constraints = [ | ||
install_req_from_parsed_requirement( | ||
c, | ||
isolated=self.pip_options.build_isolation, | ||
user_supplied=False, | ||
) | ||
for c in self.parsed_default_constraints | ||
] | ||
return default_constraints | ||
if self._default_constraints is None: | ||
self._default_constraints = [ | ||
install_req_from_parsed_requirement( | ||
c, | ||
isolated=self.pip_options.build_isolation, | ||
user_supplied=False, | ||
) | ||
for c in self.parsed_default_constraints | ||
] | ||
return self._default_constraints | ||
|
||
@property | ||
def constraints(self): | ||
from pipenv.patched.pip._internal.req.constructors import ( | ||
install_req_from_parsed_requirement, | ||
) | ||
|
||
if self._constraints is None: | ||
self._constraints = [ | ||
install_req_from_parsed_requirement( | ||
|
@@ -702,6 +688,7 @@ def constraints(self): | |
) | ||
for c in self.parsed_constraints | ||
] | ||
# Only use default_constraints when installing dev-packages | ||
if self.dev: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you explain more why we only include the default_constraints when dev is specified? I don't think I quite understand out of the gate. I got to looking at this more because this is the only place that uses self.dev, and I am noticing how many parameters There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think constraint is used only when installing dev-packages. If it does with new normal packages, the installing package could not overwrite existing packages, because it use them as contraint, and therefore might not be installed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah ok thanks, that makes sense. |
||
self._constraints += self.default_constraints | ||
return self._constraints | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should avoid shadowing built in python function name
dir
-- I recommend naming itdirectory
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed it.