Skip to content
Snippets Groups Projects
Unverified Commit 16213940 authored by Andrey Vihrov's avatar Andrey Vihrov
Browse files

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 <module>
      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 <module>
      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 <module>
      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
parent 5a1a1f3c
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment