Skip to content

Commit

Permalink
Merge pull request #640 from willkg/620-deps
Browse files Browse the repository at this point in the history
rework dev dependencies (#620)
  • Loading branch information
willkg committed Feb 10, 2022
2 parents a52aa73 + a95d603 commit 06778c0
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 625 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install -U pip setuptools>=18.5
python -m pip install -r requirements-dev.txt
python -m pip install '.[dev]'
- name: Tests
shell: bash
Expand Down
12 changes: 4 additions & 8 deletions .github/workflows/test.yml
Expand Up @@ -35,15 +35,11 @@ jobs:
restore-keys: |
${{ matrix.os }}-${{ matrix.python-version }}-
- name: Install dev dependencies
run: |
python -m pip install -r requirements-dev.txt
- name: Print and compare hashes for python and platform specific libraries
- name: Install dependencies
shell: bash
run: |
pip-compile --generate-hashes requirements-dev.in > requirements-dev.tmp
echo "diffing requirements-dev.txt and requirements-dev.tmp"
diff requirements-dev.txt requirements-dev.tmp || true
python -m pip install -U pip setuptools>=18.5
python -m pip install '.[dev]'
- name: Tests
shell: bash
Expand Down
1 change: 0 additions & 1 deletion MANIFEST.in
Expand Up @@ -2,7 +2,6 @@ include CHANGES
include CONTRIBUTORS
include CONTRIBUTING.rst
include CODE_OF_CONDUCT.rst
include requirements-dev.txt
include tox.ini
include LICENSE
include README.rst
Expand Down
32 changes: 16 additions & 16 deletions docs/dev.rst
Expand Up @@ -11,12 +11,11 @@ To install Bleach to make changes to it:

$ git clone git://github.com/mozilla/bleach.git

2. Create a virtual environment using whatever method you want.
2. Create and activate a virtual environment.

3. Install Bleach into the virtual environment such that you can see
changes::
3. Install Bleach and developer requirements into the virtual environment::

$ pip install -e .
$ pip install -e '.[dev]'


Code of conduct
Expand Down Expand Up @@ -54,8 +53,7 @@ Release process

1. Checkout main tip.

2. Check to make sure ``setup.py`` and ``requirements-dev.txt`` are
correct and match requirements-wise.
2. Check to make sure ``setup.py`` is correct and match requirements-wise.

3. Update version numbers in ``bleach/__init__.py``.

Expand Down Expand Up @@ -83,10 +81,12 @@ Release process
$ cd docs/
$ make doctest

4. Verify the local vendored files (the second invocation should **not** exit with ``/tmp/vendor-test exists. Please remove.`` and the exit code should be zero)::
4. Verify the local vendored files (the second invocation should **not**
exit with ``/tmp/vendor-test exists. Please remove.`` and the exit
code should be zero)::

$ ./scripts/run_tests.sh vendorverify
$ ./scripts/run_tests.sh vendorverify
$ ./scripts/run_tests.sh vendorverify
$ ./scripts/run_tests.sh vendorverify

5. Run any additional tests to verify everything else works

Expand All @@ -96,27 +96,27 @@ Release process

8. After CI passes, create a signed tag for the release::

$ git tag -s v0.4.0
$ git tag -s v0.4.0

Copy the details from ``CHANGES`` into the tag comment.

9. Generate distribution files::

$ python setup.py sdist bdist_wheel
$ python setup.py sdist bdist_wheel

10. Sanity check the release contents and sizes::

$ ls -lh dist/* # file sizes should be similar
$ tar tvzf dist/bleach-${VERSION}.tar.gz
$ unzip -v dist/bleach-${VERSION}-py2.py3-none-any.whl
$ ls -lh dist/* # file sizes should be similar
$ tar tvzf dist/bleach-${VERSION}.tar.gz
$ unzip -v dist/bleach-${VERSION}-py2.py3-none-any.whl

11. Upload them to PyPI::

$ twine upload dist/*
$ twine upload dist/*

12. Push the new tag::

$ git push --tags official main
$ git push --tags official main

That will push the release to PyPI.

Expand Down
33 changes: 0 additions & 33 deletions requirements-dev.in

This file was deleted.

504 changes: 0 additions & 504 deletions requirements-dev.txt

This file was deleted.

17 changes: 8 additions & 9 deletions scripts/run_tests.sh
Expand Up @@ -14,7 +14,7 @@ case "${MODE}" in
pytest
;;
lint)
flake8 bleach/
flake8 setup.py tests/ bleach/ tests_website/
;;
vendorverify)
./scripts/vendor_verify.sh
Expand All @@ -23,18 +23,17 @@ case "${MODE}" in
tox -e docs
;;
format)
black --target-version=py37 bleach/*.py tests/ tests_website/
black --target-version=py37 --exclude=_vendor setup.py bleach/ tests/ tests_website/
;;
format-check)
black --target-version=py37 --check --diff bleach/*.py tests/ tests_website/
black --target-version=py37 --check --diff --exclude=_vendor setup.py bleach/ tests/ tests_website/
;;
check-reqs)
mv requirements-dev.txt requirements-dev.txt.orig
pip-compile --generate-hashes requirements-dev.in
echo "diffing requirements-dev.txt and requirements-dev.txt.orig"
diff requirements-dev.txt requirements-dev.txt.orig
rm requirements-dev.txt
mv requirements-dev.txt.orig requirements-dev.txt
python -m venv ./tmpvenv/
./tmpvenv/bin/pip install -U pip
./tmpvenv/bin/install '.[dev]'
./tmpvenv/bin/pip list -o
rm -rf ./tmpvenv/
;;
*)
echo "Unknown mode $MODE."
Expand Down
10 changes: 6 additions & 4 deletions setup.cfg
Expand Up @@ -4,13 +4,15 @@ exclude =
.tox/,
bleach/_vendor/*
ignore =
# E203: whitespace before ":"; doesn't work with black
E203,
# E501: line too long
E501,
# E731: do not assign a lambda expression, use a def
E731,
# E203: whitespace before : (refs: https://github.com/PyCQA/pycodestyle/issues/373)
E203,
# W503: line break occurred before a binary operator
# W503: line break before opertor; this doesn't work with black
W503
max-line-length = 100
max-line-length = 88

[tool:pytest]
addopts = -W error:html5lib:DeprecationWarning
94 changes: 55 additions & 39 deletions setup.py
@@ -1,67 +1,83 @@
#!/usr/bin/env python

import io
import os
import re

from setuptools import setup, find_packages


install_requires = [
'packaging',
'six>=1.9.0',
# html5lib requirements
'webencodings',
]


def get_long_desc():
with open('README.rst', encoding='utf-8') as fp:
with open("README.rst", encoding="utf-8") as fp:
desc = fp.read()
desc += '\n\n'
with open('CHANGES', encoding='utf-8') as fp:
desc += "\n\n"
with open("CHANGES", encoding="utf-8") as fp:
desc += fp.read()
return desc


def get_version():
fn = os.path.join('bleach', '__init__.py')
fn = os.path.join("bleach", "__init__.py")
vsre = r"""^__version__ = ['"]([^'"]*)['"]"""
with open(fn, encoding='utf-8') as fp:
with open(fn, encoding="utf-8") as fp:
version_file = fp.read()
return re.search(vsre, version_file, re.M).group(1)


INSTALL_REQUIRES = [
"packaging",
# html5lib requirements
"six>=1.9.0",
"webencodings",
]


EXTRAS_REQUIRE = {
"dev": [
"pip-tools==6.5.0",
"pytest==7.0.0",
"flake8==4.0.1",
"tox==3.24.5",
"sphinx==4.3.2",
"twine==3.8.0",
"wheel==0.37.1",
"hashin==0.17.0",
"black==22.1.0; implementation_name == 'cpython'",
"mypy==0.931; implementation_name=='cpython'",
],
}


setup(
name='bleach',
name="bleach",
version=get_version(),
description='An easy safelist-based HTML-sanitizing tool.',
description="An easy safelist-based HTML-sanitizing tool.",
long_description=get_long_desc(),
maintainer='Will Kahn-Greene',
maintainer_email='willkg@mozilla.com',
url='https://github.com/mozilla/bleach',
license='Apache Software License',
maintainer="Will Kahn-Greene",
maintainer_email="willkg@mozilla.com",
url="https://github.com/mozilla/bleach",
license="Apache Software License",
packages=find_packages(),
include_package_data=True,
package_data={'': ['README.rst']},
package_data={"": ["README.rst"]},
zip_safe=False,
python_requires='>=3.7',
install_requires=install_requires,
python_requires=">=3.7",
install_requires=INSTALL_REQUIRES,
extras_require=EXTRAS_REQUIRE,
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Web Environment',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Software Development :: Libraries :: Python Modules',
]
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: Implementation :: CPython",
"Programming Language :: Python :: Implementation :: PyPy",
"Topic :: Software Development :: Libraries :: Python Modules",
],
)
15 changes: 5 additions & 10 deletions tox.ini
Expand Up @@ -10,8 +10,7 @@ envlist =
vendorverify

[testenv]
deps =
-rrequirements-dev.txt
extras = dev
commands =
pytest {posargs:-v}
python setup.py build
Expand Down Expand Up @@ -43,32 +42,28 @@ commands =
[testenv:lint]
basepython = python3.9
changedir = scripts
deps =
-rrequirements-dev.txt
extras = dev
commands =
./run_tests.sh lint

[testenv:vendorverify]
basepython = python3.9
changedir = scripts
deps =
-rrequirements-dev.txt
extras = dev
commands =
./run_tests.sh vendorverify

[testenv:format-check]
basepython = python3.9
changedir = scripts
deps =
-rrequirements-dev.txt
extras = dev
commands =
./run_tests.sh format-check

[testenv:docs]
basepython = python3.9
changedir = docs
deps =
-rrequirements-dev.txt
extras = dev
commands =
sphinx-build -b html -d {envtmpdir}/doctrees . {envtmpdir}/html
sphinx-build -b doctest -d {envtmpdir}/doctrees . {envtmpdir}/doctest

0 comments on commit 06778c0

Please sign in to comment.