Skip to content
Snippets Groups Projects
Unverified Commit ad8690a2 authored by Richard van der Hoff's avatar Richard van der Hoff Committed by GitHub
Browse files

Fix the suggested pip incantation for cryptography (#9699)

If you have the wrong version of `cryptography` installed, synapse suggests:

```
To install run:
    pip install --upgrade --force 'cryptography>=3.4.7;python_version>='3.6''
```

However, the use of ' inside '...' doesn't work, so when you run this, you get
an error.
parent 0a778c13
No related branches found
No related tags found
No related merge requests found
Fix a bug introduced in Synapse 1.30.1 which meant the suggested `pip` incantation to install an updated `cryptography` was incorrect.
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import itertools
import logging import logging
from typing import List, Set from typing import List, Set
...@@ -101,7 +102,7 @@ CONDITIONAL_REQUIREMENTS = { ...@@ -101,7 +102,7 @@ CONDITIONAL_REQUIREMENTS = {
"txacme>=0.9.2", "txacme>=0.9.2",
# txacme depends on eliot. Eliot 1.8.0 is incompatible with # txacme depends on eliot. Eliot 1.8.0 is incompatible with
# python 3.5.2, as per https://github.com/itamarst/eliot/issues/418 # python 3.5.2, as per https://github.com/itamarst/eliot/issues/418
'eliot<1.8.0;python_version<"3.5.3"', "eliot<1.8.0;python_version<'3.5.3'",
], ],
"saml2": [ "saml2": [
# pysaml2 6.4.0 is incompatible with Python 3.5 (see https://github.com/IdentityPython/pysaml2/issues/749) # pysaml2 6.4.0 is incompatible with Python 3.5 (see https://github.com/IdentityPython/pysaml2/issues/749)
...@@ -131,6 +132,18 @@ for name, optional_deps in CONDITIONAL_REQUIREMENTS.items(): ...@@ -131,6 +132,18 @@ for name, optional_deps in CONDITIONAL_REQUIREMENTS.items():
ALL_OPTIONAL_REQUIREMENTS = set(optional_deps) | ALL_OPTIONAL_REQUIREMENTS ALL_OPTIONAL_REQUIREMENTS = set(optional_deps) | ALL_OPTIONAL_REQUIREMENTS
# ensure there are no double-quote characters in any of the deps (otherwise the
# 'pip install' incantation in DependencyException will break)
for dep in itertools.chain(
REQUIREMENTS,
*CONDITIONAL_REQUIREMENTS.values(),
):
if '"' in dep:
raise Exception(
"Dependency `%s` contains double-quote; use single-quotes instead" % (dep,)
)
def list_requirements(): def list_requirements():
return list(set(REQUIREMENTS) | ALL_OPTIONAL_REQUIREMENTS) return list(set(REQUIREMENTS) | ALL_OPTIONAL_REQUIREMENTS)
...@@ -150,7 +163,7 @@ class DependencyException(Exception): ...@@ -150,7 +163,7 @@ class DependencyException(Exception):
@property @property
def dependencies(self): def dependencies(self):
for i in self.args[0]: for i in self.args[0]:
yield "'" + i + "'" yield '"' + i + '"'
def check_requirements(for_feature=None): def check_requirements(for_feature=None):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment