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

generate pipx.y besides pip-x.y #1729

Merged
merged 1 commit into from
Mar 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/changelog/1723.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Also generate ``pipx.y`` console script beside ``pip-x.y`` to be compatible with how pip installs itself -
by :user:`gaborbernat`.
2 changes: 2 additions & 0 deletions src/virtualenv/seed/via_app_data/pip_install/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ def _write_script(scriptnames, shebang, script, filenames, ext):
"{}{}".format(name, version_info.major),
"{}-{}.{}".format(name, version_info.major, version_info.minor),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we generating "scriptname-X.Y" scripts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because that's what distlib does, and the idea is that the virtualenv should shield you from calling os versions of these 👍

}
if name == "pip":
scriptnames.add("{}{}.{}".format(name, version_info.major, version_info.minor))
return previous(scriptnames, shebang, script, filenames, ext)

previous = maker._write_script
Expand Down
2 changes: 1 addition & 1 deletion src/virtualenv/seed/via_app_data/via_app_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FromAppData(BaseEmbed):
def __init__(self, options):
super(FromAppData, self).__init__(options)
self.symlinks = options.symlink_app_data
self.base_cache = self.app_data / "seed-app-data" / "v1"
self.base_cache = self.app_data / "seed-app-data" / "v1.0.1"

@classmethod
def add_parser_arguments(cls, parser, interpreter, app_data):
Expand Down
7 changes: 6 additions & 1 deletion tests/unit/create/test_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,12 @@ def test_cross_major(cross_python, coverage_env, tmp_path, session_app_data, cur
result = cli_run(cmd)
pip_scripts = {i.name.replace(".exe", "") for i in result.creator.script_dir.iterdir() if i.name.startswith("pip")}
major, minor = cross_python.version_info[0:2]
assert pip_scripts == {"pip", "pip-{}.{}".format(major, minor), "pip{}".format(major)}
assert pip_scripts == {
"pip",
"pip{}".format(major),
"pip-{}.{}".format(major, minor),
"pip{}.{}".format(major, minor),
}
coverage_env()
env = PythonInfo.from_exe(str(result.creator.exe), session_app_data)
assert env.version_info.major != CURRENT.version_info.major
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/seed/test_boostrap_link_via_app_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
@pytest.mark.slow
@pytest.mark.timeout(timeout=60)
@pytest.mark.parametrize("copies", [False, True] if fs_supports_symlink() else [True])
def test_base_bootstrap_link_via_app_data(tmp_path, coverage_env, current_fastest, copies):
def test_seed_link_via_app_data(tmp_path, coverage_env, current_fastest, copies):
current = PythonInfo.current_system()
bundle_ver = BUNDLE_SUPPORT[current.version_release_str]
create_cmd = [
Expand Down Expand Up @@ -56,6 +56,7 @@ def test_base_bootstrap_link_via_app_data(tmp_path, coverage_env, current_fastes
for suffix in (
"",
"{}".format(current.version_info.major),
"{}.{}".format(current.version_info.major, current.version_info.minor),
"-{}.{}".format(current.version_info.major, current.version_info.minor),
)
]:
Expand Down