Skip to content

Commit 154e336

Browse files
committed
Initial commit
0 parents  commit 154e336

File tree

27 files changed

+922
-0
lines changed

27 files changed

+922
-0
lines changed

.cookiecutter/cookiecutter.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"template": "https://github.com/hypothesis/cookiecutters",
3+
"directory": "pypackage",
4+
"ignore": [],
5+
"extra_context": {
6+
"name": "pip-sync-faster",
7+
"package_name": "pip_sync_faster",
8+
"slug": "pip-sync-faster",
9+
"short_description": "A wrapper that makes pip-sync faster.",
10+
"python_versions": "3.10.4, 3.9.12, 3.8.13",
11+
"github_owner": "hypothesis",
12+
"copyright_holder": "Hypothesis",
13+
"public": "yes",
14+
"console_script": "yes",
15+
"__entry_point": "pip-sync-faster",
16+
"__github_url": "https://github.com/hypothesis/pip-sync-faster",
17+
"__pypi_url": "https://pypi.org/project/pip-sync-faster"
18+
}
19+
}

.cookiecutter/includes/README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
2+
pip-sync-faster makes pip-sync run faster in the case where there's nothing to
3+
do because the virtualenv is already up to date with the requirements files. On
4+
my machine, with my requirements files, it shaves off about 500ms in the time
5+
taken to run pip-sync:
6+
7+
```terminal
8+
$ time pip-sync requirements/foo.txt
9+
Everything up-to-date
10+
11+
real 0m0.569s
12+
user 0m0.525s
13+
sys 0m0.045s
14+
15+
$ time pip-sync-faster requirements/foo.txt
16+
17+
real 0m0.037s
18+
user 0m0.029s
19+
sys 0m0.008s
20+
```
21+
22+
pip-sync-faster does this by saving hashes of the given requirements files in a
23+
JSON file within the virtualenv and not calling pip-sync if the hashes haven't
24+
changed.
25+
26+
If any of the given requirements files doesn't have a matching cached hash then
27+
pip-sync-faster calls pip-sync forwarding all command line arguments and
28+
options.
29+
30+
## pip-sync-faster doesn't sync modified virtualenvs
31+
32+
If you modify your requirements files pip-sync-faster will notice the change
33+
and call pip-sync. But if you modify your virtualenv without modifying your
34+
requirements files (for example by running a manual `pip install` command in
35+
the virtualenv) pip-sync-faster will *not* call pip-sync because the
36+
requirements files haven't changed and still match their cached hashes.
37+
38+
Calling pip-sync directly in this case would re-sync your virtualenv with your
39+
requirements files, but calling pip-sync-faster won't.
40+
41+
If you can live with this limitation then you can use pip-sync-faster and save
42+
yourself a few hundred milliseconds. If not you should just use pip-sync.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pip-tools

.github/dependabot.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "pip"
4+
directory: "/"
5+
schedule:
6+
interval: "monthly"
7+
day: "sunday"
8+
time: "00:00"
9+
timezone: "Europe/London"

.github/workflows/ci.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: CI
2+
on:
3+
push:
4+
workflow_dispatch:
5+
schedule:
6+
- cron: '0 1 * * *'
7+
jobs:
8+
Format:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v3
12+
- name: Install Python
13+
uses: actions/setup-python@v4
14+
with:
15+
python-version: '3.10'
16+
- run: python -m pip install tox
17+
- run: tox -e checkformatting
18+
Lint:
19+
runs-on: ubuntu-latest
20+
steps:
21+
- uses: actions/checkout@v3
22+
- name: Install Python
23+
uses: actions/setup-python@v4
24+
with:
25+
python-version: '3.10'
26+
- run: python -m pip install tox
27+
- run: tox -e lint
28+
Tests:
29+
runs-on: ubuntu-latest
30+
strategy:
31+
matrix:
32+
python-version: ['3.10', '3.9', '3.8']
33+
name: Unit tests with Python ${{ matrix.python-version }}
34+
steps:
35+
- uses: actions/checkout@v3
36+
- name: Install Python
37+
uses: actions/setup-python@v4
38+
with:
39+
python-version: ${{ matrix.python-version }}
40+
- run: python -m pip install tox
41+
- run: tox -e tests
42+
- name: Upload coverage file
43+
uses: actions/upload-artifact@v3
44+
with:
45+
name: coverage
46+
path: .coverage.*
47+
Coverage:
48+
needs: tests
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/checkout@v3
52+
- name: Install Python
53+
uses: actions/setup-python@v4
54+
with:
55+
python-version: '3.10'
56+
- name: Download coverage files
57+
uses: actions/download-artifact@v3
58+
with:
59+
name: coverage
60+
- run: python -m pip install tox
61+
- run: tox -e coverage
62+
Functests:
63+
runs-on: ubuntu-latest
64+
strategy:
65+
matrix:
66+
python-version: ['3.10', '3.9', '3.8']
67+
name: Functional tests with Python ${{ matrix.python-version }}
68+
steps:
69+
- uses: actions/checkout@v3
70+
- name: Install Python
71+
uses: actions/setup-python@v4
72+
with:
73+
python-version: ${{ matrix.python-version }}
74+
- run: python -m pip install tox
75+
- run: tox -e functests

