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

ImportError attempting to build ordered-set #39

Closed
jaraco opened this issue Nov 15, 2021 · 5 comments
Closed

ImportError attempting to build ordered-set #39

jaraco opened this issue Nov 15, 2021 · 5 comments

Comments

@jaraco
Copy link
Contributor

jaraco commented Nov 15, 2021

In pypa/setuptools#2825, I'm exploring using vendoring for setuptools.

In pypa/setuptools@3ac1982, I've added a vendoring config, but when I run sync, it fails with:

setuptools main $ vendoring sync
Working in .
Load configuration... Done!
Clean existing libraries... Done!
Add vendored libraries... Done!
Fetch licenses...  
  Running pip download -r setuptools/_vendor/vendored.txt --no-deps --dest /var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/vendoring-downloads
    Collecting packaging==21.2
      Using cached packaging-21.2-py3-none-any.whl (40 kB)
    Collecting pyparsing==2.2.1
      Using cached pyparsing-2.2.1-py2.py3-none-any.whl (57 kB)
    Collecting ordered-set==3.1.1
      Using cached ordered-set-3.1.1.tar.gz (10 kB)
      Preparing metadata (setup.py): started
      Preparing metadata (setup.py): finished with status 'error'
      ERROR: Command errored out with exit status 1:
       command: /usr/local/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-download-p2bjbdg5/ordered-set_63d893da93b94449b92f2e25829b487b/setup.py'"'"'; __file__='"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-download-p2bjbdg5/ordered-set_63d893da93b94449b92f2e25829b487b/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 /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-pip-egg-info-av8n3k88
           cwd: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-download-p2bjbdg5/ordered-set_63d893da93b94449b92f2e25829b487b/
      Complete output (5 lines):
      Traceback (most recent call last):
        File "<string>", line 1, in <module>
        File "/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-download-p2bjbdg5/ordered-set_63d893da93b94449b92f2e25829b487b/setup.py", line 1, in <module>
          from setuptools import setup
      ImportError: cannot import name 'setup' from 'setuptools' (unknown location)
      ----------------------------------------
    WARNING: Discarding https://files.pythonhosted.org/packages/a3/b7/d4d69641cbe707a45c23b190f2d717466ba5accc4c70b5f7a8a450387895/ordered-set-3.1.1.tar.gz#sha256=a7bfa858748c73b096e43db14eb23e2bc714a503f990c89fac8fab9b0ee79724 (from https://pypi.org/simple/ordered-set/) (requires-python:>=2.7). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
    ERROR: Could not find a version that satisfies the requirement ordered-set==3.1.1 (from versions: 1.0.1, 1.1, 1.2, 1.3, 1.3.1, 1.4.0, 2.0.0, 2.0.1, 2.0.2, 3.0.0, 3.0.1, 3.0.2, 3.1, 3.1.1, 4.0.1, 4.0.2)
    ERROR: No matching distribution found for ordered-set==3.1.1
  Command exited with non-zero exit code: 1

It seems something about how vendoring is invoking pip isn't compatible with ordered-set when invoked from the setuptools directory. This issue isn't encountered when running paver update_vendored in the project.

@pradyunsg
Copy link
Owner

Do you not have setuptools installed?

@jaraco
Copy link
Contributor Author

jaraco commented Nov 15, 2021

In general, I try not to install Setuptools and to report issues when the dependency is declared implicitly. In this specific case, I've installed vendoring with pipx, which does seem to end up with setuptools:

~ $ .local/pipx/venvs/vendoring/bin/python -m pip list
Package            Version
------------------ ---------
attrs              21.2.0
certifi            2021.10.8
charset-normalizer 2.0.7
click              8.0.3
colorama           0.4.4
commonmark         0.9.1
idna               3.3
jsonschema         4.2.1
packaging          20.4
pip                21.3.1
Pygments           2.10.0
pyparsing          2.4.7
pyrsistent         0.18.0
requests           2.26.0
rich               10.13.0
setuptools         58.5.3
six                1.15.0
toml               0.10.2
urllib3            1.26.7
vendoring          1.2.0
wheel              0.37.0

Otherwise, I haven't done anything special but invoke vendoring sync.

@pradyunsg
Copy link
Owner

Is this still an issue?

@jaraco
Copy link
Contributor Author

jaraco commented Jan 14, 2022

Yes. The issue still occurs, depending on what pip resolves to in my environment. If it resolves to an environment with Setuptools, the command succeeds. If it resolves to an environment without setuptools installed, the build of ordered-set fails.

For example, when I run the download command directly, it fails with a similar error:

$ pip download ordered-set==3.1.1
setuptools feature/vendoring $ pip download ordered-set==3.1.1
Collecting ordered-set==3.1.1
  Using cached ordered-set-3.1.1.tar.gz (10 kB)
  Preparing metadata (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/local/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-download-7k1zoxxy/ordered-set_0354c06d693f4b3db8874694fc831765/setup.py'"'"'; __file__='"'"'/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-download-7k1zoxxy/ordered-set_0354c06d693f4b3db8874694fc831765/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 /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-pip-egg-info-yzt9ot6i
       cwd: /private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-download-7k1zoxxy/ordered-set_0354c06d693f4b3db8874694fc831765/
  Complete output (5 lines):
  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/private/var/folders/c6/v7hnmq453xb6p2dbz1gqc6rr0000gn/T/pip-download-7k1zoxxy/ordered-set_0354c06d693f4b3db8874694fc831765/setup.py", line 1, in <module>
      from setuptools import setup
  ImportError: cannot import name 'setup' from 'setuptools' (unknown location)
  ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/a3/b7/d4d69641cbe707a45c23b190f2d717466ba5accc4c70b5f7a8a450387895/ordered-set-3.1.1.tar.gz#sha256=a7bfa858748c73b096e43db14eb23e2bc714a503f990c89fac8fab9b0ee79724 (from https://pypi.org/simple/ordered-set/) (requires-python:>=2.7). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement ordered-set==3.1.1 (from versions: 1.0.1, 1.1, 1.2, 1.3, 1.3.1, 1.4.0, 2.0.0, 2.0.1, 2.0.2, 3.0.0, 3.0.1, 3.0.2, 3.1, 3.1.1, 4.0.1, 4.0.2)
ERROR: No matching distribution found for ordered-set==3.1.1

Probably vendoring shouldn't be relying on pip as resolved in the path, but should instead be invoking [sys.executable, '-m', 'pip'] and to ensure that setuptools is installed there... or better use --use-pep517 to not rely on the implicit dependency.

@pradyunsg
Copy link
Owner

We’ve moved away from this in newer pip versions, automatically using pyproject.toml-based builds when setuptools isn’t available in the environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants