You are not logged in.

#1 2020-10-06 12:26:12

xeromycota
Member
Registered: 2020-10-06
Posts: 21

[SOLVED] pacman's python-setuptools doesn't provide setuptools.extern

I just try to run python line:

import setuptools.extern

using pacman's python-setuptools  package and it returns ModuleNotFoundError. After investigation, I found out that extern library folder is missing from python-setuptools package content hence it doesn't provide `setuptools.extern`. After trying the line above using setuptools package from different source, I get this result:

  • installing latest setuptools 50.3.0 from pip in virtual environment in Arch provides `setuptools.extern`. Good

  • installing python3-setuptools 45.2.0 from apt in Ubuntu provides `setuptools.extern`. Good

  • installing latest python-setuptools 50.3.0 from pacman doesn’t provide `setuptools.extern`. Why?

Last edited by xeromycota (2020-10-06 20:39:55)

Offline

#2 2020-10-06 14:23:44

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 1,976
Website

Re: [SOLVED] pacman's python-setuptools doesn't provide setuptools.extern

PKGBUILD wrote:
prepare() {
  rm -r setuptools-$pkgver/{pkg_resources,setuptools}/{extern,_vendor}

  # Upstream devendoring logic is badly broken, see:
  # https://bugs.archlinux.org/task/58670
  # https://github.com/pypa/pip/issues/5429
  # https://github.com/pypa/setuptools/issues/1383
  # The simplest fix is to simply rewrite import paths to use the canonical
  # location in the first place
  for _module in setuptools pkg_resources '' ; do
      find setuptools-$pkgver -name \*.py -exec sed -i \
          -e 's/from '$_module.extern' import/import/' \
          -e 's/from '$_module.extern'./from /' \
          -e 's/import '$_module.extern'./import /' \
          -e "s/__import__('$_module.extern./__import__('/" \
          {} +
    done

macro_rules! yolo { { $($tokens:tt)* } => { unsafe { $($tokens)* } }; }

Offline

#3 2020-10-06 14:27:05

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,544

Re: [SOLVED] pacman's python-setuptools doesn't provide setuptools.extern

Import the modules you need, don't rely on things bundled with pip. It would be pretty stupid to use them outside of pip anyway.

Offline

#4 2020-10-06 20:11:15

xeromycota
Member
Registered: 2020-10-06
Posts: 21

Re: [SOLVED] pacman's python-setuptools doesn't provide setuptools.extern

schard wrote:
PKGBUILD wrote:
prepare() {
  rm -r setuptools-$pkgver/{pkg_resources,setuptools}/{extern,_vendor}

  # Upstream devendoring logic is badly broken, see:
  # https://bugs.archlinux.org/task/58670
  # https://github.com/pypa/pip/issues/5429
  # https://github.com/pypa/setuptools/issues/1383
  # The simplest fix is to simply rewrite import paths to use the canonical
  # location in the first place
  for _module in setuptools pkg_resources '' ; do
      find setuptools-$pkgver -name \*.py -exec sed -i \
          -e 's/from '$_module.extern' import/import/' \
          -e 's/from '$_module.extern'./from /' \
          -e 's/import '$_module.extern'./import /' \
          -e "s/__import__('$_module.extern./__import__('/" \
          {} +
    done

I don't understand bash script, but I know what the comment says. Two questions remain, where they move the `extern` package? How do I import it?

Offline

#5 2020-10-06 20:34:05

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: [SOLVED] pacman's python-setuptools doesn't provide setuptools.extern

xeromycota wrote:

I don't understand bash script, but I know what the comment says. Two questions remain, where they move the `extern` package? How do I import it?

Do not use it. It is not public API. You are not permitted to assume it exists, even if it does coincidentally happen to exist on Ubuntu -- future versions of setuptools may drop it at any time. In fact, setuptools versions 34.0.0 up until 36.0.0 actually did drop it, before reintroducing it due to bootstrapping issues, but they have stated for the record as soon as the bootstrappping issue is fixed, they will drop it once more.

For the modules vendored in setuptools.extern you MUST depend on them like normal modules, and import them like normal modules. There are no ifs, ands, or buts.


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

Board footer

Powered by FluxBB