Skip to content

Improve Python version and OS compatibility, fixing deprecations #1654

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

Merged
merged 17 commits into from
Sep 12, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix installation test for Python 3.12 and Windows
Starting in Python 3.12, global and virtual Python environments no
longer automatically ship setuptools (per the "ensurepip" item in
https://docs.python.org/3.12/whatsnew/3.12.html#removed). Projects
that use setuptools as a build backend are still supported,
including with setup.py using techniques such as "pip install .".

In Windows, the "bin" subdir of a virtual environment dir is called
"Scripts" instead. Unlike in a global environment (where no names
are universal, and "python3" and "pip3" are more common for the
Python 3 commands on some popular Unix-like systems), in a virtual
environment the "python" and "pip" commands are always present and
"python3" and "pip3" are not guaranteed to be present.

This commit changes test_installation accordingly. The CI workflows
and documentation still need to be updated.
  • Loading branch information
EliahKagan committed Sep 9, 2023
commit dba42451187243ffe6d56a08e032dbcbb9ac615f
10 changes: 6 additions & 4 deletions test/test_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import ast
import os
import subprocess
from git.compat import is_win
from test.lib import TestBase
from test.lib.helper import with_rw_directory

Expand All @@ -12,8 +13,9 @@ class TestInstallation(TestBase):
def setUp_venv(self, rw_dir):
self.venv = rw_dir
subprocess.run(["virtualenv", self.venv], stdout=subprocess.PIPE)
self.python = os.path.join(self.venv, "bin/python3")
self.pip = os.path.join(self.venv, "bin/pip3")
bin_name = "Scripts" if is_win else "bin"
self.python = os.path.join(self.venv, bin_name, "python")
self.pip = os.path.join(self.venv, bin_name, "pip")
self.sources = os.path.join(self.venv, "src")
self.cwd = os.path.dirname(os.path.dirname(__file__))
os.symlink(self.cwd, self.sources, target_is_directory=True)
Expand All @@ -32,14 +34,14 @@ def test_installation(self, rw_dir):
msg=result.stderr or result.stdout or "Can't install requirements",
)
result = subprocess.run(
[self.python, "setup.py", "install"],
[self.pip, "install", "."],
stdout=subprocess.PIPE,
cwd=self.sources,
)
self.assertEqual(
0,
result.returncode,
msg=result.stderr or result.stdout or "Can't build - setup.py failed",
msg=result.stderr or result.stdout or "Can't install project",
)
result = subprocess.run([self.python, "-c", "import git"], stdout=subprocess.PIPE, cwd=self.sources)
self.assertEqual(
Expand Down