pypa / pypa/setuptools

[FR] Preserve the use of spaces/tabs in setup.cfg/setup.py in sdist tarball

Open
#3,672 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement upstream
Dominant language
Python
Stars
2.9k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
1

Description

setuptools version

65.1.1

Python version

3.10.8

OS

Arch Linux

Additional environment information

I have noticed this issue several times already when trying to apply patches for Arch Linux packages, that I supplied to upstream myself (e.g. for the mailman ecosystem). I had to basically write the patches all over again or switch to git sources to be able to apply them, which means a lot of unnecessary overhead (or may not be possible if we are relying on PGP validated source tarballs).

Description

Using python setup.py sdist, setuptools unconditionally adds tabs to setup.cfg and setup.py in the sdist tarball.

From a downstream perspective, this is extremely tedious behavior, as it requires to adapt/backport all patches that touch those files (e.g. version updates or other data in those files).

Expected behavior

Setuptools does not touch the indentation of setup.cfg and setup.py (or any other file for that matter) when creating sdist tarballs.

How to Reproduce
  1. git clone https://github.com/pycontribs/selinux
  2. cd selinux
  3. python setup.py sdist
  4. tar -zxvf dist/selinux-*.tar.gz selinux-*/setup.cfg (you'll have to choose a more specific dir in the 2nd argument!)
  5. diff -ruN selinux-*/setup.cfg setup.cfg
Output
/usr/lib/python3.10/site-packages/setuptools/config/setupcfg.py:508: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead.
  warnings.warn(msg, warning_class)
/usr/lib/python3.10/site-packages/setuptools/installer.py:27: SetuptoolsDeprecationWarning: setuptools.installer is deprecated. Requirements should be satisfied by a PEP 517 installer.
  warnings.warn(
/usr/lib/python3.10/site-packages/setuptools/config/setupcfg.py:508: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead.
  warnings.warn(msg, warning_class)
running sdist
running egg_info
writing selinux.egg-info/PKG-INFO
writing dependency_links to selinux.egg-info/dependency_links.txt
writing requirements to selinux.egg-info/requires.txt
writing top-level names to selinux.egg-info/top_level.txt
adding license file 'LICENSE'
writing manifest file 'selinux.egg-info/SOURCES.txt'
running check
creating selinux-0.1.dev73+ge90f38e
creating selinux-0.1.dev73+ge90f38e/.github
creating selinux-0.1.dev73+ge90f38e/.github/workflows
creating selinux-0.1.dev73+ge90f38e/selinux
creating selinux-0.1.dev73+ge90f38e/selinux.egg-info
creating selinux-0.1.dev73+ge90f38e/tests
creating selinux-0.1.dev73+ge90f38e/tests/roles
creating selinux-0.1.dev73+ge90f38e/tests/roles/ensure_ansible
creating selinux-0.1.dev73+ge90f38e/tests/roles/ensure_ansible/defaults
creating selinux-0.1.dev73+ge90f38e/tests/roles/ensure_ansible/meta
creating selinux-0.1.dev73+ge90f38e/tests/roles/ensure_ansible/molecule
creating selinux-0.1.dev73+ge90f38e/tests/roles/ensure_ansible/molecule/default
creating selinux-0.1.dev73+ge90f38e/tests/roles/ensure_ansible/tasks
creating selinux-0.1.dev73+ge90f38e/tests/roles/ensure_ansible/vars
creating selinux-0.1.dev73+ge90f38e/tools
creating selinux-0.1.dev73+ge90f38e/zuul.d
copying files to selinux-0.1.dev73+ge90f38e...
copying .ansible-lint -> selinux-0.1.dev73+ge90f38e
copying .flake8 -> selinux-0.1.dev73+ge90f38e
copying .gitignore -> selinux-0.1.dev73+ge90f38e
copying .pre-commit-config.yaml -> selinux-0.1.dev73+ge90f38e
copying LICENSE -> selinux-0.1.dev73+ge90f38e
copying README.rst -> selinux-0.1.dev73+ge90f38e
copying ansible.cfg -> selinux-0.1.dev73+ge90f38e
copying pyproject.toml -> selinux-0.1.dev73+ge90f38e
copying setup.cfg -> selinux-0.1.dev73+ge90f38e
copying setup.py -> selinux-0.1.dev73+ge90f38e
copying tox.ini -> selinux-0.1.dev73+ge90f38e
copying .github/FUNDING.yml -> selinux-0.1.dev73+ge90f38e/.github
copying .github/release-drafter.yml -> selinux-0.1.dev73+ge90f38e/.github
copying .github/workflows/release-drafter.yml -> selinux-0.1.dev73+ge90f38e/.github/workflows
copying selinux/__init__.py -> selinux-0.1.dev73+ge90f38e/selinux
copying selinux.egg-info/PKG-INFO -> selinux-0.1.dev73+ge90f38e/selinux.egg-info
copying selinux.egg-info/SOURCES.txt -> selinux-0.1.dev73+ge90f38e/selinux.egg-info
copying selinux.egg-info/dependency_links.txt -> selinux-0.1.dev73+ge90f38e/selinux.egg-info
copying selinux.egg-info/requires.txt -> selinux-0.1.dev73+ge90f38e/selinux.egg-info
copying selinux.egg-info/top_level.txt -> selinux-0.1.dev73+ge90f38e/selinux.egg-info
copying selinux.egg-info/zip-safe -> selinux-0.1.dev73+ge90f38e/selinux.egg-info
copying tests/roles/ensure_ansible/defaults/main.yml -> selinux-0.1.dev73+ge90f38e/tests/roles/ensure_ansible/defaults
copying tests/roles/ensure_ansible/meta/main.yml -> selinux-0.1.dev73+ge90f38e/tests/roles/ensure_ansible/meta
copying tests/roles/ensure_ansible/molecule/Dockerfile.j2 -> selinux-0.1.dev73+ge90f38e/tests/roles/ensure_ansible/molecule
copying tests/roles/ensure_ansible/molecule/default/molecule.yml -> selinux-0.1.dev73+ge90f38e/tests/roles/ensure_ansible/molecule/default
copying tests/roles/ensure_ansible/molecule/default/playbook.yml -> selinux-0.1.dev73+ge90f38e/tests/roles/ensure_ansible/molecule/default
copying tests/roles/ensure_ansible/tasks/main.yml -> selinux-0.1.dev73+ge90f38e/tests/roles/ensure_ansible/tasks
copying tests/roles/ensure_ansible/vars/centos-7.yml -> selinux-0.1.dev73+ge90f38e/tests/roles/ensure_ansible/vars
copying tests/roles/ensure_ansible/vars/centos-8.yml -> selinux-0.1.dev73+ge90f38e/tests/roles/ensure_ansible/vars
copying tests/roles/ensure_ansible/vars/debian.yml -> selinux-0.1.dev73+ge90f38e/tests/roles/ensure_ansible/vars
copying tests/roles/ensure_ansible/vars/redhat-8.yml -> selinux-0.1.dev73+ge90f38e/tests/roles/ensure_ansible/vars
copying tests/roles/ensure_ansible/vars/redhat.yml -> selinux-0.1.dev73+ge90f38e/tests/roles/ensure_ansible/vars
copying tools/test-setup.sh -> selinux-0.1.dev73+ge90f38e/tools
copying zuul.d/layout.yaml -> selinux-0.1.dev73+ge90f38e/zuul.d
Writing selinux-0.1.dev73+ge90f38e/setup.cfg
creating dist
Creating tar archive
removing 'selinux-0.1.dev73+ge90f38e' (and everything under it)

selinux-0.1.dev73+ge90f38e/setup.cfg

--- selinux-0.1.dev73+ge90f38e/setup.cfg	2022-11-12 11:30:49.269458000 +0100
+++ setup.cfg	2022-11-12 11:30:34.955041392 +0100
@@ -7,49 +7,50 @@
 [metadata]
 name = selinux
 url = https://github.com/pycontribs/selinux
-project_urls = 
-	Bug Tracker = https://github.com/pycontribs/selinux/issues
-	Release Management = https://github.com/pycontribs/selinux/releases
-	CI = https://dashboard.zuul.ansible.com/t/ansible/builds?project=pycontribs/selinux
-	Source Code = https://github.com/pycontribs/selinux
+project_urls =
+    Bug Tracker = https://github.com/pycontribs/selinux/issues
+    Release Management = https://github.com/pycontribs/selinux/releases
+    CI = https://dashboard.zuul.ansible.com/t/ansible/builds?project=pycontribs/selinux
+    Source Code = https://github.com/pycontribs/selinux
 description = shim selinux module
 long_description = file: README.rst
 long_description_content_type = text/x-rst; charset=UTF-8
-history = file: HISTORY.rst
+
+history =  file: HISTORY.rst
 author = Sorin Sbarnea
 author_email = sorin.sbarnea@gmail.com
 maintainer = Sorin Sbarnea
 maintainer_email = sorin.sbarnea@gmail.com
 license = MIT license
 license_file = LICENSE
-classifiers = 
-	Development Status :: 5 - Production/Stable
-	
-	Environment :: Console
-	
-	Intended Audience :: Developers
-	Intended Audience :: Information Technology
-	Intended Audience :: System Administrators
-	
-	License :: OSI Approved :: MIT License
-	
-	Natural Language :: English
-	
-	Operating System :: OS Independent
-	
-	Programming Language :: Python :: 2
-	Programming Language :: Python :: 2.7
-	Programming Language :: Python :: 3
-	Programming Language :: Python :: 3.5
-	Programming Language :: Python :: 3.6
-	Programming Language :: Python :: 3.7
-	Programming Language :: Python :: 3.8
-	
-	Topic :: System :: Systems Administration
-	Topic :: Utilities
-keywords = 
-	selinux
-	virtualenv
+classifiers =
+    Development Status :: 5 - Production/Stable
+
+    Environment :: Console
+
+    Intended Audience :: Developers
+    Intended Audience :: Information Technology
+    Intended Audience :: System Administrators
+
+    License :: OSI Approved :: MIT License
+
+    Natural Language :: English
+
+    Operating System :: OS Independent
+
+    Programming Language :: Python :: 2
+    Programming Language :: Python :: 2.7
+    Programming Language :: Python :: 3
+    Programming Language :: Python :: 3.5
+    Programming Language :: Python :: 3.6
+    Programming Language :: Python :: 3.7
+    Programming Language :: Python :: 3.8
+
+    Topic :: System :: Systems Administration
+    Topic :: Utilities
+keywords =
+    selinux
+    virtualenv
 
 [options]
 use_scm_version = True
@@ -57,17 +58,13 @@
 packages = find:
 include_package_data = True
 zip_safe = True
-install_requires = 
-	distro>=1.3.0
-	setuptools>=39.0
-setup_requires = 
-	setuptools_scm >= 1.15.0
-	setuptools_scm_git_archive >= 1.0
+install_requires =
+    distro>=1.3.0
+    setuptools>=39.0
 
+# These are required during `setup.py` run:
+setup_requires =
+    setuptools_scm >= 1.15.0
+    setuptools_scm_git_archive >= 1.0
 [options.packages.find]
 where = .
-
-[egg_info]
-tag_build = 
-tag_date = 0
-

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with python setup.py sdist using the mentioned setup.cfg and setup.py files, then inspect the sdist creation path that writes them into the tarball. The work is done when extracting the generated archive and comparing those files with the originals shows no indentation or other content changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.