Package: pip-sync-faster
pip-sync-fasterA wrapper that makes pip-sync faster.pip-sync-faster makespip-syncrun faster in the case where there's nothing to do because the virtualenv is
already up to date with the requirements files. On my machine, with my
requirements files, it shaves off over 500ms in the time taken to run pip-sync:$ time pip-sync requirements/foo.txt
Everything up-to-date

real    0m0.569s
user    0m0.525s
sys     0m0.045s

$ time pip-sync-faster requirements/foo.txt

real    0m0.037s
user    0m0.029s
sys     0m0.008spip-sync-fasterdoes this by saving hashes of the given requirements files in a
JSON file within the virtualenv and not calling pip-sync if the hashes haven't
changed.
If any of the given requirements files doesn't have a matching cached hash then
pip-sync-faster calls pip-sync forwarding all command line arguments and
options.You need to addpip-sync-fasterto your requirements fileA command likepip-sync-faster requirements.txtwill callpip-sync requirements.txtwhich will uninstall anything not inrequirements.txtfrom the active venv, includingpip-sync-fasteritself!You can addpip-sync-fastertorequirements.txtso that it doesn't get
uninstalled.Runningpip-sync-fasterdirectly insteadAlternatively as long aspip-toolsis installed in the active venv you can
runpip-sync-fasterdirectly with a command like:PYTHONPATH=/path/to/pip-sync-faster/srcpython3-mpip_sync_fasterrequirements.txtThis doesn't rely onpip-sync-fasterbeing installed so there's no issue withpip-syncuninstalling it.pip-sync-faster doesn't sync modified virtualenvsIf you modify your requirements files pip-sync-faster will notice the change
and call pip-sync. But if you modify your virtualenv without modifying your
requirements files (for example by running a manualpip installcommand in
the virtualenv) pip-sync-faster willnotcall pip-sync because the
requirements files haven't changed and still match their cached hashes.Calling pip-sync directly in this case would re-sync your virtualenv with your
requirements files, but calling pip-sync-faster won't.If you can live with this limitation then you can use pip-sync-faster and save
yourself a few hundred milliseconds. If not you should just use pip-sync.InstallingWe recommend usingpipxto install
pip-sync-faster.
Firstinstall pipxthen run:pipx install pip-sync-fasterYou now have pip-sync-faster installed! For some help run:pip-sync-faster --helpUpgradingTo upgrade to the latest version run:pipx upgrade pip-sync-fasterTo see what version you have run:pip-sync-faster --versionUninstallingTo uninstall run:pipx uninstall pip-sync-fasterSetting up Your pip-sync-faster Development EnvironmentFirst you'll need to install:Git.
On Ubuntu:sudo apt install git, on macOS:brew install git.GNU Make.
This is probably already installed, runmake --versionto check.pyenv.
Follow the instructions in pyenv's README to install it.
TheHomebrewmethod works best on macOS.
TheBasic GitHub Checkoutmethod works best on Ubuntu.
Youdon'tneed to set up pyenv's shell integration ("shims"), you canuse pyenv without shims.Then to set up your development environment:git clone https://github.com/hypothesis/pip-sync-faster.git
cd pip_sync_faster
make helpReleasing a New Version of the ProjectFirst, to get PyPI publishing working you need to go to:https://github.com/organizations/hypothesis/settings/secrets/actions/PYPI_TOKENand add pip-sync-faster to thePYPI_TOKENsecret's selected
repositories.Now that the pip-sync-faster project has access to thePYPI_TOKENsecret
you can release a new version by justcreating a new GitHub release.
Publishing a new GitHub release will automatically triggera GitHub Actions workflowthat will build the new version of your Python package and upload it tohttps://pypi.org/project/pip-sync-faster.Changing the Project's Python VersionsTo change what versions of Python the project uses:Change the Python versions in thecookiecutter.jsonfile. For example:"python_versions":"3.10.4, 3.9.12",Re-run the cookiecutter template:make templateCommit everything to git and send a pull requestChanging the Project's Python DependenciesTo change the production dependencies in thesetup.cfgfile:Change the dependencies in the.cookiecutter/includes/setuptools/install_requiresfile.
If this file doesn't exist yet create it and add some dependencies to it.
For example:pyramid
sqlalchemy
celeryRe-run the cookiecutter template:make templateCommit everything to git and send a pull requestTo change the project's formatting, linting and test dependencies:Change the dependencies in the.cookiecutter/includes/tox/depsfile.
If this file doesn't exist yet create it and add some dependencies to it.
Use tox'sfactor-conditional settingsto limit which environment(s) each dependency is used in.
For example:lint: flake8,
format: autopep8,
lint,tests: pytest-faker,Re-run the cookiecutter template:make templateCommit everything to git and send a pull requestTesting ManuallyNormally if you wanted to test a command manually in dev you'd do so through
tox, for example:$ tox -qe dev --run-command 'pip-sync-faster --help'
usage: pip-sync-faster [-h] [-v]

options:
  -h, --help     show this help message and exit
  -v, --versionBut there's a problem with runningpip-sync-fastercommands in this way: a
command liketox -e dev --run-command 'pip-sync-faster requirements.txt'will
runpip-sync requirements.txtandpip-syncwill sync the
current virtualenv (.tox/dev/) with therequirements.txtfile. Everything
inrequirements.txtwill get installed into.tox/dev/, which you probably
don't want. Even worse everythingnotinrequirements.txtwill getremovedfrom.tox/dev/includingpip-sync-fasteritself!To avoid this problem runpip-sync-fasterin a temporary virtualenv instead.
This installs the contents ofrequirements.txtinto the temporary venv so
your.tox/dev/env doesn't get messed up. And it does not installpip-sync-fasterinto the temporary venv so there's no issue withpip-syncuninstallingpip-sync-faster:# Make a temporary directory.
tempdir=$(mktemp -d)

# Create a virtualenv in the temporary directory.
python3 -m venv $tempdir

# Activate the virtualenv.
source $tempdir/bin/activate

# Install pip-tools in the virtualenv (pip-sync-faster needs pip-tools).
pip install pip-tools

# Call pip-sync-faster to install a requirements file into the temporary virtualenv.
PYTHONPATH=src python3 -m pip_sync_faster /path/to/requirements.txt

# When you're done testing deactivate the temporary virtualenv.
deactivate