Skip to content

Commit d1c6818

Browse files
committed
fix readme, add lint params
1 parent 6974665 commit d1c6818

14 files changed

+171
-89
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
virtualenv_embedded/*.bat text eol=crlf
1+
virtualenv_embedded/*.bat text eol=crlf

.pre-commit-config.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
repos:
2+
- repo: https://github.com/ambv/black
3+
rev: 18.9b0
4+
hooks:
5+
- id: black
6+
args: [--safe]
7+
language_version: python3.7
8+
- repo: https://github.com/asottile/blacken-docs
9+
rev: v0.3.0
10+
hooks:
11+
- id: blacken-docs
12+
additional_dependencies: [black==18.9b0]
13+
language_version: python3.7
14+
- repo: https://github.com/asottile/seed-isort-config
15+
rev: v1.2.0
16+
hooks:
17+
- id: seed-isort-config
18+
args: [--application-directories, "src:."]
19+
- repo: https://github.com/pre-commit/mirrors-isort
20+
rev: v4.3.4
21+
hooks:
22+
- id: isort
23+
- repo: https://github.com/pre-commit/pre-commit-hooks
24+
rev: v2.0.0
25+
hooks:
26+
- id: trailing-whitespace
27+
- id: end-of-file-fixer
28+
- id: check-yaml
29+
- id: debug-statements
30+
- id: flake8
31+
additional_dependencies: ["flake8-bugbear == 18.2.0"]
32+
language_version: python3.7
33+
- repo: https://github.com/asottile/pyupgrade
34+
rev: v1.9.1
35+
hooks:
36+
- id: pyupgrade
37+
- repo: https://github.com/pre-commit/pygrep-hooks
38+
rev: v1.1.0
39+
hooks:
40+
- id: rst-backticks

AUTHORS.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,4 @@ Thomas Aglassinger
8888
Vinay Sajip
8989
Vitaly Babiy
9090
Vladimir Rutsky
91-
Wang Xuerui
91+
Wang Xuerui

CONTRIBUTING.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Contributor notes
1010
Use Python 3 print-function syntax, and always ``use sys.exc_info()[1]``
1111
inside the ``except`` block to get at exception objects.
1212

13-
* Pull requests should be made against `master` branch, which is also our
13+
* Pull requests should be made against ``master`` branch, which is also our
1414
latest stable version.
1515

1616
* All changes to files inside virtualenv_embedded should be integrated to

README.rst

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,24 @@ virtualenv
33

44
A tool for creating isolated 'virtual' python environments.
55

6+
.. image:: https://badge.fury.io/py/virtualenv.svg
7+
:target: https://badge.fury.io/py/virtualenv
8+
:alt: Latest version on PyPi
9+
.. image:: https://img.shields.io/pypi/pyversions/virtualenv.svg
10+
:target: https://pypi.org/project/virtualenv/
11+
:alt: Supported Python versions
12+
.. image:: https://dev.azure.com/pypa/virtualenv/_apis/build/status/pypa.virtualenv
13+
:target: https://dev.azure.com/pypa/virtualenv/_apis/build/status/pypa.virtualenv?branchName=master
14+
:alt: Azure Pipelines build status
15+
.. image:: https://readthedocs.org/projects/virtualenv/badge/?version=latest&style=flat-square
16+
:target: https://virtualenv.readthedocs.io/en/latest/?badge=latest
17+
:alt: Documentation status
18+
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
19+
:target: https://github.com/ambv/black
20+
:alt: Code style: black
621
.. image:: https://img.shields.io/pypi/v/virtualenv.svg
7-
:target: https://pypi.org/project/virtualenv
22+
:target: https://pypi.org/project/virtualenv
823

9-
.. image:: https://img.shields.io/travis/pypa/virtualenv/develop.svg
10-
:target: http://travis-ci.org/pypa/virtualenv
1124

1225
* `Installation <https://virtualenv.pypa.io/en/latest/installation.html>`_
1326
* `Documentation <https://virtualenv.pypa.io/>`_

azure-pipelines.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ trigger:
2020
- .github/*
2121

2222
jobs:
23+
- template: azure-run-tox-env.yml
24+
parameters: {tox: fix_lint, python: 3.7}
2325
- template: azure-run-tox-env.yml
2426
parameters: {tox: embed, python: 3.7}
2527
- template: azure-run-tox-env.yml
@@ -117,4 +119,4 @@ jobs:
117119
codeCoverageTool: 'cobertura'
118120
summaryFileLocation: '$(System.DefaultWorkingDirectory)/.tox/coverage.xml'
119121
reportDirectory: '$(System.DefaultWorkingDirectory)/.tox/htmlcov'
120-
failIfCoverageEmpty: true
122+
failIfCoverageEmpty: true

bin/rebuild-script.py

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,80 +4,77 @@
44
"""
55
from __future__ import print_function
66

7+
import codecs
78
import os
89
import re
9-
import codecs
1010
from zlib import crc32 as _crc32
1111

1212

1313
def crc32(data):
1414
"""Python version idempotent"""
15-
return _crc32(data) & 0xffffffff
15+
return _crc32(data) & 0xFFFFFFFF
1616

1717

1818
here = os.path.dirname(__file__)
19-
script = os.path.join(here, '..', 'src', 'virtualenv.py')
19+
script = os.path.join(here, "..", "src", "virtualenv.py")
2020

21-
gzip = codecs.lookup('zlib')
22-
b64 = codecs.lookup('base64')
21+
gzip = codecs.lookup("zlib")
22+
b64 = codecs.lookup("base64")
2323

24-
file_regex = re.compile(
25-
br'##file (.*?)\n([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*convert\("""\n(.*?)"""\)',
26-
re.S)
27-
file_template = b'##file %(filename)s\n%(varname)s = convert("""\n%(data)s""")'
24+
file_regex = re.compile(br'# file (.*?)\n([a-zA-Z][a-zA-Z0-9_]+) = convert\(\n """\n(.*?)"""\n\)', re.S)
25+
file_template = b'# file %(filename)s\n%(variable)s = convert(\n """\n%(data)s"""\n)'
2826

2927

3028
def rebuild(script_path):
3129
exit_code = 0
32-
with open(script_path, 'rb') as f:
30+
with open(script_path, "rb") as f:
3331
script_content = f.read()
3432
parts = []
3533
last_pos = 0
3634
match = None
37-
for match in file_regex.finditer(script_content):
38-
parts += [script_content[last_pos:match.start()]]
35+
_count = 0
36+
for _count, match in enumerate(file_regex.finditer(script_content)):
37+
parts += [script_content[last_pos : match.start()]]
3938
last_pos = match.end()
4039
filename, fn_decoded = match.group(1), match.group(1).decode()
41-
varname = match.group(2)
40+
variable = match.group(2)
4241
data = match.group(3)
4342

44-
print('Found file %s' % fn_decoded)
45-
pathname = os.path.join(here, '..', 'virtualenv_embedded', fn_decoded)
43+
print("Found file %s" % fn_decoded)
44+
pathname = os.path.join(here, "..", "virtualenv_embedded", fn_decoded)
4645

47-
with open(pathname, 'rb') as f:
46+
with open(pathname, "rb") as f:
4847
embedded = f.read()
4948
new_crc = crc32(embedded)
5049
new_data = b64.encode(gzip.encode(embedded)[0])[0]
5150

5251
if new_data == data:
53-
print(' File up to date (crc: %08x)' % new_crc)
52+
print(" File up to date (crc: %08x)" % new_crc)
5453
parts += [match.group(0)]
5554
continue
5655
exit_code = 1
5756
# Else: content has changed
5857
crc = crc32(gzip.decode(b64.decode(data)[0])[0])
59-
print(' Content changed (crc: %08x -> %08x)' %
60-
(crc, new_crc))
61-
new_match = file_template % {
62-
b'filename': filename,
63-
b'varname': varname,
64-
b'data': new_data
65-
}
58+
print(" Content changed (crc: {:08x} -> {:08x})".format(crc, new_crc))
59+
new_match = file_template % {b"filename": filename, b"variable": variable, b"data": new_data}
6660
parts += [new_match]
6761

6862
parts += [script_content[last_pos:]]
69-
new_content = b''.join(parts)
63+
new_content = b"".join(parts)
7064

7165
if new_content != script_content:
72-
print('Content updated; overwriting... ', end='')
73-
with open(script_path, 'wb') as f:
66+
print("Content updated; overwriting... ", end="")
67+
with open(script_path, "wb") as f:
7468
f.write(new_content)
75-
print('done.')
69+
print("done.")
7670
else:
77-
print('No changes in content')
71+
print("No changes in content")
7872
if match is None:
79-
print('No variables were matched/found')
73+
print("No variables were matched/found")
74+
if not _count:
75+
exit_code = 1
8076
raise SystemExit(exit_code)
8177

82-
if __name__ == '__main__':
78+
79+
if __name__ == "__main__":
8380
rebuild(script)

docs/changes.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Release History
7575
15.0.0 (2016-03-05)
7676
-------------------
7777

78-
* Remove the `virtualenv-N.N` script from the package; this can no longer be
78+
* Remove the ``virtualenv-N.N`` script from the package; this can no longer be
7979
correctly created from a wheel installation.
8080
Resolves :issue:`851`, :issue:`692`
8181

@@ -124,7 +124,7 @@ Release History
124124

125125
* Upgrade setuptools to 19.6
126126

127-
* Supress any errors from `unset` on different shells (:pull:`843`)
127+
* Suppress any errors from ``unset`` on different shells (:pull:`843`)
128128

129129
* Normalize letter case for prefix path checking. Fixes :issue:`837`
130130

@@ -485,7 +485,7 @@ Release History
485485
1.8.1 (2012-09-03)
486486
------------------
487487

488-
* Fixed distribute version used with `--never-download`. Thanks michr for
488+
* Fixed distribute version used with ``--never-download``. Thanks michr for
489489
report and patch.
490490

491491
* Fix creating Python 3.3 based virtualenvs by unsetting the
@@ -498,7 +498,7 @@ Release History
498498
* **Dropped support for Python 2.4** The minimum supported Python version is
499499
now Python 2.5.
500500

501-
* Fix `--relocatable` on systems that use lib64. Fixes #78. Thanks Branden
501+
* Fix ``--relocatable`` on systems that use lib64. Fixes #78. Thanks Branden
502502
Rolston.
503503

504504
* Symlink some additional modules under Python 3. Fixes #194. Thanks Vinay
@@ -556,7 +556,7 @@ Release History
556556
1.7.1.2 (2012-02-17)
557557
--------------------
558558

559-
* Fixed minor issue in `--relocatable`. Thanks, Cap Petschulat.
559+
* Fixed minor issue in ``--relocatable``. Thanks, Cap Petschulat.
560560

561561

562562
1.7.1.1 (2012-02-16)
@@ -572,7 +572,7 @@ Release History
572572

573573
* Update embedded pip to version 1.1.
574574

575-
* Fix `--relocatable` under Python 3. Thanks Doug Hellmann.
575+
* Fix ``--relocatable`` under Python 3. Thanks Doug Hellmann.
576576

577577
* Added environ PATH modification to activate_this.py. Thanks Doug
578578
Napoleone. Fixes #14.
@@ -592,8 +592,8 @@ Release History
592592
Napoleone for testing and confirmation. Fixes #87.
593593

594594
* Fixed creation of virtualenvs using -p in installs where some modules
595-
that ought to be in the standard library (e.g. `readline`) are actually
596-
installed in `site-packages` next to `virtualenv.py`. Thanks Greg Haskins
595+
that ought to be in the standard library (e.g. ``readline``) are actually
596+
installed in ``site-packages`` next to ``virtualenv.py``. Thanks Greg Haskins
597597
for report and fix. Fixes #167.
598598

599599
* Added activation script for Powershell (signed by Jannis Leidel). Many

0 commit comments

Comments
 (0)