From 9e6b0d1117e21f2e6d092e337c5c522726016467 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Sun, 12 Jul 2020 18:25:56 -0400 Subject: Attempt to go Python3-only Ubuntu 20.04 no longer really supports Python 2, so we'd have to fork the packaging code if we wanted to keep support for Python 2 elsewhere. Given that Python 3 has been around for a more than a decade and that Python 2 was formally EOLed more than six months ago as of this writing, this seems like an unnecessary complication. The biggest change is rewriting the Homebrew formula for Python 3. --- scripts/build-debian-control-files.py | 13 ++++--------- scripts/build-firmware-package.py | 2 +- scripts/build-homebrew-formula.py | 14 +++++++++----- scripts/build-shadow-tree.py | 2 +- source/Makefile | 1 - source/debian/rules | 2 +- 6 files changed, 16 insertions(+), 18 deletions(-) diff --git a/scripts/build-debian-control-files.py b/scripts/build-debian-control-files.py index c06055d..46958ea 100755 --- a/scripts/build-debian-control-files.py +++ b/scripts/build-debian-control-files.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import subprocess import argparse @@ -25,23 +25,18 @@ Priority: optional Standards-Version: 3.9.6 Build-Depends: debhelper (>= 9), dh-python, - python (>= 2.7), - python-yaml, + python3-yaml, python3 Homepage: http://trac.cryptech.is/wiki Package: {args.package} Architecture: any -Depends: python, - python-serial (>= 3.0), - python-tornado (>= 4.0), - python-crypto, - python3, +Depends: python3, python3-serial (>= 3.0), python3-tornado (>= 4.0), python3-crypto, ${{misc:Depends}}, - ${{python:Depends}}, + ${{python3:Depends}}, ${{shlibs:Depends}} {conflicts}\ Description: Cryptech Project open-source cryptographic software and firmware. diff --git a/scripts/build-firmware-package.py b/scripts/build-firmware-package.py index 9a58970..659a63f 100755 --- a/scripts/build-firmware-package.py +++ b/scripts/build-firmware-package.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import subprocess import tempfile diff --git a/scripts/build-homebrew-formula.py b/scripts/build-homebrew-formula.py index 54cdcae..852b4b6 100755 --- a/scripts/build-homebrew-formula.py +++ b/scripts/build-homebrew-formula.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Yes, this is a Python program writing a Ruby program. @@ -32,7 +32,7 @@ template = '''\ # code, however, is what Homebrew considers "bindings", so we install # those where user scripts as well as our own can find them...then we # add a symlink so that our scripts can find our bindings regardless -# of which copy of Python 2.7 Homebrew decides we should use this week. +# of which copy of Python Homebrew decides we should use this week. # # We have to build our own software before installing our Python code, # because at least one of the Python modules we install @@ -54,6 +54,8 @@ class {classname} < Formula url "{url}" sha256 "{sha256}" + depends_on "python@3.8" + {conflicts} resource "pyserial" do @@ -88,11 +90,13 @@ class {classname} < Formula def install - ENV.prepend_create_path "PYTHONPATH", libexec/"vendor/lib/python2.7/site-packages" + xy = Language::Python.major_minor_version "python3" + + ENV.prepend_create_path "PYTHONPATH", libexec/"vendor/lib/python#{xy}/site-packages" resources.each do |r| r.stage do - system "python", *Language::Python.setup_install_args(libexec/"vendor") + system "python3", *Language::Python.setup_install_args(libexec/"vendor") end end @@ -103,7 +107,7 @@ class {classname} < Formula system "python", *Language::Python.setup_install_args(prefix) bin.env_script_all_files(libexec/"bin", :PYTHONPATH => ENV["PYTHONPATH"]) - ln_s lib/"python2.7/site-packages/cryptech", libexec/"vendor/lib/python2.7/site-packages/cryptech" + ln_s lib/"python#{xy}/site-packages/cryptech", libexec/"vendor/lib/python#{xy}/site-packages/cryptech" share.install "cryptech-alpha-firmware.tar.gz" lib.install "sw/pkcs11/libcryptech-pkcs11.dylib" diff --git a/scripts/build-shadow-tree.py b/scripts/build-shadow-tree.py index 378797f..0f3a4a1 100755 --- a/scripts/build-shadow-tree.py +++ b/scripts/build-shadow-tree.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Create a symlink build tree like the old X11 project "lndir" program. # diff --git a/source/Makefile b/source/Makefile index 5913f47..0e1f613 100644 --- a/source/Makefile +++ b/source/Makefile @@ -22,6 +22,5 @@ install: all install -D -m 644 cryptech-alpha-firmware.tar.gz ${DESTDIR}/usr/share/cryptech-alpha-firmware.tar.gz install -D -m 644 sw/pkcs11/libcryptech-pkcs11.so ${DESTDIR}/usr/lib/libcryptech-pkcs11.so ln -s libcryptech-pkcs11.so ${DESTDIR}/usr/lib/libcryptech-pkcs11.so.0 - python2 setup.py install --install-layout=deb --root=${DESTDIR} python3 setup.py install --install-layout=deb --root=${DESTDIR} find ${DESTDIR} -type d -name __pycache__ -exec rm -rf {} + diff --git a/source/debian/rules b/source/debian/rules index 0a37e86..607ba42 100755 --- a/source/debian/rules +++ b/source/debian/rules @@ -19,7 +19,7 @@ include /usr/share/dpkg/default.mk include /usr/share/dpkg/pkg-info.mk %: - dh $@ --with python2,python3 + dh $@ --with python3 # Distinct binary package versions for a single source package built # on multiple releases, to keep reprepro happy. See: -- cgit v1.2.3