linkedin / shiv

shiv is a command line utility for building fully self contained Python zipapps as outlined in PEP 441, but with all their dependencies included.
BSD 2-Clause "Simplified" License
1.73k stars 94 forks source link

ConfigParser issue with duplicate option entries #225

Open axlroden opened 2 years ago

axlroden commented 2 years ago

I have an issue with the way Shiv runs ConfigParser for a specific module I need.

configparser.DuplicateOptionError: While reading from PosixPath('/tmp/tmpjl8xhapm/pyroute2-0.7.2.dist-info/entry_points.txt') [line 56]: option 'conntrack' in section 'pyroute2' already exists

pyroute2 has multiple entries of conntrack with different capitalisation. Conntrack/conntrack. Excerpt from pyroute2 setup.cfg

conntrack = pyroute2.conntrack
--
45 | iproute = pyroute2.iproute
… |  
61 | NetlinkDumpInterrupted = pyroute2.netlink.exceptions:NetlinkDumpInterrupted
62 | Conntrack = pyroute2.conntrack:Conntrack

Since this is a linux module it shouldn't be an issue to handle this, but from what I can understand ConfigParser changes everything to lowercase because of Windows.

https://stackoverflow.com/a/19359720/837767 This answer explains it, and shows a fix for the issue.

Any way to implement this into shiv ?

axlroden commented 2 years ago

Just tested adding:

config_parser.optionxform = str

https://github.com/linkedin/shiv/blob/337e8c35fc5b730bb253ab71cad36c0f05b283bd/src/shiv/cli.py#L44 Here, will fix the issue I have.

Not sure it would break any windows binaries ?

lorencarvalho commented 2 years ago

Hi @axlroden,

Thanks for the issue! I think your solution sounds good and could even be safely implemented in a way that's compatible with Windows & Linux, by gating the optionxform on the output of https://docs.python.org/3/library/platform.html#platform.system