From: DongHun Kwak Date: Tue, 29 Dec 2020 22:09:24 +0000 (+0900) Subject: Imported Upstream version 51.1.0 X-Git-Tag: upstream/51.1.0^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=85962e80e3cd5112aec52156b6729733e7dd598f;p=platform%2Fupstream%2Fpython-setuptools.git Imported Upstream version 51.1.0 --- diff --git a/.bumpversion.cfg b/.bumpversion.cfg index c56d45d..d156ded 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 51.0.0 +current_version = 51.1.0 commit = True tag = True diff --git a/.coveragerc b/.coveragerc index 2f0e871..4582306 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,8 +1,5 @@ [run] -source= - pkg_resources - setuptools -omit= - */_vendor/* +omit = .tox/* [report] +show_missing = True diff --git a/.flake8 b/.flake8 index c658061..8bc2d27 100644 --- a/.flake8 +++ b/.flake8 @@ -1,12 +1,14 @@ [flake8] -exclude= - .tox - setuptools/_vendor, - pkg_resources/_vendor +max-line-length = 88 +exclude = + setuptools/_vendor + pkg_resources/_vendor ignore = - # W503 violates spec https://github.com/PyCQA/pycodestyle/issues/513 - W503 - # W504 has issues https://github.com/OCA/maintainer-quality-tools/issues/545 - W504 - setuptools/site-patch.py F821 - setuptools/py*compat.py F811 + # W503 violates spec https://github.com/PyCQA/pycodestyle/issues/513 + W503 + # W504 has issues https://github.com/OCA/maintainer-quality-tools/issues/545 + W504 + # Black creates whitespace before colon + E203 + setuptools/site-patch.py F821 + setuptools/py*compat.py F811 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..31b9414 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,43 @@ +name: Automated Tests + +on: [push, pull_request] + +jobs: + test: + strategy: + matrix: + python: [3.6, 3.8, 3.9, pypy3] + platform: [ubuntu-latest, macos-latest, windows-latest] + runs-on: ${{ matrix.platform }} + steps: + - uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + - name: Install tox + run: | + python -m pip install tox + - name: Run tests + run: tox + + release: + needs: test + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: 3.9 + - name: Install tox + run: | + python -m pip install tox + - name: Release + run: tox -e release + env: + TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TIDELIFT_TOKEN: ${{ secrets.TIDELIFT_TOKEN }} diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml deleted file mode 100644 index 9dc4b9d..0000000 --- a/.github/workflows/python-tests.yml +++ /dev/null @@ -1,138 +0,0 @@ -name: >- - 👷 - Test suite - -on: - push: - pull_request: - schedule: - - cron: 1 0 * * * # Run daily at 0:01 UTC - -jobs: - tests: - name: >- - ${{ matrix.python-version }} - / - ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - # max-parallel: 5 - matrix: - python-version: - - 3.9 - - 3.8 - - pypy3 - - 3.7 - - 3.6 - os: - - ubuntu-18.04 - - ubuntu-16.04 - - macOS-latest - # - windows-2019 - # - windows-2016 - include: - # Dev versions (deadsnakes) - - os: ubuntu-20.04 - python-version: 3.9-dev - - os: ubuntu-20.04 - python-version: 3.8-dev - - env: - NETWORK_REQUIRED: 1 - PYTHON_VERSION: ${{ matrix.python-version }} - TOX_PARALLEL_NO_SPINNER: 1 - TOXENV: python - USE_DEADSNAKES: false - - steps: - - uses: actions/checkout@master - - name: Set flag to use deadsnakes - if: >- - endsWith(env.PYTHON_VERSION, '-beta') || - endsWith(env.PYTHON_VERSION, '-dev') - # FIXME: replace `set-env` with a newer alternative - # Refs: - # * github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/ - env: - ACTIONS_ALLOW_UNSECURE_COMMANDS: true - run: | - from __future__ import print_function - import os - python_version = '${{ env.PYTHON_VERSION }}'.replace('-beta', '') - with open(os.environ['GITHUB_ENV'], 'a') as env_file: - env_file.write('PYTHON_VERSION={ver}\n'.format(ver=python_version)) - env_file.write('USE_DEADSNAKES=true\n') - shell: python - - name: Set up Python ${{ env.PYTHON_VERSION }} (deadsnakes) - uses: deadsnakes/action@v2.0.1 - if: fromJSON(env.USE_DEADSNAKES) && true || false - with: - python-version: ${{ env.PYTHON_VERSION }} - - name: Set up Python ${{ env.PYTHON_VERSION }} - uses: actions/setup-python@v2 - if: >- - !fromJSON(env.USE_DEADSNAKES) && true || false - with: - python-version: ${{ env.PYTHON_VERSION }} - - name: Log Python version - run: >- - python --version - - name: Log Python location - run: >- - which python - - name: Log Python env - run: >- - python -m sysconfig - - name: Pip cache - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }} - restore-keys: | - ${{ runner.os }}-pip- - ${{ runner.os }}- - - name: Upgrade pip/setuptools/wheel - run: >- - python - -m pip install - --disable-pip-version-check - --upgrade - pip setuptools wheel - - name: Install tox - run: >- - python -m pip install --upgrade tox tox-venv - - name: Log installed dists - run: >- - python -m pip freeze --all - - name: Adjust TOXENV for PyPy - if: startsWith(env.PYTHON_VERSION, 'pypy') - run: >- - echo "TOXENV=${{ env.PYTHON_VERSION }}" - >> - "${GITHUB_ENV}" - - name: Log env vars - run: >- - env - - - name: Verify that there's no cached Python modules in sources - if: >- - ! startsWith(matrix.os, 'windows-') - run: >- - ! grep pyc setuptools.egg-info/SOURCES.txt - - - name: 'Initialize tox envs: ${{ matrix.env.TOXENV }}' - run: >- - python -m - tox - --parallel auto - --parallel-live - --notest - --skip-missing-interpreters false - - name: Test with tox - run: >- - python -m - tox - --parallel auto - --parallel-live - -- - -vvvvv diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..6639c78 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,10 @@ +repos: +- repo: https://github.com/psf/black + rev: stable + hooks: + - id: black + +- repo: https://github.com/asottile/blacken-docs + rev: v1.8.0 + hooks: + - id: blacken-docs diff --git a/.readthedocs.yml b/.readthedocs.yml index 6a40653..850d79c 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,8 +1,4 @@ -# Read the Docs configuration file -# https://docs.readthedocs.io/en/stable/config-file/v2.html - version: 2 - python: install: - requirements: docs/requirements.txt diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8b945bd..0000000 --- a/.travis.yml +++ /dev/null @@ -1,60 +0,0 @@ -dist: xenial -language: python - -jobs: - fast_finish: true - include: - - python: pypy3 - - python: 3.6 - - python: 3.7 - - &latest_py3 - python: 3.8 - - <<: *latest_py3 - env: LANG=C - - python: 3.8-dev - - python: 3.9-dev - - <<: *latest_py3 - env: TOXENV=docs - - arch: ppc64le - python: pypy3 - - arch: ppc64le - python: 3.6 - - &latest_py3_ppc - arch: ppc64le - python: 3.8 - - <<: *latest_py3_ppc - env: LANG=C - - arch: ppc64le - python: 3.9-dev - allow_failures: - # suppress failures due to pypa/setuptools#2000 - - python: pypy3 - - <<: *latest_py3 - env: TOXENV=docs - - -cache: pip - -before_install: -- python tools/ppc64le-patch.py - -install: - -# ensure we have recent pip/setuptools/wheel -- pip install --disable-pip-version-check --upgrade pip setuptools wheel -# need tox to get started -- pip install --upgrade tox tox-venv - -# Output the env, to verify behavior -- pip freeze --all -- env - -- "! grep pyc setuptools.egg-info/SOURCES.txt" - -script: - - export NETWORK_REQUIRED=1 - - tox - -after_success: - - export TRAVIS_JOB_NAME="${TRAVIS_PYTHON_VERSION} (LANG=$LANG)" CODECOV_ENV=TRAVIS_JOB_NAME - - tox -e coverage,codecov diff --git a/CHANGES.rst b/CHANGES.rst index 5513387..fb5725c 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,21 @@ +v51.1.0 +------- + + +Changes +^^^^^^^ +* #2486: Project adopts jaraco/skeleton for shared package maintenance. + +Misc +^^^^ +* #2477: Restore inclusion of rst files in sdist. +* #2484: Setuptools has replaced the master branch with the main branch. +* #2485: Fixed failing test when pip 20.3+ is present. + -- by :user:`yan12125` +* #2487: Fix tests with pytest 6.2 + -- by :user:`yan12125` + + v51.0.0 ------- diff --git a/LICENSE b/LICENSE index 6e0693b..353924b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,19 +1,19 @@ -Copyright (C) 2016 Jason R Coombs +Copyright Jason R. Coombs -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -of the Software, and to permit persons to whom the Software is furnished to do -so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +IN THE SOFTWARE. diff --git a/MANIFEST.in b/MANIFEST.in index 128ae28..eba40c5 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,10 +1,12 @@ -recursive-include setuptools *.py *.exe *.xml +recursive-include setuptools *.py *.exe *.xml *.tmpl recursive-include tests *.py recursive-include setuptools/tests *.html -recursive-include docs *.py *.txt *.conf *.css *.css_t Makefile indexsidebar.html +recursive-include docs *.py *.txt *.rst *.conf *.css *.css_t Makefile indexsidebar.html recursive-include setuptools/_vendor *.py *.txt recursive-include pkg_resources *.py *.txt recursive-include pkg_resources/tests/data * +recursive-include tools * +recursive-include changelog.d * include *.py include *.rst include MANIFEST.in diff --git a/README.rst b/README.rst index 824a033..526d122 100644 --- a/README.rst +++ b/README.rst @@ -6,14 +6,13 @@ .. _PyPI link: https://pypi.org/project/setuptools -.. image:: https://dev.azure.com/jaraco/setuptools/_apis/build/status/pypa.setuptools?branchName=master - :target: https://dev.azure.com/jaraco/setuptools/_build/latest?definitionId=1&branchName=master +.. image:: https://github.com/pypa/setuptools/workflows/Automated%20Tests/badge.svg + :target: https://github.com/pypa/setuptools/actions?query=workflow%3A%22Automated+Tests%22 + :alt: Automated Tests -.. image:: https://img.shields.io/travis/pypa/setuptools/master.svg?label=Linux%20CI&logo=travis&logoColor=white - :target: https://travis-ci.org/pypa/setuptools - -.. image:: https://img.shields.io/appveyor/ci/pypa/setuptools/master.svg?label=Windows%20CI&logo=appveyor&logoColor=white - :target: https://ci.appveyor.com/project/pypa/setuptools/branch/master +.. image:: https://img.shields.io/badge/code%20style-black-000000.svg + :target: https://github.com/psf/black + :alt: Code style: Black .. image:: https://img.shields.io/readthedocs/setuptools/latest.svg :target: https://setuptools.readthedocs.io @@ -35,9 +34,13 @@ Bug reports and especially tested patches may be submitted directly to the `bug tracker `_. -To report a security vulnerability, please use the -`Tidelift security contact `_. -Tidelift will coordinate the fix and disclosure. + +Code of Conduct +=============== + +Everyone interacting in the setuptools project's codebases, issue trackers, +chat rooms, and mailing lists is expected to follow the +`PSF Code of Conduct `_. For Enterprise @@ -49,9 +52,10 @@ Setuptools and the maintainers of thousands of other packages are working with T `Learn more `_. -Code of Conduct -=============== -Everyone interacting in the setuptools project's codebases, issue trackers, -chat rooms, and mailing lists is expected to follow the -`PSF Code of Conduct `_. +Security Contact +================ + +To report a security vulnerability, please use the +`Tidelift security contact `_. +Tidelift will coordinate the fix and disclosure. diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 8c24ec3..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,50 +0,0 @@ -clone_depth: 50 - -environment: - - APPVEYOR: True - NETWORK_REQUIRED: True - CODECOV_ENV: APPVEYOR_JOB_NAME - - matrix: - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - APPVEYOR_JOB_NAME: "Python38-x64-vs2015" - PYTHON: "C:\\Python38-x64" - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - APPVEYOR_JOB_NAME: "Python38-x64-vs2017" - PYTHON: "C:\\Python38-x64" - - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - APPVEYOR_JOB_NAME: "Python38-x64-vs2019" - PYTHON: "C:\\Python38-x64" - - APPVEYOR_JOB_NAME: "python37-x64" - PYTHON: "C:\\Python37-x64" - - APPVEYOR_JOB_NAME: "python36-x64" - PYTHON: "C:\\Python36-x64" - -install: - # symlink python from a directory with a space - - "mklink /d \"C:\\Program Files\\Python\" %PYTHON%" - - "SET PYTHON=\"C:\\Program Files\\Python\"" - - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%" - -build: off - -cache: - - '%LOCALAPPDATA%\pip\Cache' - -test_script: - - python --version - - python -m pip install --disable-pip-version-check --upgrade pip setuptools wheel - - pip install --upgrade tox tox-venv virtualenv - - pip freeze --all - - tox -- --junit-xml=test-results.xml - -after_test: - - tox -e coverage,codecov - -on_finish: - - ps: | - $wc = New-Object 'System.Net.WebClient' - $wc.UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\test-results.xml)) - -version: '{build}' diff --git a/azure-pipelines.yml b/azure-pipelines.yml deleted file mode 100644 index 4567b9b..0000000 --- a/azure-pipelines.yml +++ /dev/null @@ -1,82 +0,0 @@ -# Create the project in Azure with: -# az devops project create --name $name --organization https://dev.azure.com/$org/ --visibility public -# then configure the pipelines (through web UI) - -trigger: - branches: - include: - - '*' - tags: - include: - - '*' - -pool: - vmImage: $(pool_vm_image) - -variables: -- group: Azure secrets -- name: pool_vm_image - value: Ubuntu-18.04 - -stages: -- stage: Test - jobs: - - - job: 'Test' - strategy: - matrix: - Bionic Python 3.6: - python.version: '3.6' - Bionic Python 3.8: - python.version: '3.8' - Windows: - python.version: '3.8' - pool_vm_image: vs2017-win2016 - MacOS: - python.version: '3.8' - pool_vm_image: macos-10.15 - - maxParallel: 4 - - steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: '$(python.version)' - architecture: 'x64' - - - script: python -m pip install tox - displayName: 'Install tox' - - - script: | - tox -- --junit-xml=test-results.xml - displayName: 'run tests' - - - task: PublishTestResults@2 - inputs: - testResultsFiles: '**/test-results.xml' - testRunTitle: 'Python $(python.version)' - condition: succeededOrFailed() - -- stage: Publish - dependsOn: Test - jobs: - - job: 'Publish' - - steps: - - task: UsePythonVersion@0 - inputs: - versionSpec: '3.8' - architecture: 'x64' - - - script: python -m pip install tox - displayName: 'Install tox' - - - script: | - tox -e release - env: - TWINE_PASSWORD: $(PyPI-token) - TIDELIFT_TOKEN: $(Tidelift-token) - GITHUB_TOKEN: $(Github-token) - displayName: 'publish to PyPI' - - condition: contains(variables['Build.SourceBranch'], 'tags') diff --git a/docs/_templates/tidelift-sidebar.html b/docs/_templates/tidelift-sidebar.html new file mode 100644 index 0000000..ce48f46 --- /dev/null +++ b/docs/_templates/tidelift-sidebar.html @@ -0,0 +1,6 @@ +

