-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix dependency resolving #8367
Fix dependency resolving #8367
Changes from all commits
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
Fixes the way synapse distinguishes between runtime and developer dependencies. | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,7 @@ | |
# limitations under the License. | ||
|
||
import logging | ||
from typing import List, Set | ||
from typing import Set | ||
|
||
from pkg_resources import ( | ||
DistributionNotFound, | ||
|
@@ -25,9 +25,6 @@ | |
get_provider, | ||
) | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
# REQUIREMENTS is a simple list of requirement specifiers[1], and must be | ||
# installed. It is passed to setup() as install_requires in setup.py. | ||
# | ||
|
@@ -116,6 +113,12 @@ | |
if name not in ["systemd", "lint"]: | ||
ALL_OPTIONAL_REQUIREMENTS = set(optional_deps) | ALL_OPTIONAL_REQUIREMENTS | ||
|
||
# We exclude lint and test as those are developer requirements | ||
ALL_RUNTIME_REQUIREMENT_COMPONENTS = set(CONDITIONAL_REQUIREMENTS.keys()) - { | ||
"lint", | ||
"test", | ||
} | ||
|
||
Comment on lines
+116
to
+121
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. @richvdh This change filters out all developer dependencies from all conditional dependencies, by only excluding I could change this to be only a set with |
||
|
||
def list_requirements(): | ||
return list(set(REQUIREMENTS) | ALL_OPTIONAL_REQUIREMENTS) | ||
|
@@ -139,12 +142,12 @@ def dependencies(self): | |
yield "'" + i + "'" | ||
|
||
|
||
def check_requirements(for_feature=None): | ||
def check_requirements(for_feature=None, dev=False): | ||
deps_needed = [] | ||
errors = [] | ||
|
||
if for_feature: | ||
reqs = CONDITIONAL_REQUIREMENTS[for_feature] | ||
reqs = CONDITIONAL_REQUIREMENTS.get(for_feature, []) | ||
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. Why this change? It seems unrelated? 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. if This is so that when |
||
else: | ||
reqs = REQUIREMENTS | ||
|
||
|
@@ -171,10 +174,16 @@ def check_requirements(for_feature=None): | |
else: | ||
errors.append("Needed %s but it was not installed" % (dependency,)) | ||
|
||
if not for_feature: | ||
# Check the optional dependencies are up to date. We allow them to not be | ||
if for_feature is None: | ||
# Check if the optional runtime dependencies are up to date. We allow them to not be | ||
# installed. | ||
OPTS = sum(CONDITIONAL_REQUIREMENTS.values(), []) # type: List[str] | ||
OPTS = set().union( | ||
*( | ||
set(reqs) | ||
for key, reqs in CONDITIONAL_REQUIREMENTS.items() | ||
if key in ALL_RUNTIME_REQUIREMENT_COMPONENTS or dev | ||
) | ||
) # type: Set[str] | ||
Comment on lines
+177
to
+186
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. @richvdh this is two compounded changes;
|
||
|
||
for dependency in OPTS: | ||
try: | ||
|
@@ -221,3 +230,5 @@ def _check_requirement(dependency_string): | |
import sys | ||
|
||
sys.stdout.writelines(req + "\n" for req in list_requirements()) | ||
|
||
check_requirements(dev=True) | ||
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. Does something run this module at some point? When is this 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. No, currently nothing runs the module at this point, but this way, |
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 use the same newsfragment as the PR that regressed this so that they'll show up together in the changelog.