Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Install requirements before toml #22468

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

Merged
merged 1 commit into from
Nov 13, 2023
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
8 changes: 4 additions & 4 deletions 8 pythonFiles/create_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,15 @@ def main(argv: Optional[Sequence[str]] = None) -> None:
download_pip_pyz(args.name)
install_pip(args.name)

if args.toml:
print(f"VENV_INSTALLING_PYPROJECT: {args.toml}")
install_toml(venv_path, args.extras)

requirements = get_requirements_from_args(args)
if requirements:
print(f"VENV_INSTALLING_REQUIREMENTS: {requirements}")
install_requirements(venv_path, requirements)

if args.toml:
print(f"VENV_INSTALLING_PYPROJECT: {args.toml}")
install_toml(venv_path, args.extras)


if __name__ == "__main__":
main(sys.argv[1:])
24 changes: 21 additions & 3 deletions 24 pythonFiles/tests/test_create_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def add_gitignore(_name):
)


@pytest.mark.parametrize("install_type", ["requirements", "pyproject"])
@pytest.mark.parametrize("install_type", ["requirements", "pyproject", "both"])
def test_install_packages(install_type):
importlib.reload(create_venv)
create_venv.is_installed = lambda _x: True
Expand All @@ -120,16 +120,20 @@ def test_install_packages(install_type):
pip_upgraded = False
installing = None

order = []

def run_process(args, error_message):
nonlocal pip_upgraded, installing
nonlocal pip_upgraded, installing, order
if args[1:] == ["-m", "pip", "install", "--upgrade", "pip"]:
pip_upgraded = True
assert error_message == "CREATE_VENV.UPGRADE_PIP_FAILED"
elif args[1:-1] == ["-m", "pip", "install", "-r"]:
installing = "requirements"
order += ["requirements"]
assert error_message == "CREATE_VENV.PIP_FAILED_INSTALL_REQUIREMENTS"
elif args[1:] == ["-m", "pip", "install", "-e", ".[test]"]:
installing = "pyproject"
order += ["pyproject"]
assert error_message == "CREATE_VENV.PIP_FAILED_INSTALL_PYPROJECT"

create_venv.run_process = run_process
Expand All @@ -138,9 +142,23 @@ def run_process(args, error_message):
create_venv.main(["--requirements", "requirements-for-test.txt"])
elif install_type == "pyproject":
create_venv.main(["--toml", "pyproject.toml", "--extras", "test"])
elif install_type == "both":
create_venv.main(
[
"--requirements",
"requirements-for-test.txt",
"--toml",
"pyproject.toml",
"--extras",
"test",
]
)

assert pip_upgraded
assert installing == install_type
if install_type == "both":
assert order == ["requirements", "pyproject"]
else:
assert installing == install_type


@pytest.mark.parametrize(
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.