Loading poetry/packages/dependency.py +21 −11 Changes for poetry/packages/dependency.py: 21 added lines, 11 removed lines. Original line number Diff line number Diff line Loading @@ -107,11 +107,11 @@ class Dependency: requirement = f'{self.pretty_name}' if isinstance(self.constraint, MultiConstraint): requirement += ','.join( requirement += ' ({})'.format(','.join( [str(c).replace(' ', '') for c in self.constraint.constraints] ) )) else: requirement += str(self.constraint).replace(' ', '') requirement += ' ({})'.format(str(self.constraint).replace(' ', '')) # Markers markers = [] Loading @@ -119,21 +119,31 @@ class Dependency: # Python marker if self.python_versions != '*': python_constraint = self.python_constraint marker = 'python_version' if isinstance(python_constraint, MultiConstraint): marker += ','.join( [str(c).replace(' ', '') for c in python_constraint.constraints] ) else: marker += str(python_constraint).replace(' ', '') markers.append(marker) markers.append(self._create_nested_marker('python_version', python_constraint)) if markers: requirement += f'; {" and ".join(markers)}' return requirement def _create_nested_marker(self, name, constraint): if isinstance(constraint, MultiConstraint): parts = [] for c in constraint.constraints: parts.append(self._create_nested_marker(name, c)) glue = ' and ' if constraint.is_disjunctive(): parts = [f'({part})' for part in parts] glue = ' or ' marker = glue.join(parts) else: marker = f'{name}{constraint.string_operator}"{constraint.version}"' return marker def activate(self): """ Set the dependency as mandatory. Loading poetry/semver/constraints/constraint.py +5 −0 Changes for poetry/semver/constraints/constraint.py: 5 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ class Constraint(BaseConstraint): ) self._operator = self._trans_op_str[operator] self._string_operator = operator self._version = version @property Loading @@ -52,6 +53,10 @@ class Constraint(BaseConstraint): def operator(self): return self._operator @property def string_operator(self): return self._string_operator @property def version(self) -> str: return self._version Loading tests/masonry/builders/test_sdist.py +7 −7 Changes for tests/masonry/builders/test_sdist.py: 7 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -39,9 +39,9 @@ def test_convert_dependencies(): get_dependency('C', '1.2.3'), ]) main = [ 'A>=1.0.0.0,<2.0.0.0', 'B>=1.0.0.0,<1.1.0.0', 'C==1.2.3.0', 'A (>=1.0.0.0,<2.0.0.0)', 'B (>=1.0.0.0,<1.1.0.0)', 'C (==1.2.3.0)', ] extras = [] Loading @@ -56,11 +56,11 @@ def test_convert_dependencies(): get_dependency('C', '1.2.3'), ]) main = [ 'B>=1.0.0.0,<1.1.0.0', 'C==1.2.3.0', 'B (>=1.0.0.0,<1.1.0.0)', 'C (==1.2.3.0)', ] extras = [ 'A>=1.0.0.0,<2.0.0.0; python_version>=3.4.0.0,<4.0.0.0', 'A (>=1.0.0.0,<2.0.0.0); python_version>="3.4.0.0" and python_version<"4.0.0.0"', ] assert result == (main, extras) Loading @@ -82,7 +82,7 @@ def test_make_setup(): 'my_package.sub_pkg2' ] assert ns['install_requires'] == [ 'cleo>=0.6.0.0,<0.7.0.0' 'cleo (>=0.6.0.0,<0.7.0.0)' ] assert ns['entry_points'] == { 'console_scripts': ['my-script = my_package:main'] Loading tests/packages/test_dependency.py +15 −0 Changes for tests/packages/test_dependency.py: 15 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -53,3 +53,18 @@ def test_accepts_fails_with_python_versions_mismatch(): package.python_versions = '~3.5' assert not dependency.accepts(package) def test_to_pep_508(): dependency = Dependency('Django', '^1.23') result = dependency.to_pep_508() assert result == 'Django (>=1.23.0.0,<2.0.0.0)' dependency = Dependency('Django', '^1.23') dependency.python_versions = '~2.7 || ^3.6' result = dependency.to_pep_508() assert result == 'Django (>=1.23.0.0,<2.0.0.0); ' \ '(python_version>="2.7.0.0" and python_version<"2.8.0.0") ' \ 'or (python_version>="3.6.0.0" and python_version<"4.0.0.0")' Loading
poetry/packages/dependency.py +21 −11 Changes for poetry/packages/dependency.py: 21 added lines, 11 removed lines. Original line number Diff line number Diff line Loading @@ -107,11 +107,11 @@ class Dependency: requirement = f'{self.pretty_name}' if isinstance(self.constraint, MultiConstraint): requirement += ','.join( requirement += ' ({})'.format(','.join( [str(c).replace(' ', '') for c in self.constraint.constraints] ) )) else: requirement += str(self.constraint).replace(' ', '') requirement += ' ({})'.format(str(self.constraint).replace(' ', '')) # Markers markers = [] Loading @@ -119,21 +119,31 @@ class Dependency: # Python marker if self.python_versions != '*': python_constraint = self.python_constraint marker = 'python_version' if isinstance(python_constraint, MultiConstraint): marker += ','.join( [str(c).replace(' ', '') for c in python_constraint.constraints] ) else: marker += str(python_constraint).replace(' ', '') markers.append(marker) markers.append(self._create_nested_marker('python_version', python_constraint)) if markers: requirement += f'; {" and ".join(markers)}' return requirement def _create_nested_marker(self, name, constraint): if isinstance(constraint, MultiConstraint): parts = [] for c in constraint.constraints: parts.append(self._create_nested_marker(name, c)) glue = ' and ' if constraint.is_disjunctive(): parts = [f'({part})' for part in parts] glue = ' or ' marker = glue.join(parts) else: marker = f'{name}{constraint.string_operator}"{constraint.version}"' return marker def activate(self): """ Set the dependency as mandatory. Loading
poetry/semver/constraints/constraint.py +5 −0 Changes for poetry/semver/constraints/constraint.py: 5 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ class Constraint(BaseConstraint): ) self._operator = self._trans_op_str[operator] self._string_operator = operator self._version = version @property Loading @@ -52,6 +53,10 @@ class Constraint(BaseConstraint): def operator(self): return self._operator @property def string_operator(self): return self._string_operator @property def version(self) -> str: return self._version Loading
tests/masonry/builders/test_sdist.py +7 −7 Changes for tests/masonry/builders/test_sdist.py: 7 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -39,9 +39,9 @@ def test_convert_dependencies(): get_dependency('C', '1.2.3'), ]) main = [ 'A>=1.0.0.0,<2.0.0.0', 'B>=1.0.0.0,<1.1.0.0', 'C==1.2.3.0', 'A (>=1.0.0.0,<2.0.0.0)', 'B (>=1.0.0.0,<1.1.0.0)', 'C (==1.2.3.0)', ] extras = [] Loading @@ -56,11 +56,11 @@ def test_convert_dependencies(): get_dependency('C', '1.2.3'), ]) main = [ 'B>=1.0.0.0,<1.1.0.0', 'C==1.2.3.0', 'B (>=1.0.0.0,<1.1.0.0)', 'C (==1.2.3.0)', ] extras = [ 'A>=1.0.0.0,<2.0.0.0; python_version>=3.4.0.0,<4.0.0.0', 'A (>=1.0.0.0,<2.0.0.0); python_version>="3.4.0.0" and python_version<"4.0.0.0"', ] assert result == (main, extras) Loading @@ -82,7 +82,7 @@ def test_make_setup(): 'my_package.sub_pkg2' ] assert ns['install_requires'] == [ 'cleo>=0.6.0.0,<0.7.0.0' 'cleo (>=0.6.0.0,<0.7.0.0)' ] assert ns['entry_points'] == { 'console_scripts': ['my-script = my_package:main'] Loading
tests/packages/test_dependency.py +15 −0 Changes for tests/packages/test_dependency.py: 15 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -53,3 +53,18 @@ def test_accepts_fails_with_python_versions_mismatch(): package.python_versions = '~3.5' assert not dependency.accepts(package) def test_to_pep_508(): dependency = Dependency('Django', '^1.23') result = dependency.to_pep_508() assert result == 'Django (>=1.23.0.0,<2.0.0.0)' dependency = Dependency('Django', '^1.23') dependency.python_versions = '~2.7 || ^3.6' result = dependency.to_pep_508() assert result == 'Django (>=1.23.0.0,<2.0.0.0); ' \ '(python_version>="2.7.0.0" and python_version<"2.8.0.0") ' \ 'or (python_version>="3.6.0.0" and python_version<"4.0.0.0")'