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 does not install console scripts #11067

Closed
alexreg opened this issue Apr 26, 2022 · 9 comments
Closed

pip install -e does not install console scripts #11067

alexreg opened this issue Apr 26, 2022 · 9 comments
Labels
project: setuptools Related to setuptools resolution: no action When the resolution is to not do anything type: bug A confirmed bug or unintended behavior

Comments

@alexreg
Copy link

alexreg commented Apr 26, 2022

Description

No console scripts are installed when using editable mode for pip install.

Expected behavior

Console scripts should be installed, like in non-editable mode.

pip version

22.0.4

Python version

3.9.12

OS

macOS 12.3.1

How to Reproduce

  1. Clone Git repo https://github.com/alexreg/ycomp.
  2. Run pip install -e . from within the repo.
  3. Observe that console scripts are not installed, unlike with pip install ..

Output

DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
Obtaining file:///Users/alex/Software/ycomp
  Installing build dependencies ... done
  Checking if build backend supports build_editable ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy~=1.21 in /opt/homebrew/lib/python3.9/site-packages (from ycomp==0.1.0) (1.22.3)
Requirement already satisfied: requests~=2.26 in /opt/homebrew/lib/python3.9/site-packages (from ycomp==0.1.0) (2.27.1)
Requirement already satisfied: typer~=0.4 in /opt/homebrew/lib/python3.9/site-packages (from ycomp==0.1.0) (0.4.1)
Requirement already satisfied: more-itertools~=8.10 in /opt/homebrew/lib/python3.9/site-packages (from ycomp==0.1.0) (8.12.0)
Requirement already satisfied: cssselect~=1.1 in /opt/homebrew/lib/python3.9/site-packages (from ycomp==0.1.0) (1.1.0)
Requirement already satisfied: lxml~=4.6 in /opt/homebrew/lib/python3.9/site-packages (from ycomp==0.1.0) (4.8.0)
Requirement already satisfied: pandas~=1.4 in /opt/homebrew/lib/python3.9/site-packages (from ycomp==0.1.0) (1.4.2)
Requirement already satisfied: python-dateutil>=2.8.1 in /opt/homebrew/lib/python3.9/site-packages (from pandas~=1.4->ycomp==0.1.0) (2.8.2)
Requirement already satisfied: pytz>=2020.1 in /opt/homebrew/lib/python3.9/site-packages (from pandas~=1.4->ycomp==0.1.0) (2022.1)
Requirement already satisfied: charset-normalizer~=2.0.0 in /opt/homebrew/lib/python3.9/site-packages (from requests~=2.26->ycomp==0.1.0) (2.0.12)
Requirement already satisfied: idna<4,>=2.5 in /opt/homebrew/lib/python3.9/site-packages (from requests~=2.26->ycomp==0.1.0) (3.3)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /opt/homebrew/lib/python3.9/site-packages (from requests~=2.26->ycomp==0.1.0) (1.26.9)
Requirement already satisfied: certifi>=2017.4.17 in /opt/homebrew/lib/python3.9/site-packages (from requests~=2.26->ycomp==0.1.0) (2021.10.8)
Requirement already satisfied: click<9.0.0,>=7.1.1 in /opt/homebrew/lib/python3.9/site-packages (from typer~=0.4->ycomp==0.1.0) (8.1.2)
Requirement already satisfied: six>=1.5 in /opt/homebrew/lib/python3.9/site-packages (from python-dateutil>=2.8.1->pandas~=1.4->ycomp==0.1.0) (1.16.0)
Installing collected packages: ycomp
  Attempting uninstall: ycomp
    Found existing installation: ycomp 0.1.0
    Uninstalling ycomp-0.1.0:
      Successfully uninstalled ycomp-0.1.0
  DEPRECATION: Configuring installation scheme with distutils config files is deprecated and will no longer work in the near future. If you are using a Homebrew or Linuxbrew Python, please see discussion at https://github.com/Homebrew/homebrew-core/issues/76621
  Running setup.py develop for ycomp
Successfully installed ycomp-0.1.0


### Code of Conduct