For Enterprise

+ +

+Professionally-supported {{ project }} is available with the +Tidelift Subscription. +

diff --git a/docs/conf.py b/docs/conf.py index 982f5e6..8cb959d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,80 +1,14 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + import subprocess import sys import os -# hack to run the bootstrap script so that jaraco.packaging.sphinx -# can invoke setup.py -'READTHEDOCS' in os.environ and subprocess.check_call( - [sys.executable, '-m', 'bootstrap'], - cwd=os.path.join(os.path.dirname(__file__), os.path.pardir), -) - -# -- Project information ----------------------------------------------------- - -github_url = 'https://github.com' -github_sponsors_url = f'{github_url}/sponsors' - -# -- General configuration -- - -extensions = [ - 'sphinx.ext.extlinks', # allows to create custom roles easily - 'jaraco.packaging.sphinx', - 'rst.linker', -] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The master toctree document. -master_doc = 'index' - -# List of directories, relative to source directory, that shouldn't be searched -# for source files. -exclude_trees = [] - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - -# -- Options for extlinks extension --------------------------------------- -extlinks = { - 'user': (f'{github_sponsors_url}/%s', '@'), # noqa: WPS323 -} - -# -- Options for HTML output -- - -# The theme to use for HTML and HTML Help pages. Major themes that come with -# Sphinx are currently 'default' and 'sphinxdoc'. -html_theme = 'nature' - -# Add any paths that contain custom themes here, relative to this directory. -html_theme_path = ['_theme'] +extensions = ['sphinx.ext.autodoc', 'jaraco.packaging.sphinx', 'rst.linker'] -# If true, SmartyPants will be used to convert quotes and dashes to -# typographically correct entities. -html_use_smartypants = True - -# Custom sidebar templates, maps document names to template names. -html_sidebars = { - 'index': [ - 'relations.html', 'sourcelink.html', 'indexsidebar.html', - 'searchbox.html']} - -# If false, no module index is generated. -html_use_modindex = False - -# If false, no index is generated. -html_use_index = False - -# -- Options for LaTeX output -- - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, -# documentclass [howto/manual]). -latex_documents = [( - 'index', 'Setuptools.tex', 'Setuptools Documentation', - 'The fellowship of the packaging', 'manual', -)] +master_doc = "index" link_files = { '../CHANGES.rst': dict( @@ -148,10 +82,30 @@ link_files = { } +# hack to run the bootstrap script so that jaraco.packaging.sphinx +# can invoke setup.py +'READTHEDOCS' in os.environ and subprocess.check_call( + [sys.executable, '-m', 'bootstrap'], + cwd=os.path.join(os.path.dirname(__file__), os.path.pardir), +) + + +# Add support for linking usernames +github_url = 'https://github.com' +github_sponsors_url = f'{github_url}/sponsors' +extlinks = { + 'user': (f'{github_sponsors_url}/%s', '@'), # noqa: WPS323 +} +extensions += ['sphinx.ext.extlinks'] + # Be strict about any broken references: nitpicky = True - # Ref: https://github.com/python-attrs/attrs/pull/571/files\ # #diff-85987f48f1258d9ee486e3191495582dR82 default_role = 'any' + +# Custom sidebar templates, maps document names to template names. +html_theme = 'alabaster' +templates_path = ['_templates'] +html_sidebars = {'index': ['tidelift-sidebar.html']} diff --git a/docs/userguide/quickstart.rst b/docs/userguide/quickstart.rst index 3098982..1d557d4 100644 --- a/docs/userguide/quickstart.rst +++ b/docs/userguide/quickstart.rst @@ -71,7 +71,7 @@ file in the ``dist`` directory), which you can upload to PyPI! Of course, before you release your project to PyPI, you'll want to add a bit more information to your setup script to help people find or learn about your project. And maybe your project will have grown by then to include a few -dependencies, and perhaps some data files and scripts. In the next few section, +dependencies, and perhaps some data files and scripts. In the next few sections, we will walk through those additional but essential information you need to specify to properly package your project. diff --git a/mypy.ini b/mypy.ini new file mode 100644 index 0000000..976ba02 --- /dev/null +++ b/mypy.ini @@ -0,0 +1,2 @@ +[mypy] +ignore_missing_imports = True diff --git a/pkg_resources/tests/test_resources.py b/pkg_resources/tests/test_resources.py index b08bb29..965a7c0 100644 --- a/pkg_resources/tests/test_resources.py +++ b/pkg_resources/tests/test_resources.py @@ -773,7 +773,7 @@ class TestNamespaces: ns_str = "__import__('pkg_resources').declare_namespace(__name__)\n" - @pytest.yield_fixture + @pytest.fixture def symlinked_tmpdir(self, tmpdir): """ Where available, return the tempdir as a symlink, @@ -791,7 +791,7 @@ class TestNamespaces: finally: os.unlink(link_name) - @pytest.yield_fixture(autouse=True) + @pytest.fixture(autouse=True) def patched_path(self, tmpdir): """ Patch sys.path to include the 'site-pkgs' dir. Also diff --git a/pyproject.toml b/pyproject.toml index 2d36286..658514d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,6 +7,25 @@ requires = [ build-backend = "setuptools.build_meta" backend-path = ["."] +[tool.black] +skip-string-normalization = true + +[tool.setuptools_scm] + +# jaraco/skeleton#22 +[tool.jaraco.pytest.plugins.black] +#addopts = "--black" + +# jaraco/skeleton#22 +[tool.jaraco.pytest.plugins.mypy] +#addopts = "--mypy" + +[tool.jaraco.pytest.plugins.flake8] +addopts = "--flake8" + +[tool.jaraco.pytest.plugins.cov] +addopts = "--cov" + [tool.towncrier] package = "setuptools" package_dir = "setuptools" @@ -41,9 +60,3 @@ backend-path = ["."] directory = "misc" name = "Misc" showcontent = true - -[tool.jaraco.pytest.plugins.flake8] -addopts = "--flake8" - -[tool.jaraco.pytest.plugins.cov] -addopts = "--cov" diff --git a/pytest.ini b/pytest.ini index 162ad87..03fc773 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,8 +1,15 @@ [pytest] -addopts=--doctest-modules --doctest-glob=pkg_resources/api_tests.txt -r sxX norecursedirs=dist build .tox .eggs -doctest_optionflags=ELLIPSIS ALLOW_UNICODE -filterwarnings = +addopts= + --doctest-modules + --doctest-glob=pkg_resources/api_tests.txt + -r sxX +doctest_optionflags=ALLOW_UNICODE ELLIPSIS +# workaround for warning pytest-dev/pytest#6178 +junit_family=xunit2 +filterwarnings= + # https://github.com/pytest-dev/pytest/issues/6928 + ignore:direct construction of .*Item has been deprecated:DeprecationWarning # Fail on warnings error # https://github.com/pypa/setuptools/issues/1823 diff --git a/setup.cfg b/setup.cfg index 570bd28..6ef70e2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,82 +1,79 @@ -[egg_info] -tag_build = .post -tag_date = 1 - -[aliases] -clean_egg_info = egg_info -Db '' -release = clean_egg_info sdist bdist_wheel -source = register sdist binary -binary = bdist_egg upload --show-response - -[upload] -repository = https://upload.pypi.org/legacy/ - -[sdist] -formats = zip - [metadata] +license_file = LICENSE name = setuptools -version = 51.0.0 -description = Easily download, build, install, upgrade, and uninstall Python packages +version = 51.1.0 author = Python Packaging Authority author_email = distutils-sig@python.org -long_description = file: README.rst -long_description_content_type = text/x-rst; charset=UTF-8 -license_file = LICENSE -keywords = CPAN PyPI distutils eggs package management +description = Easily download, build, install, upgrade, and uninstall Python packages +long_description = file:README.rst url = https://github.com/pypa/setuptools -project_urls = - Documentation = https://setuptools.readthedocs.io/ classifiers = - Development Status :: 5 - Production/Stable - Intended Audience :: Developers - License :: OSI Approved :: MIT License - Operating System :: OS Independent - Programming Language :: Python :: 3 - Programming Language :: Python :: 3 :: Only - Programming Language :: Python :: 3.6 - Programming Language :: Python :: 3.7 - Programming Language :: Python :: 3.8 - Programming Language :: Python :: 3.9 + Development Status :: 5 - Production/Stable + Intended Audience :: Developers + License :: OSI Approved :: MIT License + Programming Language :: Python :: 3 + Programming Language :: Python :: 3 :: Only Topic :: Software Development :: Libraries :: Python Modules Topic :: System :: Archiving :: Packaging Topic :: System :: Systems Administration Topic :: Utilities +keywords = CPAN PyPI distutils eggs package management +project_urls = + Documentation = https://setuptools.readthedocs.io/ [options] -zip_safe = True -python_requires = >=3.6 -py_modules = easy_install packages = find: +py_modules = easy_install +include_package_data = true +python_requires = >=3.6 +install_requires = [options.packages.find] exclude = *.tests [options.extras_require] -ssl = - wincertstore==0.2; sys_platform=='win32' - -certs = - certifi==2016.9.26 +testing = + # upstream + pytest >= 3.5, !=3.7.3 + pytest-checkdocs >= 1.2.3 + pytest-flake8 + pytest-black >= 0.3.7; python_implementation != "PyPy" + pytest-cov + pytest-mypy; python_implementation != "PyPy" + # jaraco/skeleton#22 + jaraco.test >= 3.2.0 -tests = + # local mock - pytest-flake8 flake8-2020 virtualenv>=13.0.0 pytest-virtualenv>=1.2.7 - pytest>=3.7 wheel - coverage>=4.5.1 - pytest-cov>=2.5.1 paver pip>=19.1 # For proper file:// URLs support. jaraco.envs - jaraco.test >= 3.1.1; python_version >= "3.6" docs = # Keep these in sync with docs/requirements.txt - sphinx - jaraco.packaging>=6.1 - rst.linker>=1.9 + # upstream + sphinx + jaraco.packaging >= 6.1 + rst.linker >= 1.9 + + # local pygments-github-lexers==0.0.5 + +ssl = + wincertstore==0.2; sys_platform=='win32' + +certs = + certifi==2016.9.26 + +[options.entry_points] + +[egg_info] +tag_build = .post +tag_date = 1 + +[sdist] +formats = zip diff --git a/setup.py b/setup.py index 2bd48da..28d3dad 100755 --- a/setup.py +++ b/setup.py @@ -1,7 +1,4 @@ #!/usr/bin/env python -""" -Distutils setup file, used to install or test 'setuptools' -""" import os import sys diff --git a/setuptools/tests/fixtures.py b/setuptools/tests/fixtures.py index 5204c8d..e8cb7f5 100644 --- a/setuptools/tests/fixtures.py +++ b/setuptools/tests/fixtures.py @@ -3,7 +3,7 @@ import pytest from . import contexts -@pytest.yield_fixture +@pytest.fixture def user_override(monkeypatch): """ Override site.USER_BASE and site.USER_SITE with temporary directories in @@ -17,7 +17,7 @@ def user_override(monkeypatch): yield -@pytest.yield_fixture +@pytest.fixture def tmpdir_cwd(tmpdir): with tmpdir.as_cwd() as orig: yield orig diff --git a/setuptools/tests/test_build_meta.py b/setuptools/tests/test_build_meta.py index 5462b26..6d3a997 100644 --- a/setuptools/tests/test_build_meta.py +++ b/setuptools/tests/test_build_meta.py @@ -108,7 +108,7 @@ defns = [ 'setup.cfg': DALS(""" [metadata] name = foo - version='0.0.0' + version = 0.0.0 [options] py_modules=hello diff --git a/setuptools/tests/test_develop.py b/setuptools/tests/test_develop.py index 9854420..2766da2 100644 --- a/setuptools/tests/test_develop.py +++ b/setuptools/tests/test_develop.py @@ -31,7 +31,7 @@ INIT_PY = """print "foo" """ -@pytest.yield_fixture +@pytest.fixture def temp_user(monkeypatch): with contexts.tempdir() as user_base: with contexts.tempdir() as user_site: @@ -40,7 +40,7 @@ def temp_user(monkeypatch): yield -@pytest.yield_fixture +@pytest.fixture def test_env(tmpdir, temp_user): target = tmpdir foo = target.mkdir('foo') diff --git a/setuptools/tests/test_easy_install.py b/setuptools/tests/test_easy_install.py index 26a5e9a..dc00e69 100644 --- a/setuptools/tests/test_easy_install.py +++ b/setuptools/tests/test_easy_install.py @@ -305,7 +305,7 @@ class TestPTHFileWriter: assert not pth.dirty -@pytest.yield_fixture +@pytest.fixture def setup_context(tmpdir): with (tmpdir / 'setup.py').open('w') as f: f.write(SETUP_PY) @@ -361,7 +361,7 @@ class TestUserInstallTest: f.write('Name: foo\n') return str(tmpdir) - @pytest.yield_fixture() + @pytest.fixture() def install_target(self, tmpdir): target = str(tmpdir) with mock.patch('sys.path', sys.path + [target]): @@ -406,7 +406,7 @@ class TestUserInstallTest: ) -@pytest.yield_fixture +@pytest.fixture def distutils_package(): distutils_setup_py = SETUP_PY.replace( 'from setuptools import setup', diff --git a/setuptools/tests/test_egg_info.py b/setuptools/tests/test_egg_info.py index dc472af..1047468 100644 --- a/setuptools/tests/test_egg_info.py +++ b/setuptools/tests/test_egg_info.py @@ -45,7 +45,7 @@ class TestEggInfo: """) }) - @pytest.yield_fixture + @pytest.fixture def env(self): with contexts.tempdir(prefix='setuptools-test.') as env_dir: env = Environment(env_dir) diff --git a/setuptools/tests/test_integration.py b/setuptools/tests/test_integration.py index 04ba62f..b557831 100644 --- a/setuptools/tests/test_integration.py +++ b/setuptools/tests/test_integration.py @@ -15,6 +15,13 @@ from setuptools.command import easy_install as easy_install_pkg from setuptools.dist import Distribution +pytestmark = pytest.mark.skipif( + 'platform.python_implementation() == "PyPy" and ' + 'platform.system() == "Windows"', + reason="pypa/setuptools#2496", +) + + def setup_module(module): packages = 'stevedore', 'virtualenvwrapper', 'pbr', 'novaclient' for pkg in packages: diff --git a/setuptools/tests/test_msvc.py b/setuptools/tests/test_msvc.py index 24e38ea..d1527bf 100644 --- a/setuptools/tests/test_msvc.py +++ b/setuptools/tests/test_msvc.py @@ -88,7 +88,7 @@ class TestModulePatch: assert isinstance(exc, expected) assert 'aka.ms/vcpython27' in str(exc) - @pytest.yield_fixture + @pytest.fixture def user_preferred_setting(self): """ Set up environment with different install dirs for user vs. system @@ -116,7 +116,7 @@ class TestModulePatch: expected = os.path.join(user_preferred_setting, 'vcvarsall.bat') assert expected == result - @pytest.yield_fixture + @pytest.fixture def local_machine_setting(self): """ Set up environment with only the system environment configured. @@ -138,7 +138,7 @@ class TestModulePatch: expected = os.path.join(local_machine_setting, 'vcvarsall.bat') assert expected == result - @pytest.yield_fixture + @pytest.fixture def x64_preferred_setting(self): """ Set up environment with 64-bit and 32-bit system settings configured diff --git a/setuptools/tests/test_virtualenv.py b/setuptools/tests/test_virtualenv.py index c8ed9e5..21dea5b 100644 --- a/setuptools/tests/test_virtualenv.py +++ b/setuptools/tests/test_virtualenv.py @@ -2,8 +2,9 @@ import glob import os import sys +import pathlib + import pytest -from pytest import yield_fixture from pytest_fixture_config import yield_requires_config import pytest_virtualenv @@ -27,7 +28,7 @@ def pytest_virtualenv_works(virtualenv): @yield_requires_config(pytest_virtualenv.CONFIG, ['virtualenv_executable']) -@yield_fixture(scope='function') +@pytest.fixture(scope='function') def bare_virtualenv(): """ Bare virtualenv (no pip/setuptools/wheel). """ @@ -124,7 +125,7 @@ def _check_test_command_install_requirements(virtualenv, tmpdir): make_nspkg_sdist(str(dist_path), distname, version) return dist_path dependency_links = [ - str(dist_path) + pathlib.Path(str(dist_path)).as_uri() for dist_path in ( sdist('foobar', '2.4'), sdist('bits', '4.2'), diff --git a/skeleton.md b/skeleton.md new file mode 100644 index 0000000..ec421c2 --- /dev/null +++ b/skeleton.md @@ -0,0 +1,144 @@ +# Overview + +This project is merged with [skeleton](https://github.com/jaraco/skeleton). What is skeleton? It's the scaffolding of a Python project jaraco [introduced in his blog](https://blog.jaraco.com/a-project-skeleton-for-python-projects/). It seeks to provide a means to re-use techniques and inherit advances when managing projects for distribution. + +## An SCM-Managed Approach + +While maintaining dozens of projects in PyPI, jaraco derives best practices for project distribution and publishes them in the [skeleton repo](https://github.com/jaraco/skeleton), a Git repo capturing the evolution and culmination of these best practices. + +It's intended to be used by a new or existing project to adopt these practices and honed and proven techniques. Adopters are encouraged to use the project directly and maintain a small deviation from the technique, make their own fork for more substantial changes unique to their environment or preferences, or simply adopt the skeleton once and abandon it thereafter. + +The primary advantage to using an SCM for maintaining these techniques is that those tools help facilitate the merge between the template and its adopting projects. + +Another advantage to using an SCM-managed approach is that tools like GitHub recognize that a change in the skeleton is the _same change_ across all projects that merge with that skeleton. Without the ancestry, with a traditional copy/paste approach, a [commit like this](https://github.com/jaraco/skeleton/commit/12eed1326e1bc26ce256e7b3f8cd8d3a5beab2d5) would produce notifications in the upstream project issue for each and every application, but because it's centralized, GitHub provides just the one notification when the change is added to the skeleton. + +# Usage + +## new projects + +To use skeleton for a new project, simply pull the skeleton into a new project: + +``` +$ git init my-new-project +$ cd my-new-project +$ git pull gh://jaraco/skeleton +``` + +Now customize the project to suit your individual project needs. + +## existing projects + +If you have an existing project, you can still incorporate the skeleton by merging it into the codebase. + +``` +$ git merge skeleton --allow-unrelated-histories +``` + +The `--allow-unrelated-histories` is necessary because the history from the skeleton was previously unrelated to the existing codebase. Resolve any merge conflicts and commit to the master, and now the project is based on the shared skeleton. + +## Updating + +Whenever a change is needed or desired for the general technique for packaging, it can be made in the skeleton project and then merged into each of the derived projects as needed, recommended before each release. As a result, features and best practices for packaging are centrally maintained and readily trickle into a whole suite of packages. This technique lowers the amount of tedious work necessary to create or maintain a project, and coupled with other techniques like continuous integration and deployment, lowers the cost of creating and maintaining refined Python projects to just a few, familiar Git operations. + +For example, here's a session of the [path project](https://pypi.org/project/path) pulling non-conflicting changes from the skeleton: + + + +Thereafter, the target project can make whatever customizations it deems relevant to the scaffolding. The project may even at some point decide that the divergence is too great to merit renewed merging with the original skeleton. This approach applies maximal guidance while creating minimal constraints. + +# Features + +The features/techniques employed by the skeleton include: + +- PEP 517/518-based build relying on Setuptools as the build tool +- Setuptools declarative configuration using setup.cfg +- tox for running tests +- A README.rst as reStructuredText with some popular badges, but with Read the Docs and AppVeyor badges commented out +- A CHANGES.rst file intended for publishing release notes about the project +- Use of [Black](https://black.readthedocs.io/en/stable/) for code formatting (disabled on unsupported Python 3.5 and earlier) +- Integrated type checking through [mypy](https://github.com/python/mypy/). + +## Packaging Conventions + +A pyproject.toml is included to enable PEP 517 and PEP 518 compatibility and declares the requirements necessary to build the project on Setuptools (a minimum version compatible with setup.cfg declarative config). + +The setup.cfg file implements the following features: + +- Assumes universal wheel for release +- Advertises the project's LICENSE file (MIT by default) +- Reads the README.rst file into the long description +- Some common Trove classifiers +- Includes all packages discovered in the repo +- Data files in the package are also included (not just Python files) +- Declares the required Python versions +- Declares install requirements (empty by default) +- Declares setup requirements for legacy environments +- Supplies two 'extras': + - testing: requirements for running tests + - docs: requirements for building docs + - these extras split the declaration into "upstream" (requirements as declared by the skeleton) and "local" (those specific to the local project); these markers help avoid merge conflicts +- Placeholder for defining entry points + +Additionally, the setup.py file declares `use_scm_version` which relies on [setuptools_scm](https://pypi.org/project/setuptools_scm) to do two things: + +- derive the project version from SCM tags +- ensure that all files committed to the repo are automatically included in releases + +## Running Tests + +The skeleton assumes the developer has [tox](https://pypi.org/project/tox) installed. The developer is expected to run `tox` to run tests on the current Python version using [pytest](https://pypi.org/project/pytest). + +Other environments (invoked with `tox -e {name}`) supplied include: + + - a `docs` environment to build the documentation + - a `release` environment to publish the package to PyPI + +A pytest.ini is included to define common options around running tests. In particular: + +- rely on default test discovery in the current directory +- avoid recursing into common directories not containing tests +- run doctests on modules and invoke Flake8 tests +- in doctests, allow Unicode literals and regular literals to match, allowing for doctests to run on Python 2 and 3. Also enable ELLIPSES, a default that would be undone by supplying the prior option. +- filters out known warnings caused by libraries/functionality included by the skeleton + +Relies on a .flake8 file to correct some default behaviors: + +- disable mutually incompatible rules W503 and W504 +- support for Black format + +## Continuous Integration + +The project is pre-configured to run Continuous Integration tests. + +### Github Actions + +[Github Actions](https://docs.github.com/en/free-pro-team@latest/actions) are the preferred provider as they provide free, fast, multi-platform services with straightforward configuration. Configured in `.github/workflows`. + +Features include: +- test against multiple Python versions +- run on late (and updated) platform versions +- automated releases of tagged commits + +### Continuous Deployments + +In addition to running tests, an additional publish stage is configured to automatically release tagged commits to PyPI using [API tokens](https://pypi.org/help/#apitoken). The release process expects an authorized token to be configured with each Github project (or org) `PYPI_TOKEN` [secret](https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets). Example: + +``` +pip-run -q jaraco.develop -- -m jaraco.develop.add-github-secrets +``` + +## Building Documentation + +Documentation is automatically built by [Read the Docs](https://readthedocs.org) when the project is registered with it, by way of the .readthedocs.yml file. To test the docs build manually, a tox env may be invoked as `tox -e docs`. Both techniques rely on the dependencies declared in `setup.cfg/options.extras_require.docs`. + +In addition to building the Sphinx docs scaffolded in `docs/`, the docs build a `history.html` file that first injects release dates and hyperlinks into the CHANGES.rst before incorporating it as history in the docs. + +## Cutting releases + +By default, tagged commits are released through the continuous integration deploy stage. + +Releases may also be cut manually by invoking the tox environment `release` with the PyPI token set as the TWINE_PASSWORD: + +``` +TWINE_PASSWORD={token} tox -e release +``` diff --git a/tox.ini b/tox.ini index 828d2c0..9680ec0 100644 --- a/tox.ini +++ b/tox.ini @@ -1,31 +1,22 @@ -# To run Tox against all supported Python interpreters, you can set: -# -# export TOXENV='py3{5,6,7,8},pypy,pypy3' - [tox] -envlist=python +envlist = python minversion = 3.2 -requires = - tox-pip-version >= 0.0.6 - -[helpers] -# Custom pip behavior -pip = python {toxinidir}/tools/tox_pip.py +# https://github.com/jaraco/skeleton/issues/6 +tox_pip_extensions_ext_venv_update = true +toxworkdir={env:TOX_WORK_DIR:.tox} [testenv] -pip_version = pip +deps = +commands = + pytest {posargs} +usedevelop = True +extras = testing install_command = {[helpers]pip} install {opts} {packages} list_dependencies_command = {[helpers]pip} freeze --all setenv = COVERAGE_FILE={toxworkdir}/.coverage.{envname} -# TODO: The passed environment variables came from copying other tox.ini files -# These should probably be individually annotated to explain what needs them. -passenv=APPDATA HOMEDRIVE HOMEPATH windir Program* CommonProgram* VS* APPVEYOR APPVEYOR_* CI CODECOV_* TRAVIS TRAVIS_* NETWORK_REQUIRED -commands = pytest {posargs} -usedevelop=True -extras = - tests - +passenv = + windir # required for test_pkg_resources [testenv:coverage] description=Combine coverage data and create report @@ -45,20 +36,11 @@ commands=codecov -X gcov --file {toxworkdir}/coverage.xml [testenv:docs] extras = - docs - testing + docs + testing changedir = docs commands = - {envpython} -m sphinx \ - -j auto \ - -b html \ - --color \ - -a \ - -n \ - -W \ - -d "{temp_dir}/.doctrees" \ - . \ - "{toxinidir}/build/html" + python -m sphinx -W . {toxinidir}/build/html [testenv:finalize] skip_install = True @@ -72,7 +54,7 @@ commands = [testenv:release] skip_install = True deps = - wheel + pep517>=0.5 twine[keyring]>=1.13 path jaraco.develop>=7.1 @@ -86,7 +68,13 @@ setenv = commands = python -m bootstrap python -c "import path; path.Path('dist').rmtree_p()" - python setup.py release + # unset tag_build and tag_date pypa/setuptools#2500 + python setup.py egg_info -Db "" saveopts + python -m pep517.build . python -m twine upload dist/* python -m jaraco.develop.create-github-release python -m jaraco.tidelift.publish-release-notes + +[helpers] +# Custom pip behavior +pip = python {toxinidir}/tools/tox_pip.py