Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest wheel breaks with setuptools #487

Closed
hloeung opened this issue Nov 8, 2022 · 21 comments
Closed

Latest wheel breaks with setuptools #487

hloeung opened this issue Nov 8, 2022 · 21 comments

Comments

@hloeung
Copy link

hloeung commented Nov 8, 2022

Hi,

The latest wheel seems to break with setuptools in some weird and wonderful way. Downgrading to 0.38.1 seems to work fine.

:: Collecting pip<22.1
::   Downloading pip-22.0.4.tar.gz (2.1 MB)
::   Installing build dependencies: started
::   Installing build dependencies: finished with status 'error'
::   ERROR: Command errored out with exit status 1:
::    command: /root/snap/charmcraft/common/tmp3ttv087k/bin/python /root/snap/charmcraft/common/tmp3ttv087k/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /root/snap/charmcraft/common/pip-build-env-kzb85ngl/overlay --no-warn-script-location --no-binary :all: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel
::        cwd: None
::   Complete output (71 lines):
::   Collecting setuptools
::     Downloading setuptools-65.5.1.tar.gz (2.6 MB)
::     Getting requirements to build wheel: started
::     Getting requirements to build wheel: finished with status 'done'
::     Installing backend dependencies: started
::     Installing backend dependencies: finished with status 'error'
::     ERROR: Command errored out with exit status 1:
::      command: /root/snap/charmcraft/common/tmp3ttv087k/bin/python /root/snap/charmcraft/common/tmp3ttv087k/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /root/snap/charmcraft/common/pip-build-env-plg_blo8/normal --no-warn-script-location --no-binary :all: --only-binary :none: -i https://pypi.org/simple -- wheel
::          cwd: None
::     Complete output (59 lines):
::     Collecting wheel
::       Downloading wheel-0.38.2.tar.gz (66 kB)
::         ERROR: Command errored out with exit status 1:
::          command: /root/snap/charmcraft/common/tmp3ttv087k/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/root/snap/charmcraft/common/pip-install-h3frlauc/wheel/setup.py'"'"'; __file__='"'"'/root/snap/charmcraft/common/pip-install-h3frlauc/wheel/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /root/snap/charmcraft/common/pip-install-h3frlauc/wheel/pip-egg-info
::              cwd: /root/snap/charmcraft/common/pip-install-h3frlauc/wheel/
::         Complete output (51 lines):
::         running egg_info
::         creating /root/snap/charmcraft/common/pip-install-h3frlauc/wheel/pip-egg-info/wheel.egg-info
::         writing /root/snap/charmcraft/common/pip-install-h3frlauc/wheel/pip-egg-info/wheel.egg-info/PKG-INFO
::         writing dependency_links to /root/snap/charmcraft/common/pip-install-h3frlauc/wheel/pip-egg-info/wheel.egg-info/dependency_links.txt
::         writing entry points to /root/snap/charmcraft/common/pip-install-h3frlauc/wheel/pip-egg-info/wheel.egg-info/entry_points.txt
::         writing requirements to /root/snap/charmcraft/common/pip-install-h3frlauc/wheel/pip-egg-info/wheel.egg-info/requires.txt
::         writing top-level names to /root/snap/charmcraft/common/pip-install-h3frlauc/wheel/pip-egg-info/wheel.egg-info/top_level.txt
::         writing manifest file '/root/snap/charmcraft/common/pip-install-h3frlauc/wheel/pip-egg-info/wheel.egg-info/SOURCES.txt'
::         Traceback (most recent call last):
::           File "<string>", line 1, in <module>
::           File "/root/snap/charmcraft/common/pip-install-h3frlauc/wheel/setup.py", line 5, in <module>
::             setup()
::           File "/root/snap/charmcraft/common/tmp3ttv087k/lib/python3.8/site-packages/setuptools/__init__.py", line 145, in setup
::             return distutils.core.setup(**attrs)
::           File "/usr/lib/python3.8/distutils/core.py", line 148, in setup
::             dist.run_commands()
::           File "/usr/lib/python3.8/distutils/dist.py", line 966, in run_commands
::             self.run_command(cmd)
::           File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
::             cmd_obj.run()
::           File "/root/snap/charmcraft/common/tmp3ttv087k/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 296, in run
::             self.find_sources()
::           File "/root/snap/charmcraft/common/tmp3ttv087k/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 303, in find_sources
::             mm.run()
::           File "/root/snap/charmcraft/common/tmp3ttv087k/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 534, in run
::             self.add_defaults()
::           File "/root/snap/charmcraft/common/tmp3ttv087k/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 570, in add_defaults
::             sdist.add_defaults(self)
::           File "/usr/lib/python3.8/distutils/command/sdist.py", line 226, in add_defaults
::             self._add_defaults_python()
::           File "/root/snap/charmcraft/common/tmp3ttv087k/lib/python3.8/site-packages/setuptools/command/sdist.py", line 135, in _add_defaults_python
::             build_py = self.get_finalized_command('build_py')
::           File "/usr/lib/python3.8/distutils/cmd.py", line 299, in get_finalized_command
::             cmd_obj.ensure_finalized()
::           File "/usr/lib/python3.8/distutils/cmd.py", line 107, in ensure_finalized
::             self.finalize_options()
::           File "/root/snap/charmcraft/common/tmp3ttv087k/lib/python3.8/site-packages/setuptools/command/build_py.py", line 34, in finalize_options
::             orig.build_py.finalize_options(self)
::           File "/usr/lib/python3.8/distutils/command/build_py.py", line 43, in finalize_options
::             self.set_undefined_options('build',
::           File "/usr/lib/python3.8/distutils/cmd.py", line 286, in set_undefined_options
::             src_cmd_obj = self.distribution.get_command_obj(src_cmd)
::           File "/usr/lib/python3.8/distutils/dist.py", line 857, in get_command_obj
::             klass = self.get_command_class(command)
::           File "/root/snap/charmcraft/common/tmp3ttv087k/lib/python3.8/site-packages/setuptools/dist.py", line 834, in get_command_class
::             self.cmdclass[command] = cmdclass = ep.load()
::           File "/root/snap/charmcraft/common/tmp3ttv087k/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2443, in load
::             return self.resolve()
::           File "/root/snap/charmcraft/common/tmp3ttv087k/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2449, in resolve
::             module = __import__(self.module_name, fromlist=['__name__'], level=0)
::         ModuleNotFoundError: No module named 'setuptools.command.build'
::         ----------------------------------------
::     ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
::     ----------------------------------------
::   ERROR: Command errored out with exit status 1: /root/snap/charmcraft/common/tmp3ttv087k/bin/python /root/snap/charmcraft/common/tmp3ttv087k/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /root/snap/charmcraft/common/pip-build-env-plg_blo8/normal --no-warn-script-location --no-binary :all: --only-binary :none: -i https://pypi.org/simple -- wheel Check the logs for full command output.
::   ----------------------------------------
:: ERROR: Command errored out with exit status 1: /root/snap/charmcraft/common/tmp3ttv087k/bin/python /root/snap/charmcraft/common/tmp3ttv087k/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /root/snap/charmcraft/common/pip-build-env-kzb85ngl/overlay --no-warn-script-location --no-binary :all: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel Check the logs for full command output.

Any ideas what's going on?

@agronholm
Copy link
Contributor

The only change between 0.38.1 and 0.38.2 is the regression fix for the wheel file name parsing regex. Nothing that would cause a lookup error for setuptools.command.build.

@agronholm
Copy link
Contributor

How do I minimally reproduce this?

@hloeung
Copy link
Author

hloeung commented Nov 8, 2022

Sorry, I mean 0.37.1.

I've been able to reproduce this with deploying a stock Ubuntu Focal VM. Then these commands:

sudo snap install charmcraft --classic
sudo snap install charm --channel 2.x/stable --classic
git clone -b testing https://git.launchpad.net/haw-test-charm
cd haw-test-charm/
make clean; charmcraft pack --destructive-mode --verbosity trace
unzip -l haw-test_ubuntu-20.04-amd64.charm | grep wheelhouse/wheel

Check out wheelhouse.txt, now update the pinning of wheel to wheel=0.38.2 and re-run

make clean; charmcraft pack --destructive-mode --verbosity trace

This fails. But if I use wheel=0.37.1 it's fine.

I'll try see if there's a more minimal way to do so tomorrow.

Thanks for your time, much appreciated.

@agronholm
Copy link
Contributor

Can this be reproduced w/o charmcraft? The biggest change between 0.37.1 and 0.38.0 was that wheel uses setuptools instead of distutils. Could this be related?

@hloeung
Copy link
Author

hloeung commented Nov 8, 2022

Let me get back to you on a way to reproduce it without charmcraft. It's late here where I'm in (Sydney, Australia) so will dig deeper tomorrow.

It may be a circular dependency. In the meantime, would this traceback / error be useful to you somehow?

llecting pip<22.1
  Downloading pip-22.0.4.tar.gz (2.1 MB)
  Installing build dependencies: started
  Installing build dependencies: finished with status 'error'
  ERROR: Command errored out with exit status 1:
   command: /tmp/tmp1gml_d1i/bin/python /tmp/tmp1gml_d1i/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-4adjpvt7/overlay --no-warn-script-location --no-binary :all: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel
       cwd: None
  Complete output (71 lines):
  Collecting setuptools
    Downloading setuptools-65.5.1.tar.gz (2.6 MB)
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'done'
    Installing backend dependencies: started
    Installing backend dependencies: finished with status 'error'
    ERROR: Command errored out with exit status 1:
     command: /tmp/tmp1gml_d1i/bin/python /tmp/tmp1gml_d1i/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-3777pjwz/normal --no-warn-script-location --no-binary :all: --only-binary :none: -i https://pypi.org/simple -- wheel
         cwd: None
    Complete output (59 lines):
    Collecting wheel
      Downloading wheel-0.38.2.tar.gz (66 kB)
        ERROR: Command errored out with exit status 1:
         command: /tmp/tmp1gml_d1i/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-rasfvbql/wheel/setup.py'"'"'; __file__='"'"'/tmp/pip-install-rasfvbql/wheel/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-rasfvbql/wheel/pip-egg-info
             cwd: /tmp/pip-install-rasfvbql/wheel/
        Complete output (51 lines):
        running egg_info
        creating /tmp/pip-install-rasfvbql/wheel/pip-egg-info/wheel.egg-info
        writing /tmp/pip-install-rasfvbql/wheel/pip-egg-info/wheel.egg-info/PKG-INFO
        writing dependency_links to /tmp/pip-install-rasfvbql/wheel/pip-egg-info/wheel.egg-info/dependency_links.txt
        writing entry points to /tmp/pip-install-rasfvbql/wheel/pip-egg-info/wheel.egg-info/entry_points.txt
        writing requirements to /tmp/pip-install-rasfvbql/wheel/pip-egg-info/wheel.egg-info/requires.txt
        writing top-level names to /tmp/pip-install-rasfvbql/wheel/pip-egg-info/wheel.egg-info/top_level.txt
        writing manifest file '/tmp/pip-install-rasfvbql/wheel/pip-egg-info/wheel.egg-info/SOURCES.txt'
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/tmp/pip-install-rasfvbql/wheel/setup.py", line 5, in <module>
            setup()
          File "/tmp/tmp1gml_d1i/lib/python3.8/site-packages/setuptools/__init__.py", line 145, in setup
            return distutils.core.setup(**attrs)
          File "/usr/lib/python3.8/distutils/core.py", line 148, in setup
            dist.run_commands()
          File "/usr/lib/python3.8/distutils/dist.py", line 966, in run_commands
            self.run_command(cmd)
          File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
            cmd_obj.run()
          File "/tmp/tmp1gml_d1i/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 296, in run
            self.find_sources()
          File "/tmp/tmp1gml_d1i/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 303, in find_sources
            mm.run()
          File "/tmp/tmp1gml_d1i/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 534, in run
            self.add_defaults()
          File "/tmp/tmp1gml_d1i/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 570, in add_defaults
            sdist.add_defaults(self)
          File "/usr/lib/python3.8/distutils/command/sdist.py", line 226, in add_defaults
            self._add_defaults_python()
          File "/tmp/tmp1gml_d1i/lib/python3.8/site-packages/setuptools/command/sdist.py", line 135, in _add_defaults_python
            build_py = self.get_finalized_command('build_py')
          File "/usr/lib/python3.8/distutils/cmd.py", line 299, in get_finalized_command
            cmd_obj.ensure_finalized()
          File "/usr/lib/python3.8/distutils/cmd.py", line 107, in ensure_finalized
            self.finalize_options()
          File "/tmp/tmp1gml_d1i/lib/python3.8/site-packages/setuptools/command/build_py.py", line 34, in finalize_options
            orig.build_py.finalize_options(self)
          File "/usr/lib/python3.8/distutils/command/build_py.py", line 43, in finalize_options
            self.set_undefined_options('build',
          File "/usr/lib/python3.8/distutils/cmd.py", line 286, in set_undefined_options
            src_cmd_obj = self.distribution.get_command_obj(src_cmd)
          File "/usr/lib/python3.8/distutils/dist.py", line 857, in get_command_obj
            klass = self.get_command_class(command)
          File "/tmp/tmp1gml_d1i/lib/python3.8/site-packages/setuptools/dist.py", line 834, in get_command_class
            self.cmdclass[command] = cmdclass = ep.load()
          File "/tmp/tmp1gml_d1i/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2443, in load
            return self.resolve()
          File "/tmp/tmp1gml_d1i/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2449, in resolve
            module = __import__(self.module_name, fromlist=['__name__'], level=0)
        ModuleNotFoundError: No module named 'setuptools.command.build'
        ----------------------------------------
    ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
    ----------------------------------------
  ERROR: Command errored out with exit status 1: /tmp/tmp1gml_d1i/bin/python /tmp/tmp1gml_d1i/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-3777pjwz/normal --no-warn-script-location --no-binary :all: --only-binary :none: -i https://pypi.org/simple -- wheel Check the logs for full command output.
  ----------------------------------------
ERROR: Command errored out with exit status 1: /tmp/tmp1gml_d1i/bin/python /tmp/tmp1gml_d1i/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-4adjpvt7/overlay --no-warn-script-location --no-binary :all: --only-binary :none: -i https://pypi.org/simple -- setuptools wheel Check the logs for full command output.

Directly calling make clean; charm build -v rather than via charmcraft.

@agronholm
Copy link
Contributor

It doesn't make sense. Clearly it's able to import pkg_resources, but that is a part of setuptools. How then is it not able to import another part of setuptools?

@hloeung
Copy link
Author

hloeung commented Nov 8, 2022

Okay, here we go:

ubuntu@juju-87625f-hloeung-126:~/haw/haw-test-charm$ virtualenv test
/home/ubuntu/.local/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
created virtual environment CPython3.8.10.final.0-64 in 126ms
  creator CPython3Posix(dest=/home/ubuntu/haw/haw-test-charm/test, clear=False, global=False)
  seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, pkg_resources=latest, via=copy, app_data_dir=/home/ubuntu/.local/share/virtualenv/seed-app-data/v1.0.1.debian.1)
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
ubuntu@juju-87625f-hloeung-126:~/haw/haw-test-charm$ test/bin/activate
-bash: test/bin/activate: Permission denied
ubuntu@juju-87625f-hloeung-126:~/haw/haw-test-charm$ . test/bin/activate
(test) ubuntu@juju-87625f-hloeung-126:~/haw/haw-test-charm$ pip install --ignore-installed --no-binary :all: --only-binary :none: wheel==0.38.2 setuptools==65.5.1
Collecting wheel==0.38.2
  Using cached wheel-0.38.2.tar.gz (66 kB)
    ERROR: Command errored out with exit status 1:
     command: /home/ubuntu/haw/haw-test-charm/test/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-wz8dxaxe/wheel/setup.py'"'"'; __file__='"'"'/tmp/pip-install-wz8dxaxe/wheel/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-wz8dxaxe/wheel/pip-egg-info
         cwd: /tmp/pip-install-wz8dxaxe/wheel/
    Complete output (51 lines):
    running egg_info
    creating /tmp/pip-install-wz8dxaxe/wheel/pip-egg-info/wheel.egg-info
    writing /tmp/pip-install-wz8dxaxe/wheel/pip-egg-info/wheel.egg-info/PKG-INFO
    writing dependency_links to /tmp/pip-install-wz8dxaxe/wheel/pip-egg-info/wheel.egg-info/dependency_links.txt
    writing entry points to /tmp/pip-install-wz8dxaxe/wheel/pip-egg-info/wheel.egg-info/entry_points.txt
    writing requirements to /tmp/pip-install-wz8dxaxe/wheel/pip-egg-info/wheel.egg-info/requires.txt
    writing top-level names to /tmp/pip-install-wz8dxaxe/wheel/pip-egg-info/wheel.egg-info/top_level.txt
    writing manifest file '/tmp/pip-install-wz8dxaxe/wheel/pip-egg-info/wheel.egg-info/SOURCES.txt'
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-wz8dxaxe/wheel/setup.py", line 5, in <module>
        setup()
      File "/home/ubuntu/haw/haw-test-charm/test/lib/python3.8/site-packages/setuptools/__init__.py", line 145, in setup
        return distutils.core.setup(**attrs)
      File "/usr/lib/python3.8/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/lib/python3.8/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/home/ubuntu/haw/haw-test-charm/test/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 296, in run
        self.find_sources()
      File "/home/ubuntu/haw/haw-test-charm/test/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 303, in find_sources
        mm.run()
      File "/home/ubuntu/haw/haw-test-charm/test/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 534, in run
        self.add_defaults()
      File "/home/ubuntu/haw/haw-test-charm/test/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 570, in add_defaults
        sdist.add_defaults(self)
      File "/usr/lib/python3.8/distutils/command/sdist.py", line 226, in add_defaults
        self._add_defaults_python()
      File "/home/ubuntu/haw/haw-test-charm/test/lib/python3.8/site-packages/setuptools/command/sdist.py", line 135, in _add_defaults_python
        build_py = self.get_finalized_command('build_py')
      File "/usr/lib/python3.8/distutils/cmd.py", line 299, in get_finalized_command
        cmd_obj.ensure_finalized()
      File "/usr/lib/python3.8/distutils/cmd.py", line 107, in ensure_finalized
        self.finalize_options()
      File "/home/ubuntu/haw/haw-test-charm/test/lib/python3.8/site-packages/setuptools/command/build_py.py", line 34, in finalize_options
        orig.build_py.finalize_options(self)
      File "/usr/lib/python3.8/distutils/command/build_py.py", line 43, in finalize_options
        self.set_undefined_options('build',
      File "/usr/lib/python3.8/distutils/cmd.py", line 286, in set_undefined_options
        src_cmd_obj = self.distribution.get_command_obj(src_cmd)
      File "/usr/lib/python3.8/distutils/dist.py", line 857, in get_command_obj
        klass = self.get_command_class(command)
      File "/home/ubuntu/haw/haw-test-charm/test/lib/python3.8/site-packages/setuptools/dist.py", line 834, in get_command_class
        self.cmdclass[command] = cmdclass = ep.load()
      File "/home/ubuntu/haw/haw-test-charm/test/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2443, in load
        return self.resolve()
      File "/home/ubuntu/haw/haw-test-charm/test/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2449, in resolve
        module = __import__(self.module_name, fromlist=['__name__'], level=0)
    ModuleNotFoundError: No module named 'setuptools.command.build'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

@agronholm
Copy link
Contributor

Tried the same in a Python 3.8 virtualenv:

$ pip install --no-binary :all: wheel==0.38.2 setuptools==65.5.1
Collecting wheel==0.38.2
  Downloading wheel-0.38.2.tar.gz (66 kB)
     |████████████████████████████████| 66 kB 2.6 MB/s            
  Preparing metadata (setup.py) ... done
Collecting setuptools==65.5.1
  Downloading setuptools-65.5.1.tar.gz (2.6 MB)
     |████████████████████████████████| 2.6 MB 13.8 MB/s            
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Skipping wheel build for wheel, due to binaries being disabled for it.
Building wheels for collected packages: setuptools
  Building wheel for setuptools (pyproject.toml) ... done
  Created wheel for setuptools: filename=setuptools-65.5.1-py3-none-any.whl size=1232712 sha256=a11b0c35ca54cfb1b84070dfe0cfdcffb10791b0ea79a0976754de40707e0bde
  Stored in directory: /home/alex/.cache/pip/wheels/ef/ed/33/76744f3b6621a1cebc2d49d332369f3161ac8a473407b9d58b
Successfully built setuptools
Installing collected packages: wheel, setuptools
    Running setup.py install for wheel ... done
  Attempting uninstall: setuptools
    Found existing installation: setuptools 59.6.0
    Uninstalling setuptools-59.6.0:
      Successfully uninstalled setuptools-59.6.0
Successfully installed setuptools-65.5.1 wheel-0.38.2

@hloeung
Copy link
Author

hloeung commented Nov 8, 2022

Is that with a clean virtualenv?

ubuntu@juju-87625f-hloeung-126:~$ rm -rf test
ubuntu@juju-87625f-hloeung-126:~$ virtualenv test
/home/ubuntu/.local/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
created virtual environment CPython3.8.10.final.0-64 in 122ms
  creator CPython3Posix(dest=/home/ubuntu/test, clear=False, global=False)
  seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, pkg_resources=latest, via=copy, app_data_dir=/home/ubuntu/.local/share/virtualenv/seed-app-data/v1.0.1.debian.1)
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
(reverse-i-search)`ac': pip install --no-c^Che --no-binary :all: wheel==0.38.2 setuptools==65.5.1 -v
ubuntu@juju-87625f-hloeung-126:~$ . test/bin/activate
(test) ubuntu@juju-87625f-hloeung-126:~$ pip install --no-cache --no-binary :all: wheel==0.38.2 setuptools==65.5.1
Collecting wheel==0.38.2
  Downloading wheel-0.38.2.tar.gz (66 kB)
     |████████████████████████████████| 66 kB 791 kB/s
    ERROR: Command errored out with exit status 1:
     command: /home/ubuntu/test/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-109g5zis/wheel/setup.py'"'"'; __file__='"'"'/tmp/pip-install-109g5zis/wheel/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-109g5zis/wheel/pip-egg-info
         cwd: /tmp/pip-install-109g5zis/wheel/
    Complete output (51 lines):
    running egg_info
    creating /tmp/pip-install-109g5zis/wheel/pip-egg-info/wheel.egg-info
    writing /tmp/pip-install-109g5zis/wheel/pip-egg-info/wheel.egg-info/PKG-INFO
    writing dependency_links to /tmp/pip-install-109g5zis/wheel/pip-egg-info/wheel.egg-info/dependency_links.txt
    writing entry points to /tmp/pip-install-109g5zis/wheel/pip-egg-info/wheel.egg-info/entry_points.txt
    writing requirements to /tmp/pip-install-109g5zis/wheel/pip-egg-info/wheel.egg-info/requires.txt
    writing top-level names to /tmp/pip-install-109g5zis/wheel/pip-egg-info/wheel.egg-info/top_level.txt
    writing manifest file '/tmp/pip-install-109g5zis/wheel/pip-egg-info/wheel.egg-info/SOURCES.txt'
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-109g5zis/wheel/setup.py", line 5, in <module>
        setup()
      File "/home/ubuntu/test/lib/python3.8/site-packages/setuptools/__init__.py", line 145, in setup
        return distutils.core.setup(**attrs)
      File "/usr/lib/python3.8/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/usr/lib/python3.8/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/usr/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/home/ubuntu/test/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 296, in run
        self.find_sources()
      File "/home/ubuntu/test/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 303, in find_sources
        mm.run()
      File "/home/ubuntu/test/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 534, in run
        self.add_defaults()
      File "/home/ubuntu/test/lib/python3.8/site-packages/setuptools/command/egg_info.py", line 570, in add_defaults
        sdist.add_defaults(self)
      File "/usr/lib/python3.8/distutils/command/sdist.py", line 226, in add_defaults
        self._add_defaults_python()
      File "/home/ubuntu/test/lib/python3.8/site-packages/setuptools/command/sdist.py", line 135, in _add_defaults_python
        build_py = self.get_finalized_command('build_py')
      File "/usr/lib/python3.8/distutils/cmd.py", line 299, in get_finalized_command
        cmd_obj.ensure_finalized()
      File "/usr/lib/python3.8/distutils/cmd.py", line 107, in ensure_finalized
        self.finalize_options()
      File "/home/ubuntu/test/lib/python3.8/site-packages/setuptools/command/build_py.py", line 34, in finalize_options
        orig.build_py.finalize_options(self)
      File "/usr/lib/python3.8/distutils/command/build_py.py", line 43, in finalize_options
        self.set_undefined_options('build',
      File "/usr/lib/python3.8/distutils/cmd.py", line 286, in set_undefined_options
        src_cmd_obj = self.distribution.get_command_obj(src_cmd)
      File "/usr/lib/python3.8/distutils/dist.py", line 857, in get_command_obj
        klass = self.get_command_class(command)
      File "/home/ubuntu/test/lib/python3.8/site-packages/setuptools/dist.py", line 834, in get_command_class
        self.cmdclass[command] = cmdclass = ep.load()
      File "/home/ubuntu/test/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2443, in load
        return self.resolve()
      File "/home/ubuntu/test/lib/python3.8/site-packages/pkg_resources/__init__.py", line 2449, in resolve
        module = __import__(self.module_name, fromlist=['__name__'], level=0)
    ModuleNotFoundError: No module named 'setuptools.command.build'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
(test) ubuntu@juju-87625f-hloeung-126:~$

@hloeung
Copy link
Author

hloeung commented Nov 8, 2022

Success if I drop the --no-binary :all::

(test) ubuntu@juju-87625f-hloeung-126:~$ pip install --no-cache wheel==0.38.2 setuptools==65.5.1
Collecting wheel==0.38.2
  Downloading wheel-0.38.2-py3-none-any.whl (36 kB)
Collecting setuptools==65.5.1
  Downloading setuptools-65.5.1-py3-none-any.whl (1.2 MB)
     |████████████████████████████████| 1.2 MB 1.1 MB/s
Installing collected packages: wheel, setuptools
  Attempting uninstall: wheel
    Found existing installation: wheel 0.34.2
    Uninstalling wheel-0.34.2:
      Successfully uninstalled wheel-0.34.2
  Attempting uninstall: setuptools
    Found existing installation: setuptools 44.0.0
    Uninstalling setuptools-44.0.0:
      Successfully uninstalled setuptools-44.0.0
Successfully installed setuptools-65.5.1 wheel-0.38.2
(test) ubuntu@juju-87625f-hloeung-126:~$

I'm puzzled. I'll do some more digging. Again, appreciate your time!

@agronholm
Copy link
Contributor

Is that with a clean virtualenv?

Yes, that was with a clean virtualenv.

@facundobatista
Copy link

Hello! Thanks for opening the issue here about this problem. It's 100% reproducible in a clean virtual environment in Ubuntu Focal.

@agronholm
Copy link
Contributor

agronholm commented Nov 8, 2022

How? I have a Ubuntu 22.04 installation and I can't reproduce it:

$ virtualenv testenv
created virtual environment CPython3.10.6.final.0-64 in 104ms
  creator CPython3Posix(dest=/home/alex/testenv, clear=False, no_vcs_ignore=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=/home/alex/.local/share/virtualenv)
    added seed packages: pip==22.0.2, setuptools==59.6.0, wheel==0.37.1
  activators BashActivator,CShellActivator,FishActivator,NushellActivator,PowerShellActivator,PythonActivator
$ source testenv/bin/activate
(testenv) $ pip install --no-cache --no-binary :all: --ignore-installed wheel
Collecting wheel
  Downloading wheel-0.38.2.tar.gz (66 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 66.5/66.5 KB 6.5 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Skipping wheel build for wheel, due to binaries being disabled for it.
Installing collected packages: wheel
  Running setup.py install for wheel ... done
Successfully installed wheel-0.38.2

@agronholm
Copy link
Contributor

Oh, Focal is the code name for the older LTS version, 20.04.

@agronholm
Copy link
Contributor

agronholm commented Nov 8, 2022

A-ha, I was able to repro the issue with the ubuntu:20.04 Docker image.

@facundobatista
Copy link

Yes, sorry! Ubuntu 20.04.

The problem does not happen in Ubuntu 22.04 because setuptools there is "modern enough" to know how to deal with latest wheel changes.

@agronholm
Copy link
Contributor

agronholm commented Nov 8, 2022

I found that I can't even do python setup.py egg_info in the checked out wheel project without triggering this issue. The traceback does not contain any references to wheel, and wheel's setup.py is pretty bare bones and not all that different compared to v0.37.1. So, I'm stumped.

@agronholm
Copy link
Contributor

Strangely, if I remove the setup_requires = setuptools >= 45.2.0 line from setup.cfg, it works fine.

@agronholm
Copy link
Contributor

Did some further testing. Whenever setup_requires points to a setuptools version higher than what is already installed, it crashes with ModuleNotFoundError: No module named 'setuptools.command.build', even on v0.37.1. So the only reason v0.37.1 works on Ubuntu 20.04 is that the setuptools version that comes with it is recent enough to satisfy the setup_requires condition.

@agronholm
Copy link
Contributor

So, setuptools.command.build was introduced in setuptools v62.4.0. It looks like the required setuptools version is being downloaded, but somehow not used on sys.path. It's rather bizarre. The only fix I can think of is ditching setup_requires entirely and hoping it doesn't cause issues elsewhere.

As a side note, I checked if Ubuntu 18.04 (which should still be supported) can install wheel with --no-binary wheel, and turns out it cannot: UnicodeEncodeError: 'ascii' codec can't encode characters in position 70-72: ordinal not in range(128). Oddly, nobody has been complaining about that.

@hloeung
Copy link
Author

hloeung commented Nov 8, 2022

Thank you @agronholm !

hswong3i added a commit to alvistack/pagure.io-python-daemon that referenced this issue Oct 27, 2024
`setuptools.command.build` was introduced since 62.4.0 (see
pypa/wheel#487 (comment)), which
require Python >= 3.7.

Fixes https://pagure.io/python-daemon/issue/74
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants