Skip to content

pip-sync

Pip-tools is a set of tools to keep pip-based packages fresh. pip-sync, a command provided bypip-tools, can update a virtual environment to exactly match a requirements.txt file. It will both install and delete resources in the environment to match a requirements.txt file. Note that it is recommended, you only use pip-sync on requirements.txt files generated by pip-tools using the pip-compile command.

Parameters:

  • requirementFiles: (array[string], required) A list of requirement files to supply pip-sync. Supports both requirements.txt and dev-requirements.txt

  • virtualEnv: (string) An optional virtual env to use. Specify the path to the virtual environment folder.

  • cwd: (string) The working directory to run commands from. If cwd is supplied, the other parameters can be specified as relative to cwd.

Example usage:

codify.json
[
{
"type": "pip-sync",
"cwd": "~/Project/my_project",
"virtualEnv": ".venv",
"requirementFiles": [
"requirements.txt",
"dev-requirements.txt"
]
}
]

In this example, pip-sync is used to install dependencies for the project located at ~/Project/my_project. Pip-sync can be used so that the virtual environment matches the requirements.txt exactly.

codify.json
[
{
"type": "venv-project",
"envDir": ".venv",
"cwd": "~/Projects/example-project2"
},
{
"type": "pip-sync",
"cwd": "~/Projects/example-project2",
"requirementFiles": ["requirements.txt", "dev-requirements.txt"],
"virtualEnv": ".venv"
}
]

In the example above, we first create a virtual environment (if it doesn’t exist) located at ~/Projects/example-project2/.venv. We then install dependencies into the virtual environment by using pip-sync on requirements.txt and dev-requirements.txt