Skip to content

Commit

Permalink
remove some instances of branching code supporting older python versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jayracine authored and abn committed Oct 30, 2021
1 parent 3bbec0c commit 8f8e190
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 35 deletions.
6 changes: 3 additions & 3 deletions docs/managing-environments.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ to activate one explicitly, see [Switching environments](#switching-between-envi
To easily switch between Python versions, it is recommended to
use [pyenv](https://github.com/pyenv/pyenv) or similar tools.

For instance, if your project is Python 2.7 only, a standard workflow
For instance, if your project is Python 3.6 only, a standard workflow
would be:

```bash
pyenv install 2.7.15
pyenv local 2.7.15 # Activate Python 2.7 for the current project
pyenv install 3.6.15
pyenv local 3.6.15 # Activate Python 3.6 for the current project
poetry install
```
{{% /note %}}
Expand Down
6 changes: 1 addition & 5 deletions poetry/repositories/installed_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,7 @@ def get_package_paths(cls, env: Env, name: str) -> Set[Path]:
if line and not line.startswith(("#", "import ", "import\t")):
path = Path(line)
if not path.is_absolute():
try:
path = lib.joinpath(path).resolve()
except FileNotFoundError:
# this is required to handle pathlib oddity on win32 python==3.5
path = lib.joinpath(path)
path = lib.joinpath(path).resolve()
paths.add(path)

src_path = env.path / "src" / name
Expand Down
2 changes: 0 additions & 2 deletions sonnet
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,6 @@ class MakeReleaseCommand(Command):
subprocess.check_output(
[python, "-V"], stderr=subprocess.STDOUT, shell=WINDOWS
)
if version == "3.4" and WINDOWS:
continue

subprocess.check_output([python, "-m", "pip", "install", "pip", "-U"])
except subprocess.CalledProcessError:
Expand Down
7 changes: 1 addition & 6 deletions tests/installation/test_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import itertools
import json
import sys

from pathlib import Path

Expand Down Expand Up @@ -1751,11 +1750,7 @@ def test_installer_test_solver_finds_compatible_package_for_dependency_python_no

expected = fixture("with-conditional-dependency")
assert locker.written_data == expected

if sys.version_info >= (3, 5, 0):
assert 1 == installer.executor.installations_count
else:
assert 0 == installer.executor.installations_count
assert 1 == installer.executor.installations_count


def test_installer_required_extras_should_not_be_removed_when_updating_single_dependency(
Expand Down
7 changes: 1 addition & 6 deletions tests/installation/test_installer_old.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from __future__ import unicode_literals

import itertools
import sys

from pathlib import Path

Expand Down Expand Up @@ -1447,11 +1446,7 @@ def test_installer_test_solver_finds_compatible_package_for_dependency_python_no
assert locker.written_data == expected

installs = installer.installer.installs

if sys.version_info >= (3, 5, 0):
assert len(installs) == 1
else:
assert len(installs) == 0
assert len(installs) == 1


def test_installer_required_extras_should_not_be_removed_when_updating_single_dependency(
Expand Down
7 changes: 2 additions & 5 deletions tests/utils/fixtures/setups/pyyaml/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,7 @@ def run(self):
build_cmd = self.get_finalized_command("build")
build_cmd.run()
sys.path.insert(0, build_cmd.build_lib)
if sys.version_info[0] < 3:
sys.path.insert(0, "tests/lib")
else:
sys.path.insert(0, "tests/lib3")
sys.path.insert(0, "tests/lib3")
import test_all

if not test_all.main([]):
Expand All @@ -337,7 +334,7 @@ def run(self):
url=URL,
download_url=DOWNLOAD_URL,
classifiers=CLASSIFIERS,
package_dir={"": {2: "lib", 3: "lib3"}[sys.version_info[0]]},
package_dir={"": "lib3"},
packages=["yaml"],
ext_modules=[
Extension(
Expand Down
2 changes: 0 additions & 2 deletions tests/utils/fixtures/setups/sqlalchemy/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
from setuptools.command.test import test as TestCommand

cmdclass = {}
if sys.version_info < (2, 7):
raise Exception("SQLAlchemy requires Python 2.7 or higher.")

cpython = platform.python_implementation() == "CPython"

Expand Down
7 changes: 1 addition & 6 deletions tests/utils/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -963,12 +963,7 @@ def test_env_system_packages(tmp_path, config):

EnvManager(config).build_venv(path=venv_path, flags={"system-site-packages": True})

if sys.version_info >= (3, 3):
assert "include-system-site-packages = true" in pyvenv_cfg.read_text()
elif (2, 6) < sys.version_info < (3, 0):
assert not venv_path.joinpath(
"lib", "python2.7", "no-global-site-packages.txt"
).exists()
assert "include-system-site-packages = true" in pyvenv_cfg.read_text()


def test_env_finds_the_correct_executables(tmp_dir, manager):
Expand Down

0 comments on commit 8f8e190

Please sign in to comment.