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

[BUG] KeyError: 'unix_user' with setuptools 60.0.0 #2938

Closed
1 task done
yashk2810 opened this issue Dec 20, 2021 · 15 comments · Fixed by #2944
Closed
1 task done

[BUG] KeyError: 'unix_user' with setuptools 60.0.0 #2938

yashk2810 opened this issue Dec 20, 2021 · 15 comments · Fixed by #2944
Labels
bug Needs Triage Issues that need to be evaluated for severity and status.

Comments

@yashk2810
Copy link

setuptools version

setuptools-60.0.0

Python version

Python 3.9

OS

Ubuntu 18.04

Additional environment information

No response

Description

Getting this error with setuptools 60.0.0

Traceback (most recent call last):
File "", line 1, in
File "/tmpfs/src/github/jax/setup.py", line 31, in
setup(
File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/init.py", line 153, in setup
return distutils.core.setup(**attrs)
File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 148, in setup
return run_commands(dist)
File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 163, in run_commands
dist.run_commands()
File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 967, in run_commands
self.run_command(cmd)
File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 985, in run_command
cmd_obj.ensure_finalized()
File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 107, in ensure_finalized
self.finalize_options()
File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/command/develop.py", line 52, in finalize_options
easy_install.finalize_options(self)
File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/command/easy_install.py", line 263, in finalize_options
self._fix_install_dir_for_user_site()
File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/command/easy_install.py", line 375, in _fix_install_dir_for_user_site
self.select_scheme(scheme_name)
File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/command/easy_install.py", line 716, in select_scheme
scheme = INSTALL_SCHEMES[name]
KeyError: 'unix_user'
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python3.9 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmpfs/src/github/jax/setup.py'"'"'; file='"'"'/tmpfs/src/github/jax/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'"'"'))' develop --no-deps --user --prefix= Check the logs for full command output.

Expected behavior

The Error should not happen. It was working fine with setuptools 59.8.0

How to Reproduce

  1. git clone https://github.com/google/jax.git
  2. cd jax
  3. python3.9 -m pip install -e .

Make sure the setuptools version in 60.0.0

Output

Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmpfs/src/github/jax/setup.py", line 31, in <module>
        setup(
      File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/__init__.py", line 153, in setup
        return distutils.core.setup(**attrs)
      File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 148, in setup
        return run_commands(dist)
      File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 163, in run_commands
        dist.run_commands()
      File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 967, in run_commands
        self.run_command(cmd)
      File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 985, in run_command
        cmd_obj.ensure_finalized()
      File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 107, in ensure_finalized
        self.finalize_options()
      File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/command/develop.py", line 52, in finalize_options
        easy_install.finalize_options(self)
      File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/command/easy_install.py", line 263, in finalize_options
        self._fix_install_dir_for_user_site()
      File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/command/easy_install.py", line 375, in _fix_install_dir_for_user_site
        self.select_scheme(scheme_name)
      File "/home/kbuilder/.local/lib/python3.9/site-packages/setuptools/command/easy_install.py", line 716, in select_scheme
        scheme = INSTALL_SCHEMES[name]
    KeyError: 'unix_user'
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/local/bin/python3.9 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmpfs/src/github/jax/setup.py'"'"'; __file__='"'"'/tmpfs/src/github/jax/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'"'"'))' develop --no-deps --user --prefix= Check the logs for full command output.

Code of Conduct

  • I agree to follow the PSF Code of Conduct
@yashk2810 yashk2810 added bug Needs Triage Issues that need to be evaluated for severity and status. labels Dec 20, 2021
@yashk2810 yashk2810 changed the title [BUG] [BUG] KeyError: 'unix_user' with setuptools 60.0.0 Dec 20, 2021
@yashk2810
Copy link
Author

@jaraco

@jaraco
Copy link
Member

jaraco commented Dec 20, 2021

I’ll explore this soon. I suspect the issue is that there is some gap in how the install schemes are resolved on your platform. The quick fix will be to pin to Setuptools <60 or set SETUPTOOLS_USE_DISTUTILS=stdlib as a workaround in the interim.

@jaraco
Copy link
Member

jaraco commented Dec 20, 2021

I see that the issue is due to easy_install and is probably due to the fact that the easy_install module imports, manipulates, and consumes the INSTALL_SCHEMES from distutils, with some of the code being copy-pasted from there.

@jaraco
Copy link
Member

jaraco commented Dec 20, 2021

As a reminder, easy_install is deprecated. I'll try to find a solution for this issue, as it was unintended breakage.

Edit: I also recognize now that no-one has invoked easy_install, but instead is using the preferred pip install -e, which incidentally uses easy_install, so I retract the advice.

@jaraco
Copy link
Member

jaraco commented Dec 20, 2021

I've been unsuccessful triggering the issue in a virtualenv. It seems the issue is related to the implicit --user install created by pip, which I'm unable to trigger manually.

I was able to trigger the issue thus:

draft $ rm -rf jax; git clone -q gh://google/jax
draft $ $PYTHONUSERBASE=@($(pwd).strip() + '/userbase') pip-run -q setuptools==60 -- -m pip install --user --no-deps -e jax
Obtaining file:///Users/jaraco/draft/jax
  Preparing metadata (setup.py) ... done
Installing collected packages: jax
  Running setup.py develop for jax
    ERROR: Command errored out with exit status 1:
     command: /Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/Users/jaraco/draft/jax/setup.py'"'"'; __file__='"'"'/Users/jaraco/draft/jax/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'"'"'))' develop --no-deps --user --prefix=
         cwd: /Users/jaraco/draft/jax/
    Complete output (28 lines):
    running develop
    /var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-run-4s2jnu9r/setuptools/command/easy_install.py:156: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
      warnings.warn(
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/Users/jaraco/draft/jax/setup.py", line 31, in <module>
        setup(
      File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-run-4s2jnu9r/setuptools/__init__.py", line 153, in setup
        return distutils.core.setup(**attrs)
      File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-run-4s2jnu9r/setuptools/_distutils/core.py", line 148, in setup
        return run_commands(dist)
      File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-run-4s2jnu9r/setuptools/_distutils/core.py", line 163, in run_commands
        dist.run_commands()
      File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-run-4s2jnu9r/setuptools/_distutils/dist.py", line 967, in run_commands
        self.run_command(cmd)
      File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-run-4s2jnu9r/setuptools/_distutils/dist.py", line 985, in run_command
        cmd_obj.ensure_finalized()
      File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-run-4s2jnu9r/setuptools/_distutils/cmd.py", line 107, in ensure_finalized
        self.finalize_options()
      File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-run-4s2jnu9r/setuptools/command/develop.py", line 52, in finalize_options
        easy_install.finalize_options(self)
      File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-run-4s2jnu9r/setuptools/command/easy_install.py", line 263, in finalize_options
        self._fix_install_dir_for_user_site()
      File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-run-4s2jnu9r/setuptools/command/easy_install.py", line 375, in _fix_install_dir_for_user_site
        self.select_scheme(scheme_name)
      File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-run-4s2jnu9r/setuptools/command/easy_install.py", line 716, in select_scheme
        scheme = INSTALL_SCHEMES[name]
    KeyError: 'unix_user'
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/Users/jaraco/draft/jax/setup.py'"'"'; __file__='"'"'/Users/jaraco/draft/jax/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'"'"'))' develop --no-deps --user --prefix= Check the logs for full command output.

@jaraco
Copy link
Member

jaraco commented Dec 20, 2021

Fix released as 60.0.1. Please test and report back.

@jcpunk
Copy link

jcpunk commented Dec 20, 2021

I'm still showing the bug up here after Successfully installed setuptools-60.0.1 wheel-0.37.0

https://github.com/HEPCloud/decisionengine/runs/4586741107?check_suite_focus=true

@jaraco jaraco reopened this Dec 20, 2021
@jaraco
Copy link
Member

jaraco commented Dec 20, 2021

Confirmed. I can replicate the issue on Python 3.9.

draft $ $PYTHONUSERBASE=@($(pwd).strip() + '/userbase') py -3.9 -m pip-run -q setuptools==60.0.1 -- -m pip install --user --no-deps -e jax
Obtaining file:///Users/jaraco/draft/jax
  Preparing metadata (setup.py) ... done
Installing collected packages: jax
  Running setup.py develop for jax
    ERROR: Command errored out with exit status 1:
     command: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/Users/jaraco/draft/jax/setup.py'"'"'; __file__='"'"'/Users/jaraco/draft/jax/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'"'"'))' develop --no-deps --user --prefix=
         cwd: /Users/jaraco/draft/jax/
    Complete output (32 lines):
    running develop
    /var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-run-p5t810vq/setuptools/command/easy_install.py:156: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
      warnings.warn(
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/Users/jaraco/draft/jax/setup.py", line 31, in <module>
        setup(
      File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-run-p5t810vq/setuptools/__init__.py", line 153, in setup
        return distutils.core.setup(**attrs)
      File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-run-p5t810vq/setuptools/_distutils/core.py", line 148, in setup
        return run_commands(dist)
      File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-run-p5t810vq/setuptools/_distutils/core.py", line 163, in run_commands
        dist.run_commands()
      File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-run-p5t810vq/setuptools/_distutils/dist.py", line 967, in run_commands
        self.run_command(cmd)
      File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-run-p5t810vq/setuptools/_distutils/dist.py", line 985, in run_command
        cmd_obj.ensure_finalized()
      File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-run-p5t810vq/setuptools/_distutils/cmd.py", line 107, in ensure_finalized
        self.finalize_options()
      File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-run-p5t810vq/setuptools/command/develop.py", line 52, in finalize_options
        easy_install.finalize_options(self)
      File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-run-p5t810vq/setuptools/command/easy_install.py", line 270, in finalize_options
        self._fix_install_dir_for_user_site()
      File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-run-p5t810vq/setuptools/command/easy_install.py", line 382, in _fix_install_dir_for_user_site
        self.select_scheme(scheme_name)
      File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-run-p5t810vq/setuptools/command/easy_install.py", line 722, in select_scheme
        install._select_scheme(self, name)
      File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-run-p5t810vq/setuptools/_distutils/command/install.py", line 127, in _select_scheme
        vars(ob).update(_remove_set(ob, _scheme_attrs(_resolve_scheme(name))))
      File "/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-run-p5t810vq/setuptools/_distutils/command/install.py", line 152, in _scheme_attrs
        scheme = _load_schemes()[name]
    KeyError: 'unix_user'
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/Users/jaraco/draft/jax/setup.py'"'"'; __file__='"'"'/Users/jaraco/draft/jax/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'"'"'))' develop --no-deps --user --prefix= Check the logs for full command output.

Although I'd tested the fix on Python 3.10, it seems there's an additional issue that on Python 3.9, there's no sysconfig.get_preferred_scheme, so unix_user is chosen (?), but the schemes are there for posix_user.

@jaraco jaraco closed this as completed in edf116b Dec 20, 2021
@jaraco
Copy link
Member

jaraco commented Dec 20, 2021

60.0.2 is now released with edf116b, which should fix the issue (at least in my testing). Please test and confirm.

@jcpunk
Copy link

jcpunk commented Dec 20, 2021

works for me

@mxmlnkn
Copy link

mxmlnkn commented Jul 16, 2022

I still have this problem on Ubuntu 22.04 with Python 3.10 and setuptools 63.2.0 installed. Is that normal?

Edit: I tried a lot of different versions of setuptools: 59,60,61,63 and none works. It works when using python3 setup.py develop --user instead of python3 -m pip install --user --editable.

Note that I also have to use the site.ENABLE_USER_SITE = "--user" in sys.argv[1:] workaround described in this pip issue. It seems to me like installing a development version becomes increasingly impossible.

Obtaining file:///projects/ratarmount/worktrees/1/core
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Installing collected packages: ratarmountcore
  Running setup.py develop for ratarmountcore
    error: subprocess-exited-with-error
    
    × python setup.py develop did not run successfully.
    │ exit code: 1
    ╰─> [29 lines of output]
        running develop
        /usr/lib/python3/dist-packages/setuptools/command/easy_install.py:158: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
          warnings.warn(
        Traceback (most recent call last):
          File "<string>", line 2, in <module>
          File "<pip-setuptools-caller>", line 34, in <module>
          File "/projects/ratarmount/worktrees/1/core/setup.py", line 11, in <module>
            setup()
          File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 153, in setup
            return distutils.core.setup(**attrs)
          File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 148, in setup
            return run_commands(dist)
          File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 163, in run_commands
            dist.run_commands()
          File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 967, in run_commands
            self.run_command(cmd)
          File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 985, in run_command
            cmd_obj.ensure_finalized()
          File "/usr/lib/python3/dist-packages/setuptools/_distutils/cmd.py", line 107, in ensure_finalized
            self.finalize_options()
          File "/usr/lib/python3/dist-packages/setuptools/command/develop.py", line 52, in finalize_options
            easy_install.finalize_options(self)
          File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 270, in finalize_options
            self._fix_install_dir_for_user_site()
          File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 400, in _fix_install_dir_for_user_site
            self.select_scheme(scheme_name)
          File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 741, in select_scheme
            scheme = INSTALL_SCHEMES[name]
        KeyError: 'unix_user'
        [end of output]
    
    note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× python setup.py develop did not run successfully.
│ exit code: 1
╰─> [29 lines of output]
    running develop
    /usr/lib/python3/dist-packages/setuptools/command/easy_install.py:158: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
      warnings.warn(
    Traceback (most recent call last):
      File "<string>", line 2, in <module>
      File "<pip-setuptools-caller>", line 34, in <module>
      File "/projects/ratarmount/worktrees/1/core/setup.py", line 11, in <module>
        setup()
      File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 153, in setup
        return distutils.core.setup(**attrs)
      File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 148, in setup
        return run_commands(dist)
      File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 163, in run_commands
        dist.run_commands()
      File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 967, in run_commands
        self.run_command(cmd)
      File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 985, in run_command
        cmd_obj.ensure_finalized()
      File "/usr/lib/python3/dist-packages/setuptools/_distutils/cmd.py", line 107, in ensure_finalized
        self.finalize_options()
      File "/usr/lib/python3/dist-packages/setuptools/command/develop.py", line 52, in finalize_options
        easy_install.finalize_options(self)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 270, in finalize_options
        self._fix_install_dir_for_user_site()
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 400, in _fix_install_dir_for_user_site
        self.select_scheme(scheme_name)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 741, in select_scheme
        scheme = INSTALL_SCHEMES[name]
    KeyError: 'unix_user'
    [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.

@CroMarmot
Copy link

Same

Ubuntu 22.04.1(Linux 5.15.0-47-generic)

setuptools 65.3.0

Python 3.10.4

pip 22.2.2

setup.py

import site
import sys
from setuptools import setup
site.ENABLE_USER_SITE = "--user" in sys.argv[1:] # https://github.com/pypa/pip/issues/7953#issuecomment-645133255

setup()

pyproject.toml

[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"

[project]
name = "yxr-oi-cli"
description = "Simple Online Judge Cli Tool"
version = "0.0.1"
authors = [
  { name="YeXiaoRain", email="[email protected]" }
]
dependencies = [
  "requests >= 2",
  "beautifulsoup4 >= 4",
  "lxml >= 4",
  "pycryptodome >= 3.13.0",
  "click >= 8.1.3",
  "rich >= 11.0.0",
  "yxr-atcoder-core >= 0.0.1",
]
readme = "README.md"
requires-python = ">=3.7"
classifiers = [
  "Programming Language :: Python :: 3",
  "License :: OSI Approved :: MIT License",
]
keywords = ["atcoder", "cli", "api", "yxr"]
license = { file="LICENSE" }

[project.urls]
"Homepage" = "https://github.com/CroMarmot/oiTerminal"
"Bug Tracker" = "https://github.com/CroMarmot/oiTerminal/issues"

[project.scripts]
oi = "oi_cli2.cli.main:main"

[project.optional-dependencies]
tests = [
  'build',
  'coverage >= 6',
  'pytest >= 7',
]

[tool.setuptools.packages.find]
where = ["."] # default "."
include = ["oi_cli2"] # ["*"] by default
exclude = ["TODO.md", "tests", "docs"] # empty by default
namespaces = true # true by default

[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-ra -q"
testpaths = [
  "tests",
]

[tool.yapf]
based_on_style = "pep8"
column_limit = 9999
indent_width = 2

output

pip3 install --user -e .
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Obtaining file:///home/cromarmot/Documents/computer/oiTerminalv2dev
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Installing collected packages: UNKNOWN
  Running setup.py develop for UNKNOWN
    error: subprocess-exited-with-error
    
    × python setup.py develop did not run successfully.
    │ exit code: 1
    ╰─> [29 lines of output]
        running develop
        /usr/lib/python3/dist-packages/setuptools/command/easy_install.py:158: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
          warnings.warn(
        Traceback (most recent call last):
          File "<string>", line 2, in <module>
          File "<pip-setuptools-caller>", line 34, in <module>
          File "/home/cromarmot/Documents/computer/oiTerminalv2dev/setup.py", line 6, in <module>
            setup()
          File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 153, in setup
            return distutils.core.setup(**attrs)
          File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 148, in setup
            return run_commands(dist)
          File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 163, in run_commands
            dist.run_commands()
          File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 967, in run_commands
            self.run_command(cmd)
          File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 985, in run_command
            cmd_obj.ensure_finalized()
          File "/usr/lib/python3/dist-packages/setuptools/_distutils/cmd.py", line 107, in ensure_finalized
            self.finalize_options()
          File "/usr/lib/python3/dist-packages/setuptools/command/develop.py", line 52, in finalize_options
            easy_install.finalize_options(self)
          File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 270, in finalize_options
            self._fix_install_dir_for_user_site()
          File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 400, in _fix_install_dir_for_user_site
            self.select_scheme(scheme_name)
          File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 741, in select_scheme
            scheme = INSTALL_SCHEMES[name]
        KeyError: 'unix_user'
        [end of output]
    
    note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error

× python setup.py develop did not run successfully.
│ exit code: 1
╰─> [29 lines of output]
    running develop
    /usr/lib/python3/dist-packages/setuptools/command/easy_install.py:158: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
      warnings.warn(
    Traceback (most recent call last):
      File "<string>", line 2, in <module>
      File "<pip-setuptools-caller>", line 34, in <module>
      File "/home/cromarmot/Documents/computer/oiTerminalv2dev/setup.py", line 6, in <module>
        setup()
      File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 153, in setup
        return distutils.core.setup(**attrs)
      File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 148, in setup
        return run_commands(dist)
      File "/usr/lib/python3/dist-packages/setuptools/_distutils/core.py", line 163, in run_commands
        dist.run_commands()
      File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 967, in run_commands
        self.run_command(cmd)
      File "/usr/lib/python3/dist-packages/setuptools/_distutils/dist.py", line 985, in run_command
        cmd_obj.ensure_finalized()
      File "/usr/lib/python3/dist-packages/setuptools/_distutils/cmd.py", line 107, in ensure_finalized
        self.finalize_options()
      File "/usr/lib/python3/dist-packages/setuptools/command/develop.py", line 52, in finalize_options
        easy_install.finalize_options(self)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 270, in finalize_options
        self._fix_install_dir_for_user_site()
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 400, in _fix_install_dir_for_user_site
        self.select_scheme(scheme_name)
      File "/usr/lib/python3/dist-packages/setuptools/command/easy_install.py", line 741, in select_scheme
        scheme = INSTALL_SCHEMES[name]
    KeyError: 'unix_user'
    [end of output]

@CroMarmot
Copy link

this link solved for me #3269 (comment)

It looks like it using a python3-setuptool from Ubuntu apt instead of pip

sudo apt purge python3-setuptools

@mxmlnkn
Copy link

mxmlnkn commented Sep 9, 2022

@CroMarmot Thanks, that makes sense but I would count it as a bug that the system-installed older setuptools has precedence. Also, purging pytho3n-setuptools is not an option for me, it also removes pip and makes my python installation wholly unusable.

Alternatively, you can setup a venv (do not use the --system-site-packages option) and update setuptools inside there. Then the editable install will use the correct setuptools version. However, then you also have to install your project into that venv, which I find cumbersome.

I found yet another workaround mentioned here. So, you would install it like this: python3 -m pip install --user --editable --no-build-isolation. I think I prefer this over executing setup.py directly.

But, alas, my original point still stands. The hoops you have to jump through to set up a development version are not amusing.

@CroMarmot
Copy link

it always working correctly in venv in my system

as for it will remove python3-pip when purging python3-setuptools, I've tried some weird way to solve it, and it works in docker

docker run -it --rm ubuntu /bin/bash
apt update && apt install python3 python3-pip -y
useradd -m demouser
su demouser
pip list --outdated
        Package    Version Latest Type
        ---------- ------- ------ -----
        pip        22.0.2  22.2.2 wheel
        setuptools 59.6.0  65.3.0 wheel
pip install --upgrade pip setuptools
        Defaulting to user installation because normal site-packages is not writeable
        Requirement already satisfied: pip in /usr/lib/python3/dist-packages (22.0.2)
        Collecting pip
          Downloading pip-22.2.2-py3-none-any.whl (2.0 MB)
             ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.0/2.0 MB 94.0 kB/s eta 0:00:00
        Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (59.6.0)
        Collecting setuptools
          Downloading setuptools-65.3.0-py3-none-any.whl (1.2 MB)
             ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.2/1.2 MB 78.1 kB/s eta 0:00:00
        Installing collected packages: setuptools, pip
          WARNING: The scripts pip, pip3 and pip3.10 are installed in '/home/demouser/.local/bin' which is not on PATH.
          Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
        Successfully installed pip-22.2.2 setuptools-65.3.0
exit
apt purge python3-pip -y && apt autoremove -y
pip list
        bash: pip: command not found
su demouser
export PATH=~/.local/bin:$PATH
pip list
        Package    Version
        ---------- -------
        pip        22.2.2
        setuptools 65.3.0

docker ubuntu version: ubuntu@sha256:20fa2d7bb4de7723f542be5923b06c4d704370f0390e4ae9e1c833c8785644c1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Needs Triage Issues that need to be evaluated for severity and status.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants