Skip to content

Commit

Permalink
fixes #7: console_scripts file names now have the major python versio…
Browse files Browse the repository at this point in the history
…n appended for python3
  • Loading branch information
Hilton Rudham committed Jul 10, 2020
1 parent f327edf commit de87c0e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
18 changes: 17 additions & 1 deletion src/_wheel2deb/debian.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,9 +334,25 @@ def run_install_scripts(self):
config = configparser.ConfigParser()
config.read_string(self.wheel.entrypoints)

# Some python debian packages have separate python2 and python3
# Debian packages released. If a package has a `console_scripts`
# entry, and the python2 version of a debian package is already
# installed, when we attempt to install a python3 package created
# by wheel2deb, it will fail because apt will not let it overwrite
# an existing file.
# An example of this is the `pyjwt` package: for the officially
# released Debian packages, this creates `/usr/bin/pyjwt` (apt install
# python-jwt) and `/usr/bin/pyjwt3` (apt install python3-jwt).
# The code below follows a similar pattern, by appending the python
# major version to `console_scripts` entries for versions greater
# than three.
endpoint_python_version = ""
if self.pyvers.major >= 3:
endpoint_python_version = str(self.pyvers.major)

entrypoints = {}
for section in config:
x = ['%s=%s' % k for k in config.items(section)]
x = ['%s%s=%s' % (k[0], endpoint_python_version, k[1]) for k in config.items(section)]
if x:
entrypoints[section] = x

Expand Down
6 changes: 5 additions & 1 deletion testing/test_wheel2deb.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ def test_conversion(tmp_path, wheel_path):

package_hash = digests(package_list[0])

endpoint_python_version = ""
if sys.version_info[0] >= 3:
endpoint_python_version = str(sys.version_info[0])

# check that the entrypoint will be installed in /usr/bin
entrypoint = (unpack_path / 'debian/python3-foobar/usr/bin/entrypoint')
entrypoint = (unpack_path / ('debian/python3-foobar/usr/bin/entrypoint'+endpoint_python_version))
assert entrypoint.exists()

# check shebang
Expand Down

0 comments on commit de87c0e

Please sign in to comment.