question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

console_scripts are not created or removed on subsequent package installations

See original GitHub issue

Environment

  • pip version: 20.2.4
  • Python version: 3.7.6
  • OS: Solus 4.1 Fortitude

Description

If a user had previously installed a package that had no console_scripts entrypoints, then installs the package again without uninstalling it first, pip will not create (or remove) any console_scripts.

This happens when installing in development mode (-e) or when not in development mode.

Expected behavior

pip checks if console_scripts entrypoints have changed on each install and creates (or removes) console scripts as needed.

How to Reproduce

  1. Create a new package without any console_scripts
  2. Install the package
  3. Add a console_scripts entrypoint
  4. Install the package again
  5. Observe lack of wrapper script for entrypoint
  6. Uninstall the package
  7. Install the package
  8. Observe presence of wrapper script for entrypoint
$ cd $(mktemp -d)
$ python -m venv .venv
$ source .venv/bin/activate
$ python -m pip install -U pip setuptools wheel
Collecting pip
  Using cached https://files.pythonhosted.org/packages/cb/28/91f26bd088ce8e22169032100d4260614fc3da435025ff389ef1d396a433/pip-20.2.4-py2.py3-none-any.whl
Collecting setuptools
  Using cached https://files.pythonhosted.org/packages/6d/38/c21ef5034684ffc0412deefbb07d66678332290c14bb5269c85145fbd55e/setuptools-50.3.2-py3-none-any.whl
Collecting wheel
  Using cached https://files.pythonhosted.org/packages/a7/00/3df031b3ecd5444d572141321537080b40c1c25e1caa3d86cdd12e5e919c/wheel-0.35.1-py2.py3-none-any.whl
Installing collected packages: pip, setuptools, wheel
  Found existing installation: pip 19.2.3
    Uninstalling pip-19.2.3:
      Successfully uninstalled pip-19.2.3
  Found existing installation: setuptools 41.2.0
    Uninstalling setuptools-41.2.0:
      Successfully uninstalled setuptools-41.2.0
Successfully installed pip-20.2.4 setuptools-50.3.2 wheel-0.35.1
$ mkdir testpkg
$ cat > setup.py <<'EOF'
from setuptools import setup, find_packages

setup(
    name="testpkg",
    version="0.0.1",
    description="My test package",
    long_description="# testpkg\nMy test package",
    long_description_content_type="text/markdown",
    author="test",
    author_email="test@example.com",
    maintainer="test",
    maintainer_email="test@example.com",
    url=f"https://git.example.com/test/testpkg/blob/master/README.md",
    license="MIT",
    classifiers=[
        "Development Status :: 3 - Alpha",
        "Intended Audience :: Developers",
        "License :: OSI Approved :: MIT License",
        "Natural Language :: English",
        "Operating System :: OS Independent",
        "Programming Language :: Python :: 3 :: Only",
        "Programming Language :: Python :: 3.7",
        "Programming Language :: Python :: Implementation :: CPython",
    ],
    packages=find_packages(),
)
EOF
$ cat > testpkg/cli.py <<'EOF'
def main():
    print("Hello World")
EOF
$ find $VIRTUAL_ENV -name testpkgcli
$ python -m pip install --use-feature=2020-resolver -e .
Obtaining file:///tmp/tmp.pYPp8bLmjq
Installing collected packages: testpkg
  Running setup.py develop for testpkg
Successfully installed testpkg
$ find $VIRTUAL_ENV -name testpkgcli
$ patch -p1 <<'EOF'
--- ./setup.py    2020-11-07 15:59:04.823235435 -0800
+++ ./setup.py    2020-11-07 15:59:20.927199879 -0800
@@ -23,4 +23,9 @@
         "Programming Language :: Python :: Implementation :: CPython",
     ],
     packages=find_packages(),
+    entry_points={
+        "console_scripts": [
+            "testpkgcli = testpkg.cli:main"
+        ],
+    }
 )
EOF
patching file setup.py
$ python -m pip install --use-feature=2020-resolver -e .
Obtaining file:///tmp/tmp.pYPp8bLmjq
$ find $VIRTUAL_ENV -name testpkgcli                    
$ python -m pip uninstall -y testpkg
Found existing installation: testpkg 0.0.1
Uninstalling testpkg-0.0.1:
  Successfully uninstalled testpkg-0.0.1
$ python -m pip install --use-feature=2020-resolver -e .
Obtaining file:///tmp/tmp.pYPp8bLmjq
Installing collected packages: testpkg
  Running setup.py develop for testpkg
Successfully installed testpkg
$ find $VIRTUAL_ENV -name testpkgcli
/tmp/tmp.pYPp8bLmjq/.venv/bin/testpkgcli

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
uranusjrcommented, Nov 8, 2020

Oh BTW I forgot to mention, pip has a shorthand for the uninstall-install combination: pip install --force-reinstall.

0reactions
pdxjohnnycommented, Nov 8, 2020

Very true.

So to summarize

  • Users should uninstall and then install if they want changes to entry_points (or anything else) to take effect
  • Users could run python setup.py egg_info to update the entry_points and console_scripts
Read more comments on GitHub >

github_iconTop Results From Across the Web

Python Entry point 'console_scripts' not found - Stack Overflow
It appears that command_line is not being added to the relevant site_packages folder. grant@DevBox2:/opt/anaconda2/lib/python2.7/site-packages/ ...
Read more >
Manage NuGet packages with the Visual Studio Package ...
This article describes how to find, install, update, and uninstall NuGet packages with PowerShell commands in the Package Manager Console.
Read more >
Install or update packages - AWS Systems Manager
Scheduling a package installation or update (console) · Uninstall and reinstall: The package is completely uninstalled, and then reinstalled. · In-place update: ...
Read more >
Managing packages - Tanium Documentation
Consequently, even if signed in users do not have administrative rights, a Tanium Console user can deploy actions to the endpoint that install, ......
Read more >
Troubleshooting | Apps Script - Google Developers
Server not available. or Server error occurred, please try again. Authorization is required to perform that action. Access denied: DriveApp or ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found