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

pip install -e . fails with version = attr: pkg.__version__ in setup.cfg #6350

Closed
kohr-h opened this issue Mar 19, 2019 · 3 comments
Closed
Labels
auto-locked Outdated issues that have been locked by automation resolution: wrong project Should be reported elsewhere type: support User Support

Comments

@kohr-h
Copy link

kohr-h commented Mar 19, 2019

Environment

  • pip version: 19.0.3
  • Python version: CPython 3.7.2
  • OS: Linux

Description
When a package has version = attr: pkg.__version__ in its setup.cfg file, pip install -e . can fail with an ImportError if not all runtime dependencies have been installed yet.

Expected behavior
Runtime dependencies should be installed first, and after that the version should be determined. (At least that would fix the problem.) Or something else that would make the command succeed and the package with correct version and dependencies installed.

How to Reproduce
I've created a minimal repo to reproduce the error: https://github.com/kohr-h/minimal

Reproducing the error:

  • Create a fresh environment with python and pip inside, but without numpy (our example dependency)
  • Run pip install -e . in the repo root

Workaround:

  • Install numpy as well
  • Now pip install -e . succeeds

Output

Failure case:

Obtaining file:///home/hkohr/git/minimal
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/home/hkohr/git/minimal/setup.py", line 3, in <module>
        setup()
      File "/home/hkohr/miniconda/envs/tmp/lib/python3.7/site-packages/setuptools/__init__.py", line 145, in setup
        return distutils.core.setup(**attrs)
      File "/home/hkohr/miniconda/envs/tmp/lib/python3.7/distutils/core.py", line 121, in setup
        dist.parse_config_files()
      File "/home/hkohr/miniconda/envs/tmp/lib/python3.7/site-packages/setuptools/dist.py", line 705, in parse_config_files
        ignore_option_errors=ignore_option_errors)
      File "/home/hkohr/miniconda/envs/tmp/lib/python3.7/site-packages/setuptools/config.py", line 120, in parse_configuration
        meta.parse()
      File "/home/hkohr/miniconda/envs/tmp/lib/python3.7/site-packages/setuptools/config.py", line 425, in parse
        section_parser_method(section_options)
      File "/home/hkohr/miniconda/envs/tmp/lib/python3.7/site-packages/setuptools/config.py", line 398, in parse_section
        self[name] = value
      File "/home/hkohr/miniconda/envs/tmp/lib/python3.7/site-packages/setuptools/config.py", line 183, in __setitem__
        value = parser(value)
      File "/home/hkohr/miniconda/envs/tmp/lib/python3.7/site-packages/setuptools/config.py", line 513, in _parse_version
        version = self._parse_attr(value, self.package_dir)
      File "/home/hkohr/miniconda/envs/tmp/lib/python3.7/site-packages/setuptools/config.py", line 348, in _parse_attr
        module = import_module(module_name)
      File "/home/hkohr/miniconda/envs/tmp/lib/python3.7/importlib/__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
      File "<frozen importlib._bootstrap>", line 983, in _find_and_load
      File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 728, in exec_module
      File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
      File "/home/hkohr/git/minimal/minimal/__init__.py", line 2, in <module>
        from . import mod
      File "/home/hkohr/git/minimal/minimal/mod.py", line 1, in <module>
        import numpy
    ModuleNotFoundError: No module named 'numpy'
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /home/hkohr/git/minimal/
@pfmoore
Copy link
Member

pfmoore commented Mar 19, 2019

install_requires is processed by setuptools, not pip, so this seems like it's a setuptools issue.

To handle this within pip, you should try using pyproject.toml:

[build-system]
requires = ['setuptools', 'wheel', 'numpy']

(and remove install_requires from setup.cfg)

@kohr-h
Copy link
Author

kohr-h commented Mar 19, 2019

Thanks for the quick reply, @pfmoore. I'll check with setuptools whether it's a known issue.

@pradyunsg pradyunsg added the S: needs triage Issues/PRs that need to be triaged label Jun 22, 2019
@chrahunt chrahunt added resolution: wrong project Should be reported elsewhere type: support User Support labels Sep 1, 2019
@triage-new-issues triage-new-issues bot removed the S: needs triage Issues/PRs that need to be triaged label Sep 1, 2019
@chrahunt
Copy link
Member

chrahunt commented Sep 1, 2019

Hello. It looks like further advice was given over on the setuptools issue so I will close this one, but please let us know if you have any other issues. Thanks!

@chrahunt chrahunt closed this as completed Sep 1, 2019
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Oct 1, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation resolution: wrong project Should be reported elsewhere type: support User Support
Projects
None yet
Development

No branches or pull requests

4 participants