- [X] I agree to follow the [PSF Code of Conduct](https://www.python.org/psf/conduct/).
@alexreg alexreg added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Apr 26, 2022
@sbidoul
Copy link
Member

sbidoul commented May 7, 2022

I just tried this procedure in a python:3.9 docker image and could not reproduce.

@alexreg
Copy link
Author

alexreg commented May 7, 2022

@sbidoul It definitely occurs on macOS using Homebrew Python!

@sbidoul
Copy link
Member

sbidoul commented May 7, 2022

If confirmed it is likely a setuptools issue, actually, as pip delegates installation to setup.py develop.

Could you try creating a setup.py with from setuptools import setup; setup() and run python setup.py develop ?
If the console script is not created, you should report the issue to the setuptools project.

@alexreg
Copy link
Author

alexreg commented May 8, 2022

@sbidoul I presume you mean with entry_points and console_scripts definitions too? The following is how I set things up.

setup.py

from setuptools import setup

setup(
    entry_points = {
        'console_scripts': [
            'foo = foopackage:main',
        ],
    }
)

foopackage/__init__.py

def main():
    print("foo")

I then ran python setup.py develop like you instructed, and this produced the following output.

/opt/homebrew/lib/python3.9/site-packages/setuptools/command/easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
/opt/homebrew/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
running egg_info
creating foopackage.egg-info
writing foopackage.egg-info/PKG-INFO
writing dependency_links to foopackage.egg-info/dependency_links.txt
writing entry points to foopackage.egg-info/entry_points.txt
writing top-level names to foopackage.egg-info/top_level.txt
writing manifest file 'foopackage.egg-info/SOURCES.txt'
listing git files failed - pretending there aren't any
reading manifest file 'foopackage.egg-info/SOURCES.txt'
writing manifest file 'foopackage.egg-info/SOURCES.txt'
running build_ext
Creating /opt/homebrew/lib/python3.9/site-packages/foopackage.egg-link (link to .)
foopackage 0.0.0 is already the active version in easy-install.pth
Installing foo script to /opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/bin

Installed /Users/alex/foo
Processing dependencies for foopackage==0.0.0
Finished processing dependencies for foopackage==0.0.0

The above generated foopackage.egg-info in the same directory, but no console script.

On the other hand, if I run python setup.py install, it output the following.

running install
/opt/homebrew/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
/opt/homebrew/lib/python3.9/site-packages/setuptools/command/easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
running bdist_egg
running egg_info
writing foopackage.egg-info/PKG-INFO
writing dependency_links to foopackage.egg-info/dependency_links.txt
writing entry points to foopackage.egg-info/entry_points.txt
writing top-level names to foopackage.egg-info/top_level.txt
listing git files failed - pretending there aren't any
reading manifest file 'foopackage.egg-info/SOURCES.txt'
writing manifest file 'foopackage.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-12-arm64/egg
running install_lib
running build_py
creating build
creating build/lib
creating build/lib/foopackage
copying foopackage/__init__.py -> build/lib/foopackage
creating build/bdist.macosx-12-arm64
creating build/bdist.macosx-12-arm64/egg
creating build/bdist.macosx-12-arm64/egg/foopackage
copying build/lib/foopackage/__init__.py -> build/bdist.macosx-12-arm64/egg/foopackage
byte-compiling build/bdist.macosx-12-arm64/egg/foopackage/__init__.py to __init__.cpython-39.pyc
creating build/bdist.macosx-12-arm64/egg/EGG-INFO
copying foopackage.egg-info/PKG-INFO -> build/bdist.macosx-12-arm64/egg/EGG-INFO
copying foopackage.egg-info/SOURCES.txt -> build/bdist.macosx-12-arm64/egg/EGG-INFO
copying foopackage.egg-info/dependency_links.txt -> build/bdist.macosx-12-arm64/egg/EGG-INFO
copying foopackage.egg-info/entry_points.txt -> build/bdist.macosx-12-arm64/egg/EGG-INFO
copying foopackage.egg-info/top_level.txt -> build/bdist.macosx-12-arm64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/foopackage-0.0.0-py3.9.egg' and adding 'build/bdist.macosx-12-arm64/egg' to it
removing 'build/bdist.macosx-12-arm64/egg' (and everything under it)
Processing foopackage-0.0.0-py3.9.egg
Copying foopackage-0.0.0-py3.9.egg to /opt/homebrew/lib/python3.9/site-packages
Removing foopackage 0.0.0 from easy-install.pth file
Adding foopackage 0.0.0 to easy-install.pth file
Installing foo script to /opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/bin

Installed /opt/homebrew/lib/python3.9/site-packages/foopackage-0.0.0-py3.9.egg
Processing dependencies for foopackage==0.0.0
Finished processing dependencies for foopackage==0.0.0

So, clearly the foo console scriptis installed in this case (although it's not in thePATHby default). I supposepip -e installuses thepython setup.py develop` command or something very similar?

To be honest, I'm not sure I'm well-qualified to report this issue properly. However, I suppose I can (more or less) copy and paste the above, as long as you confirm that I'm testing this in the right way.

Thanks.

@sbidoul
Copy link
Member

sbidoul commented May 8, 2022

I suppose pip -e install uses the python setup.py develop command or something very similar?

Yes currently that is what pip does with setuptools projects (until setuptools implements PEP 660).
You can see that in the pip output: Running setup.py develop for ycomp

In your latest example you also see setuptools saying Installing foo script to /opt/homebrew/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/bin.

What I was proposing is that you add, for the sake of testing, a simplified setup.py with no arguments to the setup() call so it picks up options from setup.cfg. You can then test setup.py develop and pip install -v -e . to compare the output and try to understand is the issue comes from setuptools or the way pip invokes setup.py in this case.

@alexreg
Copy link
Author

alexreg commented May 8, 2022

Oh I see. Anyway, I think from my example it's clear that it's a setuptools issue with the develop command, no?

@uranusjr
Copy link
Member

uranusjr commented May 8, 2022

Yes this should probably better be discussed in the setuptools tracker. I suspect it has something to do with how Homebrew configured the environment; it uses distutils.cfg to specify where to put things, and if that’s not correctly picked up or applied, things get installed to wrong locations.

@alexreg
Copy link
Author

alexreg commented May 8, 2022

@uranusjr Makes sense. I'll do that.

Thanks to both of you for your comments.

@pradyunsg
Copy link
Member

Closing since this looks like a setuptools/Homebrew issue. :)

@pradyunsg pradyunsg added project: setuptools Related to setuptools resolution: no action When the resolution is to not do anything and removed S: needs triage Issues/PRs that need to be triaged labels May 8, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
project: setuptools Related to setuptools resolution: no action When the resolution is to not do anything type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

No branches or pull requests

4 participants