{"id":3784,"library":"pyvers","title":"Pyvers","description":"Pyvers is a Python library designed to manage multiple versions of project dependencies locally within a `.pyvers` directory. It helps isolate project environments and ensures consistent dependency versions across development teams. The current version is 0.2.2, with releases occurring periodically, focusing on core functionality and stability.","status":"active","version":"0.2.2","language":"en","source_language":"en","source_url":"https://github.com/Pyvers-dev/pyvers","tags":["dependency management","version management","virtual environments"],"install":[{"cmd":"pip install pyvers","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Used for data validation and settings management within the library.","package":"pydantic","optional":false},{"reason":"Used for making HTTP requests, likely for fetching package information.","package":"requests","optional":false}],"imports":[{"symbol":"Pyvers","correct":"from pyvers import Pyvers"}],"quickstart":{"code":"import os\nimport shutil\nimport json\nfrom pyvers import Pyvers\n\ntemp_project_name = \"my_pyvers_project_quickstart\"\nproject_root = os.path.join(os.getcwd(), temp_project_name)\n\n# Clean up previous run if exists\nif os.path.exists(project_root):\n    shutil.rmtree(project_root)\n\nos.makedirs(project_root)\nprint(f\"Created temporary project directory: {project_root}\")\n\ntry:\n    pyvers_manager = Pyvers(project_path=project_root)\n\n    # 1. Initialize the Pyvers project\n    print(\"Initializing Pyvers project...\")\n    pyvers_manager.init()\n    print(f\"Pyvers project initialized at {os.path.join(project_root, '.pyvers')}\")\n\n    # 2. Add a dependency to the pyvers.json config\n    dep_name = \"requests\"\n    dep_version = \"2.28.1\"\n    print(f\"Adding dependency: {dep_name}@{dep_version} (type='prod')...\")\n    pyvers_manager.add_dependency(name=dep_name, version=dep_version, dep_type=\"prod\")\n    print(f\"Dependency '{dep_name}' added to config.\")\n\n    # 3. List dependencies from the config\n    print(\"\\nListing dependencies from config:\")\n    deps = pyvers_manager.list_dependencies()\n    if deps:\n        for dep in deps:\n            print(f\"  - {dep.name} @ {dep.version} ({dep.type})\")\n    else:\n        print(\"  No dependencies found in config.\")\n    \n    # 4. Install dependencies (creates/updates local virtual environment)\n    print(\"\\nInstalling dependencies...\")\n    # In a real scenario, this would install the added 'requests' package into '.pyvers/env'\n    # For this quickstart, we just demonstrate the call.\n    pyvers_manager.install()\n    print(\"Dependencies installed to local .pyvers environment.\")\n\nfinally:\n    # Clean up the temporary directory\n    if os.path.exists(project_root):\n        shutil.rmtree(project_root)\n        print(f\"\\nCleaned up temporary project directory: {project_root}\")","lang":"python","description":"This quickstart demonstrates how to initialize a Pyvers project, add a dependency to its configuration, list current dependencies, and then install them into the local `.pyvers` environment. It sets up a temporary directory to avoid affecting your current workspace."},"warnings":[{"fix":"Always pass the desired project root: `pyvers_instance = Pyvers(project_path='/path/to/your/project')`.","message":"When initializing `Pyvers`, ensure you explicitly provide `project_path` (e.g., `Pyvers(project_path=os.getcwd())`). If omitted, it defaults to the current working directory (`os.getcwd()`), which might not be the intended project root, leading to `.pyvers` directories being created in unexpected locations.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Specify the dependency type: `pyvers_manager.add_dependency(name='requests', version='2.28.1', dep_type='prod')`.","message":"The `add_dependency` method requires a `dep_type` parameter (e.g., 'prod', 'dev', 'test'). Forgetting this or providing an unrecognized type will result in an error, as the library enforces specific dependency categories.","severity":"gotcha","affected_versions":"All versions"},{"fix":"After adding dependencies, run `pyvers_manager.install()` to synchronize the environment with the configuration.","message":"Adding a dependency via `add_dependency` only updates the `pyvers.json` configuration file. To actually install the specified packages into the local `.pyvers` virtual environment, you must explicitly call `pyvers_manager.install()` afterward.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}