From f476a8823438e251a20aa3809f8ca0dfe4ed6af8 Mon Sep 17 00:00:00 2001 From: Peter Grayson Date: Sun, 29 Aug 2021 08:14:21 -0400 Subject: [PATCH] Use setuptools instead of distutils for packaging PEP-632 deprecates the distutils package and establishes a timeline for its eventual removal from the Python standard library. This PEP also identifies setuptools as the appropriate alternative solution for distributing Python code. The presence of a pyproject.toml file, which already exists for stgit, identifies stgit as a PEP-518 enabled project. This means that stgit's build-time dependencies (setuptools and wheel) are enumerated in pyproject.toml. Some notes: - setup.py is no longer executable. The conventional way to run setup.py is by explicitly calling it with the python interpreter of choice. I.e. with `python setup.py ...`. - The python_requires metadata, which is supported by setuptools, allows stgit to specify its minimum required python version. This is an opportunity to obviate stgit's other minimum python version specification and checking. I.e. the minimum python version will now be enforced at package installation time instead of runtime. - The zip_safe=False option is used to indicate that stgit cannot be installed in zip form. This is needed because stgit has "data files" in the package (specifically, .tmpl files) that need to be accessible at runtime. - Removed umask manipulation which seems to have been voodoo remaining from ages past. Signed-off-by: Peter Grayson --- .gitignore | 1 + Makefile | 2 +- pyproject.toml | 4 ++++ setup.py | 11 ++++------- 4 files changed, 10 insertions(+), 8 deletions(-) mode change 100755 => 100644 setup.py diff --git a/.gitignore b/.gitignore index 6ac98a0..5ee14d3 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ htmlcov/ .coverage .cov-files/ .DS_Store +stgit.egg-info/ diff --git a/Makefile b/Makefile index 6729c31..98971e0 100644 --- a/Makefile +++ b/Makefile @@ -92,7 +92,7 @@ coverage-report: .coverage .PHONY: coverage coverage-test coverage-report dev-env: - $(PYTHON) -m pip install -U pip + $(PYTHON) -m pip install -U pip setuptools wheel $(PYTHON) -m pip install coverage[toml] black flake8 flake8-bugbear isort .PHONY: dev-env diff --git a/pyproject.toml b/pyproject.toml index 781e91a..a6ddc45 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,7 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" + [tool.black] line-length = 88 skip-string-normalization = true diff --git a/setup.py b/setup.py old mode 100755 new mode 100644 index a26f5b7..37640c5 --- a/setup.py +++ b/setup.py @@ -1,9 +1,10 @@ #!/usr/bin/env python3 import os import sys -from distutils.core import setup from glob import glob +from setuptools import setup + from stgit import commands, version from stgit.completion.bash import write_bash_completion from stgit.completion.fish import write_fish_completion @@ -58,9 +59,6 @@ def __check_git_version(): __check_python_version() __check_git_version() -# ensure readable template files -old_mask = os.umask(0o022) - for get_ver in [ version.git_describe_version, version.git_archival_version, @@ -110,6 +108,8 @@ setup( download_url='https://github.com/stacked-git/stgit.git', description='Stacked Git', long_description='Application for managing Git commits as a stack of patches.', + python_requires='>=3.5', + zip_safe=False, scripts=['stg'], packages=[ 'stgit', @@ -159,6 +159,3 @@ setup( 'Topic :: Software Development :: Version Control', ], ) - -# restore the old mask -os.umask(old_mask) -- 2.11.4.GIT