-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FR] Preserve the use of spaces/tabs in setup.cfg/setup.py in sdist tarball #3672
Comments
…dependencies. Apply upstreamed patch to remove use of python-wheel, python-pip and python-setuptools-scm-git-archive in makedepends and python-setuptools in depends: pycontribs/selinux#54 Switch to git sources to not have to backport patches again: pypa/setuptools#3672 Switch to PEP517. git-svn-id: file:///srv/repos/svn-community/svn@1346953 9fca08f4-af9d-4005-b8df-a31f2cc04f65
…dependencies. Apply upstreamed patch to remove use of python-wheel, python-pip and python-setuptools-scm-git-archive in makedepends and python-setuptools in depends: pycontribs/selinux#54 Switch to git sources to not have to backport patches again: pypa/setuptools#3672 Switch to PEP517. git-svn-id: file:///srv/repos/svn-community/svn@1346953 9fca08f4-af9d-4005-b8df-a31f2cc04f65
…essary dependencies. Apply upstreamed patch to remove use of python-wheel, python-pip and python-setuptools-scm-git-archive in makedepends and python-setuptools in depends: pycontribs/subprocess-tee#60 Apply upstreamed patch to remove use of mock: pycontribs/subprocess-tee#62 Remove unnecessary quotes and curly braces. Switch to git sources to not have to backport patches again: pypa/setuptools#3672 Switch to PEP517. git-svn-id: file:///srv/repos/svn-community/svn@1346987 9fca08f4-af9d-4005-b8df-a31f2cc04f65
…essary dependencies. Apply upstreamed patch to remove use of python-wheel, python-pip and python-setuptools-scm-git-archive in makedepends and python-setuptools in depends: pycontribs/subprocess-tee#60 Apply upstreamed patch to remove use of mock: pycontribs/subprocess-tee#62 Remove unnecessary quotes and curly braces. Switch to git sources to not have to backport patches again: pypa/setuptools#3672 Switch to PEP517. git-svn-id: file:///srv/repos/svn-community/svn@1346987 9fca08f4-af9d-4005-b8df-a31f2cc04f65
…ependencies. Apply upstreamed patch to remove use of python-wheel, python-pip and python-setuptools-scm-git-archive in makedepends and python-setuptools in depends: pycontribs/enrich#45 Apply upstreamed patch to remove use of mock: pycontribs/enrich#46 Remove unnecessary quotes and curly braces. Switch to git sources to not have to backport patches again: pypa/setuptools#3672 git-svn-id: file:///srv/repos/svn-community/svn@1346989 9fca08f4-af9d-4005-b8df-a31f2cc04f65
…ependencies. Apply upstreamed patch to remove use of python-wheel, python-pip and python-setuptools-scm-git-archive in makedepends and python-setuptools in depends: pycontribs/enrich#45 Apply upstreamed patch to remove use of mock: pycontribs/enrich#46 Remove unnecessary quotes and curly braces. Switch to git sources to not have to backport patches again: pypa/setuptools#3672 git-svn-id: file:///srv/repos/svn-community/svn@1346989 9fca08f4-af9d-4005-b8df-a31f2cc04f65
…ependencies. Apply upstreamed patch to remove use of python-wheel, python-pip and python-setuptools-scm-git-archive in makedepends and python-setuptools in depends: pycontribs/enrich#45 Apply upstreamed patch to remove use of mock: pycontribs/enrich#46 Remove unnecessary quotes and curly braces. Switch to git sources to not have to backport patches again: pypa/setuptools#3672 git-svn-id: file:///srv/repos/svn-community/svn@1346990 9fca08f4-af9d-4005-b8df-a31f2cc04f65
…ependencies. Apply upstreamed patch to remove use of python-wheel, python-pip and python-setuptools-scm-git-archive in makedepends and python-setuptools in depends: pycontribs/enrich#45 Apply upstreamed patch to remove use of mock: pycontribs/enrich#46 Remove unnecessary quotes and curly braces. Switch to git sources to not have to backport patches again: pypa/setuptools#3672 git-svn-id: file:///srv/repos/svn-community/svn@1346990 9fca08f4-af9d-4005-b8df-a31f2cc04f65
Hi @dvzrv, thank you very much for reporting this. I believe the following is happening:
I went through configparser's doc and I could not find a configuration that enforces I believe that before we implement any change in the setuptools, that needs to be implemented first1. Please let me know if you have a different solution (also please feel free to submit a PR). Meanwhile, I will reclassify this issue as a Feature Request and tag it as dependent of the Footnotes
|
@abravalheri hmm, so altering/extending the configparser behavior would be the ideal solution for this? |
Hi @dvzrv , I would word it differently: without support for preserving indentation implemented in |
same here
quickfix: convert tab-indent back to space-indent, and then apply the patch here: indent with 4 spaces
so setup.cfg is modified... otherwise we could just copy the original setup.cfg ideally, such dynamic fields should be spaced by 3 empty lines from other fields
i guess we will wait 1000 years until configparser can do that : P this would require a concrete syntax tree (CST) parser like tree-sitter tree-sitter-ini fails to parse
tree-sitter-toml (online) fails to parse tree-sitter-yaml (online) fails to parse |
I wasted time with this problem when trying to create a Conda patch, although I'm using the absolutely uniquely named and searchable "build" Python module. I tried to open an issue there but was redirected here. The whitespace handling is documented behavior and therefore unlikely to change, imho. Although I hope that configparser (or setuptools) at least might be convinced to not produce trailing whitespaces. I think the easiest workaround that doe not require waiting for ConfigParser to change behavior would be this workflow:
There is a similar issue in bumpversion |
You might wish to look into migrating to |
speaking of workarounds
use import configparser
cfg = configparser.ConfigParser()
assert cfg.read("setup.cfg") == ["setup.cfg"]
# set value
try:
cfg.add_section("metadata")
except configparser.DuplicateSectionError:
pass
cfg.set("metadata", "name", "some_name")
# remove value
try:
cfg.remove_option("some_section", "some_key")
except configparser.NoSectionError:
pass
# remove section
cfg.remove_section("some_section")
with open("setup.cfg", "w") as f:
cfg.write(f) this could be shorter with a command line tool
|
Thanks for the pointer. That might work for me as a workaround. It seems that support was added in setuptools 61, which was released 2022-03-24. This makes me a bit hesistant regarding backwards compatibility, but I'm already using pyproject.toml build, which seems to be supported since pip 10.0 released 2018-04-14, so I should still have quite a bit of compatibility after simply increasing the required setuptools version inside the pyproject.toml. |
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
git clone https://github.com/pycontribs/selinux
cd selinux
python setup.py sdist
tar -zxvf dist/selinux-*.tar.gz selinux-*/setup.cfg
(you'll have to choose a more specific dir in the 2nd argument!)diff -ruN selinux-*/setup.cfg setup.cfg
Output
The text was updated successfully, but these errors were encountered: