question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected behavior when distutils is invoked before Setuptools

See original GitHub issue

TL;DR We are forced to use distutils because setuptools has broken symlink processing and this causes distutils.errors.DistutilsClassError: command class <class '__main__.SDistCommand'> must subclass Command.

It works with setuptools<48 and the changelog doesn’t document any breaking behaviors for this version.

Repro:

$ git clone https://github.com/ansible/ansible.git
$ cd ansible
$ pip install -U 'setuptools>=48'
$ python setup.py sdist

(tried under Python 3.8)

Ref: https://github.com/ansible/ansible/issues/70456

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:16 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
jorisvandenbosschecommented, Jul 13, 2020

We also run into this warning in pandas, where we use distutils.version for version checking in the actual library (so not just in the packaging code).

1reaction
jaracocommented, Jul 10, 2020

Great. Thanks for enacting that.

I’m wondering if there’s something that Setuptools should do here to help other projects with similar usages from encountering the same issue as we bring the adopted distutils back. For example, the project could:

  1. Prior to re-enabling the adoption, warn when ‘distutils’ appears in sys.modules (except on PyPy, where that’s the status quo on startup).
  2. When re-enabling the adoption, error with a helpful message when distutils is replaced (again exempting PyPy).

I think I’ll enact (1) now and give it some time to percolate over the weekend and maybe longer.

Do please consider filing something with Ansible to investigate a long-term solution for what Ansible will do when distutils is sunset and all that’s left is Setuptools (as that’s the plan).

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix 'UserWarning: Distutils was imported before ...
This may lead to undesirable behaviors or errors. To avoid these issues, avoid using distutils directly, ensure that setuptools is installed ...
Read more >
distutils-r1 — standard Python build systems
The legacy mode invokes the setup.py script directly. The build command is invoked to populate the build directory in the compile phase, then...
Read more >
twine 4.0.2 documentation
The biggest reason to use Twine is that it securely authenticates you to PyPI over HTTPS using a verified connection, regardless of the...
Read more >
This Way Up: A Bottom-Up Look At Python Packaging
A long standing criticism of setuptools (and distutils before it) was its use of a Python script ( setup.py ), instead of a...
Read more >
Setuptools can't find my GCC compiler - Numba Discussion
I am attempting to include my AOT-compiled extensions in my setup.py. from setuptools import setup import sys import os script_path ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found