-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Define the Python version used by PipEnv using UV to create the venv #19388
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
base: develop2
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -139,3 +139,84 @@ def build(self): | |
|
|
||
| assert "RUN: hello-world" in client.out | ||
| assert "Hello Test World!" in client.out | ||
|
|
||
|
|
||
| def test_build_pip_manager_using_uv(): | ||
|
|
||
| pip_package_folder = temp_folder(path_with_spaces=True) | ||
| _create_py_hello_world(pip_package_folder) | ||
| pip_package_folder = pip_package_folder.replace('\\', '/') | ||
|
|
||
| conanfile_pip = textwrap.dedent(f""" | ||
| from conan import ConanFile | ||
| from conan.tools.system import PipEnv | ||
| from conan.tools.layout import basic_layout | ||
| import platform | ||
| import os | ||
|
|
||
|
|
||
| class PipPackage(ConanFile): | ||
| name = "pip_hello_test" | ||
| version = "0.1" | ||
|
|
||
| def layout(self): | ||
| basic_layout(self) | ||
|
|
||
| def generate(self): | ||
| pip_env = PipEnv(self, py_version="3.11.6") | ||
| pip_env.install(["{pip_package_folder}"]) | ||
| pip_env.generate() | ||
| self.run(pip_env._get_env_python(pip_env._env_dir) + " --version") | ||
|
||
|
|
||
| def build(self): | ||
| self.run("hello-world") | ||
| """) | ||
|
|
||
| client = TestClient(path_with_spaces=False) | ||
| # FIXME: the python shebang inside vitual env packages fails when using path_with_spaces | ||
| client.save({"pip/conanfile.py": conanfile_pip}) | ||
| client.run("build pip/conanfile.py") | ||
| assert "Using CPython 3.11.6" in client.out | ||
| assert "Creating virtual environment with seed packages" in client.out | ||
| assert "Virtual environment for Python 3.11.6 created successfully using UV." in client.out | ||
| assert "python --version\nPython 3.11.6" in client.out | ||
| assert "RUN: hello-world" in client.out | ||
| assert "Hello Test World!" in client.out | ||
|
|
||
|
|
||
| def test_fail_build_pip_manager_using_uv(): | ||
|
|
||
| pip_package_folder = temp_folder(path_with_spaces=True) | ||
| _create_py_hello_world(pip_package_folder) | ||
| pip_package_folder = pip_package_folder.replace('\\', '/') | ||
|
|
||
| conanfile_pip = textwrap.dedent(f""" | ||
| from conan import ConanFile | ||
| from conan.tools.system import PipEnv | ||
| from conan.tools.layout import basic_layout | ||
| import platform | ||
| import os | ||
|
|
||
|
|
||
| class PipPackage(ConanFile): | ||
| name = "pip_hello_test" | ||
| version = "0.1" | ||
|
|
||
| def layout(self): | ||
| basic_layout(self) | ||
|
|
||
| def generate(self): | ||
| pip_env = PipEnv(self, py_version="3.11.86") | ||
| pip_env.install(["{pip_package_folder}"]) | ||
| pip_env.generate() | ||
| self.run(pip_env._get_env_python(pip_env._env_dir) + " --version") | ||
|
|
||
| def build(self): | ||
| self.run("hello-world") | ||
| """) | ||
|
|
||
| client = TestClient(path_with_spaces=False) | ||
| # FIXME: the python shebang inside vitual env packages fails when using path_with_spaces | ||
| client.save({"pip/conanfile.py": conanfile_pip}) | ||
| client.run("build pip/conanfile.py", assert_error=True) | ||
| assert "PipEnv could not create a Python 3.11.86 virtual environment using UV" in client.out | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What other advantages of using
uvcouldPipEnvenjoy?Do we want a generic access interface to it like
def install(self, packages, pip_args=None):?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The install interface is the same, It only affects how the virtual environment is created