Skip to content

Commit

Permalink
progress 5
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Dec 20, 2024
1 parent 1d78da4 commit 92d274f
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 5 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ jobs:
# python setup.py sdist
# mv dist/psutil*.tar.gz wheelhouse/

# Linux + macOS + Python 2
# Test setup.py compatibility with Python 2.7 syntax.
py2:
name: py2
name: py2.7 setup.py syntax check
runs-on: ubuntu-24.04
timeout-minutes: 20
strategy:
Expand All @@ -86,7 +86,7 @@ jobs:
- uses: LizardByte/setup-python-action@master
with:
python-version: '2.7'
- run: python setup.py
- run: python scripts/internal/test_python2_setup_py.py

# # Run linters
# linters:
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ include scripts/internal/print_downloads.py
include scripts/internal/print_hashes.py
include scripts/internal/print_timeline.py
include scripts/internal/purge_installation.py
include scripts/internal/test_python2_setup_py.py
include scripts/internal/winmake.py
include scripts/iotop.py
include scripts/killall.py
Expand Down
38 changes: 38 additions & 0 deletions scripts/internal/test_python2_setup_py.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env python2

# Copyright (c) 2009 Giampaolo Rodola'. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.


"""Invoke setup.py and make sure that on Python 2.7 it fails but prints
a meaningful error message.
"""

import os
import subprocess
import sys


ROOT_DIR = os.path.realpath(
os.path.join(os.path.dirname(__file__), "..", "..")
)


def main():
if sys.version_info[:2] != (2, 7):
raise RuntimeError("this script is supposed to be run with python 2.7")
setup_py = os.path.join(ROOT_DIR, "setup.py")
p = subprocess.Popen(
[sys.executable, setup_py],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
stdout, stderr = p.communicate()
assert p.wait() == 1
assert not stdout, stdout
assert "psutil no longer supports Python 2.7" in stderr, stderr


if __name__ == "__main__":
main()
7 changes: 5 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@

if sys.version_info[0] == 2: # noqa: UP036
sys.exit(textwrap.dedent("""\
As of version 7.0.0, psutil no longer supports Python 2.7.
As of version 7.0.0 psutil no longer supports Python 2.7.
Latest version supporting Python 2.7 is psutil 6.1.X.
Install it with: "pip2 install psutil>=6.1"."""))
Install it with:
pip2 install psutil==6.1.*\
"""))


with warnings.catch_warnings():
Expand Down

0 comments on commit 92d274f

Please sign in to comment.