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

Use an available python2 binary name in debian templates. #203

Merged
merged 2 commits into from
Jul 12, 2024
Merged
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
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