From 162139405ec5826e6a733e0fc64274cd886df5fc Mon Sep 17 00:00:00 2001 From: Andrey Vihrov Date: Mon, 20 Dec 2021 18:13:26 +0200 Subject: [PATCH] Use distutils from Python standard library setuptools 60.0 switched from standard library distutils to its own local distutils by default [1]. setuptools' own distutils version doesn't support building with 2to3 translation anymore [2]. However, the current pycryptodomex version (3.6) relies on distutils 2to3 translation support for correct Python 3 builds. Building with the setuptools distutils version results in run-time errors such as . . . File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/cms-1.5.dev0-py3.8.egg/cmscommon/crypto.py", line 31, in from Cryptodome.Cipher import AES File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/Cryptodome/Cipher/__init__.py", line 31, in from Cryptodome.Cipher._mode_ctr import _create_ctr_cipher File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/Cryptodome/Cipher/_mode_ctr.py", line 37, in from Cryptodome.Util.number import long_to_bytes File "/opt/hostedtoolcache/Python/3.8.12/x64/lib/python3.8/site-packages/Cryptodome/Util/number.py", line 399 s = pack('>I', n & 0xffffffffL) + s ^ SyntaxError: invalid syntax We set the SETUPTOOLS_USE_DISTUTILS environment variable to continue using the system distutils version with 2to3 translation support for now. The variable can be removed later when we update to a newer pycryptodomex version. In the documentation, we also pass the environment variable to the "setup.py install" command for consistency. [1] https://github.com/pypa/setuptools/commit/f7a55da560b35c5edff2795a5c9ee5ac3985668f [2] https://github.com/pypa/setuptools/commit/d989cdb36f50785d23b07939ba8b4fc2b68cf02a --- .github/workflows/main.yml | 3 +++ docs/Installation.rst | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4556f37973..16ae9fc043 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -51,6 +51,9 @@ jobs: - name: Install requirements run: | + # Use distutils from the standard library for 2to3 translation + export SETUPTOOLS_USE_DISTUTILS="stdlib" + pip install -U pip setuptools wheel pip install -r requirements.txt pip install -r dev-requirements.txt diff --git a/docs/Installation.rst b/docs/Installation.rst index 94f6d1313f..9ad179c2db 100644 --- a/docs/Installation.rst +++ b/docs/Installation.rst @@ -145,13 +145,15 @@ Assuming you have ``pip`` installed, you can do this: .. sourcecode:: bash - sudo pip3 install -r requirements.txt - sudo python3 setup.py install + export SETUPTOOLS_USE_DISTUTILS="stdlib" + sudo --preserve-env=SETUPTOOLS_USE_DISTUTILS pip3 install -r requirements.txt + sudo --preserve-env=SETUPTOOLS_USE_DISTUTILS python3 setup.py install This command installs python dependencies globally. Note that on some distros, like Arch Linux, this might interfere with the system package manager. If you want to perform the installation in your home folder instead, then you can do this instead: .. sourcecode:: bash + export SETUPTOOLS_USE_DISTUTILS="stdlib" pip3 install --user -r requirements.txt python3 setup.py install --user @@ -176,6 +178,7 @@ After the activation, the ``pip`` command will *always* be available (even if it .. sourcecode:: bash + export SETUPTOOLS_USE_DISTUTILS="stdlib" pip3 install -r requirements.txt python3 setup.py install