Skip to content
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

fixes #7: console_scripts file names now have the major python version appended for python3 #9

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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