From 8543b11cc8f9575c28dc748931e590219accf6f9 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Fri, 11 Nov 2022 03:25:31 -0800 Subject: [PATCH 1/2] make.bat: use default 'python' exe; get rid of hard-coded python path --- make.bat | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/make.bat b/make.bat index b424ed203..2c79d4291 100644 --- a/make.bat +++ b/make.bat @@ -3,28 +3,26 @@ rem ========================================================================== rem Shortcuts for various tasks, emulating UNIX "make" on Windows. rem It is primarily intended as a shortcut for compiling / installing -rem psutil ("make.bat build", "make.bat install") and running tests -rem ("make.bat test"). +rem psutil and running tests. E.g.: +rem +rem make build +rem make install +rem make test rem rem This script is modeled after my Windows installation which uses: rem - Visual studio 2008 for Python 2.7 rem - Visual studio 2010 for Python 3.4+ rem ...therefore it might not work on your Windows installation. rem -rem By default C:\Python27\python.exe is used. rem To compile for a specific Python version run: rem set PYTHON=C:\Python34\python.exe & make.bat build rem rem To use a different test script: -rem set PYTHON=C:\Python34\python.exe & set TSCRIPT=foo.py & make.bat test +rem set TSCRIPT=foo.py & make.bat test rem ========================================================================== if "%PYTHON%" == "" ( - if exist "C:\Python38-64\python.exe" ( - set PYTHON=C:\Python38-64\python.exe - ) else ( - set PYTHON=C:\Python27\python.exe - ) + set PYTHON=python ) if "%TSCRIPT%" == "" ( From c0aadb18038f2ce29dbdd9cc11be072b15fd34eb Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Fri, 11 Nov 2022 07:29:43 -0800 Subject: [PATCH 2/2] fix long_description on Windows (see: #2168) --- .github/workflows/build.yml | 6 +++--- Makefile | 6 +++--- scripts/internal/convert_readme.py | 6 +----- setup.py | 12 +++++------- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 502ecb5a2..1d9999f8b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,7 +22,7 @@ name: build jobs: # Linux + macOS + Windows Python 3 py3: - name: ${{ matrix.os }}-py3 + name: py3-${{ matrix.os }} runs-on: ${{ matrix.os }} timeout-minutes: 20 strategy: @@ -62,7 +62,7 @@ jobs: # psutil tests do not like running from a virtualenv with python>=3.7 so # not using cibuildwheel for those. run them "manually" with this job. windows-py3-test: - name: windows-py3-test-${{ matrix.python }}-${{ matrix.architecture }} + name: py3-windows-test-${{ matrix.python }}-${{ matrix.architecture }} needs: py3 runs-on: windows-2019 timeout-minutes: 20 @@ -105,7 +105,7 @@ jobs: # Linux + macOS + Python 2 linux-macos-py2: - name: ${{ matrix.os }}-py2 + name: py2-${{ matrix.os }} runs-on: ${{ matrix.os }} timeout-minutes: 20 strategy: diff --git a/Makefile b/Makefile index a5ee28e29..930325dd1 100644 --- a/Makefile +++ b/Makefile @@ -254,7 +254,7 @@ git-tag-release: ## Git-tag a new release. sdist: ## Create tar.gz source distribution. ${MAKE} generate-manifest $(PYTHON) setup.py sdist - $(PYTHON) -m twine check dist/*.tar.gz + $(PYTHON) -m twine check --strict dist/*.tar.gz # --- others @@ -276,7 +276,7 @@ pre-release: ## Check if we're ready to produce a new release. ${MAKE} download-wheels-appveyor ${MAKE} print-hashes ${MAKE} print-wheels - $(PYTHON) -m twine check dist/* + $(PYTHON) -m twine check --strict dist/* $(PYTHON) -c \ "from psutil import __version__ as ver; \ doc = open('docs/index.rst').read(); \ @@ -286,7 +286,7 @@ pre-release: ## Check if we're ready to produce a new release. assert 'XXXX' not in history, 'XXXX in HISTORY.rst';" release: ## Create a release (down/uploads tar.gz, wheels, git tag release). - $(PYTHON) -m twine check dist/* + $(PYTHON) -m twine check --strict dist/* $(PYTHON) -m twine upload dist/* # upload tar.gz and Windows wheels on PyPI ${MAKE} git-tag-release diff --git a/scripts/internal/convert_readme.py b/scripts/internal/convert_readme.py index bd00cf234..d96c6c5d3 100755 --- a/scripts/internal/convert_readme.py +++ b/scripts/internal/convert_readme.py @@ -48,11 +48,7 @@ def main(): data = f.read() data = re.sub(r".. raw:: html\n+\s+
", summary, data) data = re.sub(r"Sponsors\n========[\s\S]*?Example usages", funding, data) - if len(sys.argv) > 2: - with open(sys.argv[2], "wb") as f: - f.write(data.encode("utf8")) - else: - print(data) + print(data) if __name__ == '__main__': diff --git a/setup.py b/setup.py index 31777b9d2..29039aad7 100755 --- a/setup.py +++ b/setup.py @@ -118,18 +118,16 @@ def get_version(): py_limited_api = {} -def get_description(): +def get_long_description(): script = os.path.join(HERE, "scripts", "internal", "convert_readme.py") readme = os.path.join(HERE, 'README.rst') p = subprocess.Popen([sys.executable, script, readme], - stdout=subprocess.PIPE, stderr=subprocess.PIPE) + stdout=subprocess.PIPE, stderr=subprocess.PIPE, + universal_newlines=True) stdout, stderr = p.communicate() if p.returncode != 0: raise RuntimeError(stderr) - data = stdout.decode('utf8') - if WINDOWS: - data = data.replace('\r\n', '\n') - return data + return stdout @contextlib.contextmanager @@ -388,7 +386,7 @@ def main(): version=VERSION, cmdclass=cmdclass, description=__doc__ .replace('\n', ' ').strip() if __doc__ else '', - long_description=get_description(), + long_description=get_long_description(), long_description_content_type='text/x-rst', keywords=[ 'ps', 'top', 'kill', 'free', 'lsof', 'netstat', 'nice', 'tty',