'How to change seed packages versions when creating virtualenv?

I am running into an issue when deploying a django-rest-framework API to production. The addition of seed packages pip, setuptools and wheel upon virtualenv's creation causes my deployment to fail. It appears that the specific version of setuptools (59.1.1) used here prevents usage from Newlines (related to this issue) which are used in the description of django-hijack==2.10.1 and causes the following error. This behaviour has been reverted in the newer versions of setuptools (from 59.4.0). Thus I would like to pin the version of setuptools added in seed packages upon virtualenv creation to make sure my deployment succeeds but I have no idea if/where I can set added packages versions. Any help is appreciated!

Successfully created virtual environment! 
Virtualenv location: /var/www/backoffice/20211223111028/back/.venv
Installing dependencies from Pipfile.lock (6e978f)...
Ignoring appnope: markers 'sys_platform == "darwin"' don't match your environment
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
Running command 'cd /var/www/backoffice/20211223111028/back && pipenv install' on host 172.31.128.48
Creating a virtualenv for this project...
Pipfile: /var/www/backoffice/20211223111028/back/Pipfile
Using /home/ignition/.pyenv/versions/3.9.0/bin/python3.9 (3.9.0) to create virtualenv...
⠸ Creating virtual environment...created virtual environment CPython3.9.0.final.0-64 in 152ms
  creator CPython3Posix(dest=/var/www/backoffice/20211223111028/back/.venv, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, wheel=bundle, pip=bundle, setuptools=bundle, via=copy, app_data_dir=/home/ignition/.local/share/virtualenv)
    added seed packages: pip==21.3.1, setuptools==59.1.1, wheel==0.37.0
  activators BashActivator,PowerShellActivator,PythonActivator,FishActivator,XonshActivator,CShellActivator
                                                                                                                                                                           ✔ Successfully created virtual environment! 
Installing dependencies from Pipfile.lock (6e978f)...
Virtualenv location: /var/www/backoffice/20211223111028/back/.venv
An error occurred while installing django-hijack==2.1.10 --hash=sha256:be484f0ca67a092d5bf9bf8a5307beb716dc2e86b56a69796479183fdeb9036c! Will try again.
Ignoring appnope: markers 'sys_platform == "darwin"' don't match your environment
Installing initially failed dependencies...
[InstallError]:   File "/usr/local/lib/python3.5/dist-packages/pipenv/cli/command.py", line 253, in install
[InstallError]:       site_packages=state.site_packages
[InstallError]:   File "/usr/local/lib/python3.5/dist-packages/pipenv/core.py", line 2063, in do_install
[InstallError]:       keep_outdated=keep_outdated
[InstallError]:   File "/usr/local/lib/python3.5/dist-packages/pipenv/core.py", line 1312, in do_init
[InstallError]:       pypi_mirror=pypi_mirror,
[InstallError]:   File "/usr/local/lib/python3.5/dist-packages/pipenv/core.py", line 900, in do_install_dependencies
[InstallError]:       retry_list, procs, failed_deps_queue, requirements_dir, **install_kwargs
[InstallError]:   File "/usr/local/lib/python3.5/dist-packages/pipenv/core.py", line 796, in batch_install
[InstallError]:       _cleanup_procs(procs, failed_deps_queue, retry=retry)
[InstallError]:   File "/usr/local/lib/python3.5/dist-packages/pipenv/core.py", line 703, in _cleanup_procs
[InstallError]:       raise exceptions.InstallError(c.dep.name, extra=err_lines)
[pipenv.exceptions.InstallError]: Collecting django-hijack==2.1.10
[pipenv.exceptions.InstallError]:   Using cached django-hijack-2.1.10.tar.gz (20 kB)
[pipenv.exceptions.InstallError]:   Preparing metadata (setup.py): started
[pipenv.exceptions.InstallError]:   Preparing metadata (setup.py): finished with status 'error'
[pipenv.exceptions.InstallError]:   ERROR: Command errored out with exit status 1:
[pipenv.exceptions.InstallError]:    command: /var/www/backoffice/20211223111028/back/.venv/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-oupxjc2y/django-hijack_997c7a8fad3a4188b9337ef9ba8d2bd9/setup.py'"'"'; __file__='"'"'/tmp/pip-install-oupxjc2y/django-hijack_997c7a8fad3a4188b9337ef9ba8d2bd9/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-nykp1oz9
[pipenv.exceptions.InstallError]:        cwd: /tmp/pip-install-oupxjc2y/django-hijack_997c7a8fad3a4188b9337ef9ba8d2bd9/
[pipenv.exceptions.InstallError]:   Complete output (26 lines):
[pipenv.exceptions.InstallError]:   running egg_info
[pipenv.exceptions.InstallError]:   creating /tmp/pip-pip-egg-info-nykp1oz9/django_hijack.egg-info
[pipenv.exceptions.InstallError]:   writing /tmp/pip-pip-egg-info-nykp1oz9/django_hijack.egg-info/PKG-INFO
[pipenv.exceptions.InstallError]:   Traceback (most recent call last):
[pipenv.exceptions.InstallError]:     File "<string>", line 1, in <module>
[pipenv.exceptions.InstallError]:     File "/tmp/pip-install-oupxjc2y/django-hijack_997c7a8fad3a4188b9337ef9ba8d2bd9/setup.py", line 44, in <module>
[pipenv.exceptions.InstallError]:       setup(name="django-hijack",
[pipenv.exceptions.InstallError]:     File "/var/www/backoffice/20211223111028/back/.venv/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
[pipenv.exceptions.InstallError]:       return distutils.core.setup(**attrs)
[pipenv.exceptions.InstallError]:     File "/home/ignition/.pyenv/versions/3.9.0/lib/python3.9/distutils/core.py", line 148, in setup
[pipenv.exceptions.InstallError]:       dist.run_commands()
[pipenv.exceptions.InstallError]:     File "/home/ignition/.pyenv/versions/3.9.0/lib/python3.9/distutils/dist.py", line 966, in run_commands
[pipenv.exceptions.InstallError]:       self.run_command(cmd)
[pipenv.exceptions.InstallError]:     File "/home/ignition/.pyenv/versions/3.9.0/lib/python3.9/distutils/dist.py", line 985, in run_command
[pipenv.exceptions.InstallError]:       cmd_obj.run()


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source