Skip to content

Commit

Permalink
Merge pull request #203 from astraw/python2-binname
Browse files Browse the repository at this point in the history
Use an available python2 binary name in debian templates.
  • Loading branch information
nuclearsandwich authored Jul 12, 2024
2 parents 1601cb9 + 0eecfbd commit b268e83
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
14 changes: 11 additions & 3 deletions stdeb/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -1116,6 +1116,14 @@ def __init__(self,

if not (with_python2 or with_python3):
raise RuntimeError('nothing to do - neither Python 2 or 3.')

if with_python2:
if shutil.which("python"):
self.python2_binname = "python"
elif shutil.which("python2"):
self.python2_binname = "python2"
else:
raise RuntimeError("Python 2 binary not found on path as either `python` or `python2`")
sequencer_with = []
if with_python2:
sequencer_with.append('python2')
Expand Down Expand Up @@ -1650,22 +1658,22 @@ def build_dsc(debinfo,
%(binary_target_lines)s
"""

RULES_OVERRIDE_CLEAN_TARGET_PY2 = " python setup.py clean -a"
RULES_OVERRIDE_CLEAN_TARGET_PY2 = " %(python2_binname)s setup.py clean -a"
RULES_OVERRIDE_CLEAN_TARGET_PY3 = " python3 setup.py clean -a"
RULES_OVERRIDE_CLEAN_TARGET = r"""
override_dh_auto_clean:
%(rules_override_clean_target_pythons)s
find . -name \*.pyc -exec rm {} \;
"""

RULES_OVERRIDE_BUILD_TARGET_PY2 = " python setup.py build --force"
RULES_OVERRIDE_BUILD_TARGET_PY2 = " %(python2_binname)s setup.py build --force"
RULES_OVERRIDE_BUILD_TARGET_PY3 = " python3 setup.py build --force"
RULES_OVERRIDE_BUILD_TARGET = """
override_dh_auto_build:
%(rules_override_build_target_pythons)s
"""

RULES_OVERRIDE_INSTALL_TARGET_PY2 = " python setup.py install --force --root=debian/%(package)s --no-compile -O0 --install-layout=deb %(install_prefix)s %(no_python2_scripts_cli_args)s" # noqa: E501
RULES_OVERRIDE_INSTALL_TARGET_PY2 = " %(python2_binname)s setup.py install --force --root=debian/%(package)s --no-compile -O0 --install-layout=deb %(install_prefix)s %(no_python2_scripts_cli_args)s" # noqa: E501

RULES_OVERRIDE_INSTALL_TARGET_PY3 = " python3 setup.py install --force --root=debian/%(package3)s --no-compile -O0 --install-layout=deb %(install_prefix)s %(no_python3_scripts_cli_args)s" # noqa: E501

Expand Down
5 changes: 5 additions & 0 deletions test2and3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ if [ "$DO_PY3" = true ]; then
# test the "sdist_dsc" and "bdist_deb" commands
${PY3EXE} setup.py --command-packages stdeb.command sdist_dsc --with-python3=true --with-python2=false bdist_deb
cd ../..

echo "using Python 3 to test 2 and 3 generation"
cd test_data/simple_pkg
${PY3EXE} setup.py --command-packages stdeb.command sdist_dsc --with-python3=true --with-python2=true bdist_deb
cd ../..
else
echo "skipping Python >= 3.2 test"
fi
Expand Down

0 comments on commit b268e83

Please sign in to comment.