.github/workflows/pypi.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: PyPI
2+
on:
3+
release:
4+
types: [published]
5+
jobs:
6+
PyPI:
7+
uses: hypothesis/workflows/.github/workflows/pypi.yml@main
8+
secrets: inherit

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
build
2+
coverage
3+
node_modules
4+
yarn-error.log
5+
.coverage*
6+
.tox
7+
*.egg-info
8+
*.pyc
9+
supervisord.log
10+
supervisord.pid
11+
.DS_Store
12+
.devdata.env

.python-version

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
3.10.4
2+
3.9.12
3+
3.8.13

HACKING.md

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Setting up Your pip-sync-faster Development Environment
2+
3+
First you'll need to install:
4+
5+
* [Git](https://git-scm.com/).
6+
On Ubuntu: `sudo apt install git`, on macOS: `brew install git`.
7+
* [GNU Make](https://www.gnu.org/software/make/).
8+
This is probably already installed, run `make --version` to check.
9+
* [pyenv](https://github.com/pyenv/pyenv).
10+
Follow the instructions in pyenv's README to install it.
11+
The **Homebrew** method works best on macOS.
12+
The **Basic GitHub Checkout** method works best on Ubuntu.
13+
You _don't_ need to set up pyenv's shell integration ("shims"), you can
14+
[use pyenv without shims](https://github.com/pyenv/pyenv#using-pyenv-without-shims).
15+
16+
Then to set up your development environment:
17+
18+
```terminal
19+
git clone https://github.com/hypothesis/pip-sync-faster.git
20+
cd pip_sync_faster
21+
make help
22+
```
23+
24+
Releasing a New Version of the Project
25+
--------------------------------------
26+
27+
1. First, to get PyPI publishing working you need to go to:
28+
<https://github.com/organizations/hypothesis/settings/secrets/actions/PYPI_TOKEN>
29+
and add pip-sync-faster to the `PYPI_TOKEN` secret's selected
30+
repositories.
31+
32+
2. Now that the pip-sync-faster project has access to the `PYPI_TOKEN` secret
33+
you can release a new version by just [creating a new GitHub release](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository).
34+
Publishing a new GitHub release will automatically trigger
35+
[a GitHub Actions workflow](.github/workflows/pypi.yml)
36+
that will build the new version of your Python package and upload it to
37+
<https://pypi.org/project/pip-sync-faster>.
38+
39+
Changing the Project's Python Versions
40+
--------------------------------------
41+
42+
To change what versions of Python the project uses:
43+
44+
1. Change the Python versions in the
45+
[cookiecutter.json](.cookiecutter/cookiecutter.json) file. For example:
46+
47+
```json
48+
"python_versions": "3.10.4, 3.9.12",
49+
```
50+
51+
2. Re-run the cookiecutter template:
52+
53+
```terminal
54+
make template
55+
```
56+
57+
3. Commit everything to git and send a pull request
58+
59+
Changing the Project's Python Dependencies
60+
------------------------------------------
61+
62+
To change the production dependencies in the `setup.cfg` file:
63+
64+
1. Change the dependencies in the [`.cookiecutter/includes/setuptools/install_requires`](.cookiecutter/includes/setuptools/install_requires) file.
65+
If this file doesn't exist yet create it and add some dependencies to it.
66+
For example:
67+
68+
```
69+
pyramid
70+
sqlalchemy
71+
celery
72+
```
73+
74+
2. Re-run the cookiecutter template:
75+
76+
```terminal
77+
make template
78+
```
79+
80+
3. Commit everything to git and send a pull request
81+
82+
To change the project's formatting, linting and test dependencies:
83+
84+
1. Change the dependencies in the [`.cookiecutter/includes/tox/deps`](.cookiecutter/includes/tox/deps) file.
85+
If this file doesn't exist yet create it and add some dependencies to it.
86+
Use tox's [factor-conditional settings](https://tox.wiki/en/latest/config.html#factors-and-factor-conditional-settings)
87+
to limit which environment(s) each dependency is used in.
88+
For example:
89+
90+
```
91+
lint: flake8,
92+
format: autopep8,
93+
lint,tests: pytest-faker,
94+
```
95+
96+
2. Re-run the cookiecutter template:
97+
98+
```terminal
99+
make template
100+
```
101+
102+
3. Commit everything to git and send a pull request

INSTALL.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Installing pip-sync-faster
2+
3+
We recommend using [pipx](https://pypa.github.io/pipx/) to install
4+
pip-sync-faster.
5+
First [install pipx](https://pypa.github.io/pipx/#install-pipx) then run:
6+
7+
```terminal
8+
pipx install pip-sync-faster
9+
```
10+
11+
You now have pip-sync-faster installed! For some help run:
12+
13+
```
14+
pip-sync-faster --help
15+
```
16+
17+
Upgrading
18+
---------
19+
20+
To upgrade to the latest version run:
21+
22+
```terminal
23+
pipx upgrade pip-sync-faster
24+
```
25+
26+
To see what version you have run:
27+
28+
```terminal
29+
pip-sync-faster --version
30+
```
31+
32+
Uninstalling
33+
------------
34+
35+
To uninstall run:
36+
37+
```
38+
pipx uninstall pip-sync-faster
39+
```

0 commit comments

Comments
 (0)