From 5df591b2789cf15c9d8f6a9e250e404e567739a0 Mon Sep 17 00:00:00 2001 From: Peter Grayson Date: Fri, 10 Sep 2021 14:09:11 -0400 Subject: [PATCH] Do not use data_files in setup.py The data_files feature is deprecated by setuptools. The gist of rationale is that these data_files, which are files that exist outside the python package, have platform-specific destinations and this falls outside the scope of what setuptools wants to help with. For StGit, which is first and foremost an application and not a Python library, we cannot count on setuptools to provide/perform a complete installation of all the extras that come with StGit. We *can* rely on setuptools to install the `stgit` Python package and accompanying `stg` executable. In other words, setuptools is fine for packaging and installing the `stg` executable and its required runtime which includes the `stgit` package and the template files found in `stgit/templates`, but not for other bits and pieces that are not essential for `stg` to run correctly, such as completion scripts, vim config files, documentation, contrib scripts, etc. A complete distribution of StGit must thus be accomplished via operating system specific packaging. E.g. debian packages, rpms, brew, etc. These systems can account for packaging and installing both StGit's python runtime and StGit's ancilliary files in their platform-specific destinations. N.B. the sdist tarball produced by setuptools still contains everything needed to make a complete StGit distribution. But not everything will be installed if installing the sdist (or wheel) with setuptools or pip. Signed-off-by: Peter Grayson --- MANIFEST.in | 2 ++ contrib/release/pkgtest.py | 37 +------------------------------------ setup.py | 13 ------------- 3 files changed, 3 insertions(+), 49 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 07d2d85..1b517d4 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -16,6 +16,7 @@ include Makefile include README.md include TODO include build.py +include completion/* include contrib/*.sh include contrib/Makefile include contrib/stg-* @@ -27,6 +28,7 @@ include perf/*.py include perf/*.sh include pyproject.toml include stg +include stgit/templates/*.tmpl include t/*.pl include t/*.sh include t/Makefile diff --git a/contrib/release/pkgtest.py b/contrib/release/pkgtest.py index a66f43a..4274003 100644 --- a/contrib/release/pkgtest.py +++ b/contrib/release/pkgtest.py @@ -346,14 +346,6 @@ def test_install_from_git_url(base, repo, cache): ) log(f'{version=}') - share_dir = base / 'venv' / 'share' / 'stgit' - assert (share_dir / 'completion' / 'stg.fish').is_file() - assert (share_dir / 'completion' / 'stgit.bash').is_file() - assert (share_dir / 'completion' / 'stgit.zsh').is_file() - assert (share_dir / 'templates' / 'patchmail.tmpl').is_file() - assert (share_dir / 'contrib').is_dir() - assert (share_dir / 'examples').is_dir() - # Ensure cmdlist.py was generated check_call([venv_py_exe(base), '-c', 'import stgit.commands.cmdlist'], cwd=base) @@ -502,10 +494,7 @@ def test_bdist_wheel(base, repo): with zipfile.ZipFile(stgit_whl, 'r') as zf: zf.getinfo('stgit/commands/cmdlist.py') assert 'def _get_version' not in zf.read('stgit/_version.py').decode() - share_prefix = Path(f'stgit-{version}.data/data/share/stgit') - zf.getinfo(str(share_prefix / 'completion' / 'stg.fish')) - zf.getinfo(str(share_prefix / 'completion' / 'stgit.bash')) - zf.getinfo(str(share_prefix / 'completion' / 'stgit.zsh')) + zf.getinfo('stgit/templates/patchmail.tmpl') def test_develop_mode(base, repo, cache): @@ -635,14 +624,6 @@ def test_install_from_unpacked_sdist(base, cache): ) assert work_sdist.name.endswith(version) - share_dir = base / 'venv' / 'share' / 'stgit' - assert (share_dir / 'completion' / 'stg.fish').is_file() - assert (share_dir / 'completion' / 'stgit.bash').is_file() - assert (share_dir / 'completion' / 'stgit.zsh').is_file() - assert (share_dir / 'templates' / 'patchmail.tmpl').is_file() - assert (share_dir / 'contrib').is_dir() - assert (share_dir / 'examples').is_dir() - def test_install_sdist(base, cache): log_test('test_install_sdist') @@ -665,14 +646,6 @@ def test_install_sdist(base, cache): ) assert sdist_path.name.split('stgit-', 1)[1].startswith(version) - share_dir = base / 'venv' / 'share' / 'stgit' - assert (share_dir / 'completion' / 'stg.fish').is_file() - assert (share_dir / 'completion' / 'stgit.bash').is_file() - assert (share_dir / 'completion' / 'stgit.zsh').is_file() - assert (share_dir / 'templates' / 'patchmail.tmpl').is_file() - assert (share_dir / 'contrib').is_dir() - assert (share_dir / 'examples').is_dir() - def test_install_wheel(base): log_test('test_install_wheel') @@ -687,14 +660,6 @@ def test_install_wheel(base): ) assert whl_path.name.split('stgit-', 1)[1].startswith(version) - share_dir = base / 'venv' / 'share' / 'stgit' - assert (share_dir / 'completion' / 'stg.fish').is_file() - assert (share_dir / 'completion' / 'stgit.bash').is_file() - assert (share_dir / 'completion' / 'stgit.zsh').is_file() - assert (share_dir / 'templates' / 'patchmail.tmpl').is_file() - assert (share_dir / 'contrib').is_dir() - assert (share_dir / 'examples').is_dir() - if __name__ == '__main__': main() diff --git a/setup.py b/setup.py index 059265e..aad273d 100644 --- a/setup.py +++ b/setup.py @@ -128,19 +128,6 @@ setup( 'stgit.lib', 'stgit.lib.git', ], - data_files=[ - ('share/stgit/templates', glob('stgit/templates/*.tmpl')), - ('share/stgit/examples', glob('examples/*.tmpl') + ['examples/gitconfig']), - ('share/stgit/contrib', ['contrib/stgbashprompt.sh']), - ( - 'share/stgit/completion', - [ - 'completion/stg.fish', - 'completion/stgit.bash', - 'completion/stgit.zsh', - ], - ), - ], classifiers=[ 'Development Status :: 5 - Production/Stable', 'Environment :: Console', -- 2.11.4.GIT