From 86e999fe01503273ffdd7ef4941623c6dd2272f6 Mon Sep 17 00:00:00 2001 From: jbannister Date: Fri, 30 Aug 2024 13:02:50 +0100 Subject: [PATCH 1/9] Experiment with new versions of python --- .circleci/config.yml | 40 ++++++++++++++++++++++++++++++++++++++++ install.sh | 13 ++++++------- 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4d312e1..3a113ed 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -160,6 +160,31 @@ jobs: environment: PYTHON: "python3.7" + py38: + <<: *job-tmpl + environment: + PYTHON: "python3.8" + + py39: + <<: *job-tmpl + environment: + PYTHON: "python3.9" + + py310: + <<: *job-tmpl + environment: + PYTHON: "python3.10" + + py311: + <<: *job-tmpl + environment: + PYTHON: "python3.11" + + py312: + <<: *job-tmpl + environment: + PYTHON: "python3.12" + pypi-release: docker: - image: cimg/python:3.11.0 @@ -221,10 +246,20 @@ workflows: jobs: - py36 - py37 + - py38 + - py39 + - py310 + - py311 + - py312 - pypi-release: requires: - py36 - py37 + - py38 + - py39 + - py310 + - py311 + - py312 filters: branches: only: @@ -233,6 +268,11 @@ workflows: requires: - py36 - py37 + - py38 + - py39 + - py310 + - py311 + - py312 filters: branches: only: diff --git a/install.sh b/install.sh index ef6cac8..2b53362 100644 --- a/install.sh +++ b/install.sh @@ -36,16 +36,15 @@ function install_python_packaging { function install_python { local py=$1 sudo apt-get install -y $py $py-dev - if [ "$py" = "python3.6" ]; then - sudo apt-get install python3.6-distutils || { - curl --silent --show-error --retry 5 https://bootstrap.pypa.io/pip/3.6/get-pip.py | sudo $py + local version=$(echo $py | cut -d'.' -f1-2) + + if [ "$version" = "3.6" ] || [ "$version" = "3.7" ]; then + sudo apt-get install ${py}-distutils || { + curl --silent --show-error --retry 5 https://bootstrap.pypa.io/pip/$version/get-pip.py | sudo $py sudo $py -m pip install setuptools } else - sudo apt-get install python3.7-distutils || { - curl --silent --show-error --retry 5 https://bootstrap.pypa.io/pip/3.7/get-pip.py | sudo $py - sudo $py -m pip install setuptools - } + sudo apt-get install ${py}-distutils fi install_python_packaging $py } From 388b185d82f1c5e01a64517f578a31eea44f25df Mon Sep 17 00:00:00 2001 From: jbannister Date: Fri, 30 Aug 2024 13:12:45 +0100 Subject: [PATCH 2/9] Try using pypa --- install.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 2b53362..94bb647 100644 --- a/install.sh +++ b/install.sh @@ -36,13 +36,16 @@ function install_python_packaging { function install_python { local py=$1 sudo apt-get install -y $py $py-dev - local version=$(echo $py | cut -d'.' -f1-2) - + local version=$(echo $py | grep -oP '(?<=python)\d+\.\d+') + if [ "$version" = "3.6" ] || [ "$version" = "3.7" ]; then sudo apt-get install ${py}-distutils || { curl --silent --show-error --retry 5 https://bootstrap.pypa.io/pip/$version/get-pip.py | sudo $py sudo $py -m pip install setuptools } + elif [ "$version" = "3.10" ] || [ "$version" = "3.11" ] || [ "$version" = "3.12" ]; then + sudo apt-get install ${py}-distutils + curl --silent --show-error --retry 5 https://bootstrap.pypa.io/get-pip.py | sudo $py else sudo apt-get install ${py}-distutils fi From 38abe56ea09d6ffee78398cd38bd35c4bbe41e8a Mon Sep 17 00:00:00 2001 From: jbannister Date: Mon, 2 Sep 2024 16:19:49 +0100 Subject: [PATCH 3/9] Add some debugging to common_setup.py --- common_setup.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/common_setup.py b/common_setup.py index 318fbc2..99a9b57 100644 --- a/common_setup.py +++ b/common_setup.py @@ -27,6 +27,8 @@ def run_tests(self): import pytest self.pytest_args.extend(['--junitxml', 'junit.xml']) + logger = logging.getLogger(__name__) + logger.info("Pytest args are {}".format(str(self.pytest_args))) errno = pytest.main(self.pytest_args) sys.exit(errno) From 6dba02c91a26f42f4afc3af8e663759b7fcdf09a Mon Sep 17 00:00:00 2001 From: jbannister Date: Mon, 2 Sep 2024 18:19:34 +0100 Subject: [PATCH 4/9] Try something a little different --- .circleci/config.yml | 10 +++++++++- common_setup.py | 25 +++++-------------------- pytest-profiling/setup.py | 11 +++++++++-- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3a113ed..0e90014 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,7 +6,15 @@ test-tmpl: &test-tmpl export DEBUG=1 export SERVER_FIXTURES_HOSTNAME=127.0.0.1 export SERVER_FIXTURES_JENKINS_WAR= - cat *.egg-info/top_level.txt | xargs -Ipysrc coverage run -p --source=pysrc setup.py test -sv -ra || touch ../FAILED-$(basename $PWD) + set -x + pwd + cat *.egg-info/top_level.txt + pytest --version + pytest -svvvvvv -ra tests/ + pytest -svvvvvvv -ra $(cat *.egg-info/top_level.txt) + coverage run -p --source=$(cat *.egg-info/top_level.txt | tr '\n' ',') -m pytest -sv -ra $(cat *.egg-info/top_level.txt) + + cat *.egg-info/top_level.txt | xargs -I {} coverage run -p --source={} -m pytest -sv -ra {} || touch ../FAILED-$(basename $PWD) job-tmpl: &job-tmpl machine: diff --git a/common_setup.py b/common_setup.py index 99a9b57..636168e 100644 --- a/common_setup.py +++ b/common_setup.py @@ -4,7 +4,7 @@ import logging from setuptools.command.test import test as TestCommand -from setuptools.command.egg_info import egg_info as EggInfoCommand +from wheel.bdist_wheel import bdist_wheel class PyTest(TestCommand): @@ -20,39 +20,24 @@ def finalize_options(self): self.test_suite = True def run_tests(self): - global pytest_args logging.basicConfig(format='%(asctime)s %(levelname)s %(name)s %(message)s', level='DEBUG') - # import here, cause outside the eggs aren't loaded import pytest - self.pytest_args.extend(['--junitxml', 'junit.xml']) logger = logging.getLogger(__name__) - logger.info("Pytest args are {}".format(str(self.pytest_args))) - errno = pytest.main(self.pytest_args) + logger.info("Pytest args are {}".format(str(PyTest.pytest_args))) + errno = pytest.main(PyTest.pytest_args) sys.exit(errno) -class EggInfo(EggInfoCommand): - """ Customisation of the package metadata creation. Changes are: - - Save the test requirements into an extra called 'tests' - """ - def run(self): - if self.distribution.extras_require is None: - self.distribution.extras_require = {} - if 'tests' not in self.distribution.extras_require and hasattr(self.distribution, 'tests_require'): - self.distribution.extras_require['tests'] = self.distribution.tests_require - EggInfoCommand.run(self) - - def common_setup(src_dir): this_dir = os.path.dirname(__file__) readme_file = os.path.join(this_dir, 'README.md') changelog_file = os.path.join(this_dir, 'CHANGES.md') version_file = os.path.join(this_dir, 'VERSION') + long_description = open(readme_file).read() changelog = open(changelog_file).read() - # Gather trailing arguments for pytest, this can't be done using setuptools' api if 'test' in sys.argv: PyTest.pytest_args = sys.argv[sys.argv.index('test') + 1:] @@ -68,7 +53,7 @@ def common_setup(src_dir): url='https://github.com/man-group/pytest-plugins', license='MIT license', platforms=['unix', 'linux'], - cmdclass={'test': PyTest, 'egg_info': EggInfo}, + cmdclass={'test': PyTest, 'bdist_wheel': bdist_wheel}, include_package_data=True, python_requires='>=3.6', ) diff --git a/pytest-profiling/setup.py b/pytest-profiling/setup.py index 612899a..24ab0b0 100644 --- a/pytest-profiling/setup.py +++ b/pytest-profiling/setup.py @@ -1,8 +1,10 @@ import sys import os -sys.path.append(os.path.dirname(os.path.dirname(__file__))) - from setuptools import setup +from setuptools.command.test import test as TestCommand +from wheel.bdist_wheel import bdist_wheel + +sys.path.append(os.path.dirname(os.path.dirname(__file__))) from common_setup import common_setup classifiers = [ @@ -15,6 +17,11 @@ 'Operating System :: POSIX', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', ] install_requires = ['six', From bea1bb9d76dea0f5b7a6ca2b198228cb2d2aedcd Mon Sep 17 00:00:00 2001 From: jbannister Date: Thu, 17 Oct 2024 17:39:23 +0100 Subject: [PATCH 5/9] Attempt to fix "int" issue with pytest-profiling --- .circleci/config.yml | 4 ++-- pytest-profiling/pytest_profiling.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0e90014..8a4fbee 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -7,7 +7,7 @@ test-tmpl: &test-tmpl export SERVER_FIXTURES_HOSTNAME=127.0.0.1 export SERVER_FIXTURES_JENKINS_WAR= set -x - pwd + pwd cat *.egg-info/top_level.txt pytest --version pytest -svvvvvv -ra tests/ @@ -245,7 +245,7 @@ jobs: -n ${VERSION} \ -b "${CHANGES}" \ -soft \ - ${VERSION} /tmp/to-release/dist + "v${VERSION}" /tmp/to-release/dist workflows: diff --git a/pytest-profiling/pytest_profiling.py b/pytest-profiling/pytest_profiling.py index e6316e6..2d3eed2 100644 --- a/pytest-profiling/pytest_profiling.py +++ b/pytest-profiling/pytest_profiling.py @@ -143,7 +143,7 @@ def pytest_addoption(parser): help="generate profiling graph (using gprof2dot and dot -Tsvg)") group.addoption("--pstats-dir", nargs=1, help="configure the dump directory of profile data files") - group.addoption("--element-number", action="store", type="int", default=20, + group.addoption("--element-number", action="store", type=int, default=20, help="defines how many elements will display in a result") group.addoption("--strip-dirs", action="store_true", help="configure to show/hide the leading path information from file names") From 3885dbec177292b4ef15d4adff13897654f03261 Mon Sep 17 00:00:00 2001 From: Chris Rose Date: Fri, 18 Oct 2024 09:48:58 -0500 Subject: [PATCH 6/9] Change project build to use hatch/pyproject.toml - hatch is chosen because it supports the declarative versioning in `../VERSION` - the pyproject.toml is set up with uv to allow cross-package linking, as well as releasing the code. --- pyproject.toml | 10 ++++++ pytest-profiling/pyproject.toml | 62 +++++++++++++++++++++++++++++++++ pytest-profiling/setup.cfg | 12 ------- pytest-profiling/setup.py | 55 ----------------------------- 4 files changed, 72 insertions(+), 67 deletions(-) create mode 100644 pyproject.toml create mode 100644 pytest-profiling/pyproject.toml delete mode 100644 pytest-profiling/setup.cfg delete mode 100644 pytest-profiling/setup.py diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..9c1a025 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,10 @@ +[project] +name = "pytest-plugins" +version = "0.1.0" +description = "Add your description here" +readme = "README.md" +requires-python = ">=3.10" +dependencies = [] + +[tool.uv.workspace] +members = ["pytest-profiling"] diff --git a/pytest-profiling/pyproject.toml b/pytest-profiling/pyproject.toml new file mode 100644 index 0000000..a989d63 --- /dev/null +++ b/pytest-profiling/pyproject.toml @@ -0,0 +1,62 @@ +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[project] +name = "pytest-profiling" +description = "Profiling plugin for py.test" +readme = "README.md" +readme-content-type = "text/markdown" +license = {text = "MIT"} +authors = [{name = "Ed Catmur", email = "ed@catmur.co.uk"}] +classifiers = [ + "License :: OSI Approved :: MIT License", + "Development Status :: 5 - Production/Stable", + "Topic :: Software Development :: Libraries", + "Topic :: Software Development :: Testing", + "Topic :: Utilities", + "Intended Audience :: Developers", + "Operating System :: POSIX", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", + "Programming Language :: Python :: 3.12" +] +dependencies = ["six", "pytest", "gprof2dot"] +requires-python = ">=3.6" +dynamic = ["version"] + +[tool.hatch.version] +path = "../VERSION" +pattern = "^(?P[^']+)$" + +[tool.hatch.build.targets.wheel] +packages = ["src/pytest_profiling"] + +[project.urls] +homepage = "https://github.com/man-group/pytest-plugins" + +[project.optional-dependencies] +test = ["pytest-virtualenv"] + +[project.entry-points.pytest11] +profiling = "pytest_profiling" + +[tool.pytest.ini_options] +norecursedirs = [".git", "*.egg", "build", "dist", "tests/integration/profile/tests"] + +[tool.wheel] +universal = false + +[tool.uv] +dev-dependencies = [ + "importlib-metadata>=8.5.0", + "importlib-resources>=6.4.5", + "pytest-virtualenv", +] + +[tool.uv.sources] +pytest-virtualenv = { path = "../pytest-virtualenv", editable = true } diff --git a/pytest-profiling/setup.cfg b/pytest-profiling/setup.cfg deleted file mode 100644 index 06ba283..0000000 --- a/pytest-profiling/setup.cfg +++ /dev/null @@ -1,12 +0,0 @@ -[tool:pytest] -# This section sets configuration for all invocations of py.test, -# both standalone cmdline and running via setup.py -norecursedirs = - .git - *.egg - build - dist - tests/integration/profile/tests - -[bdist_wheel] -universal = 0 diff --git a/pytest-profiling/setup.py b/pytest-profiling/setup.py deleted file mode 100644 index 24ab0b0..0000000 --- a/pytest-profiling/setup.py +++ /dev/null @@ -1,55 +0,0 @@ -import sys -import os -from setuptools import setup -from setuptools.command.test import test as TestCommand -from wheel.bdist_wheel import bdist_wheel - -sys.path.append(os.path.dirname(os.path.dirname(__file__))) -from common_setup import common_setup - -classifiers = [ - 'License :: OSI Approved :: MIT License', - 'Development Status :: 5 - Production/Stable', - 'Topic :: Software Development :: Libraries', - 'Topic :: Software Development :: Testing', - 'Topic :: Utilities', - 'Intended Audience :: Developers', - 'Operating System :: POSIX', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Programming Language :: Python :: 3.10', - 'Programming Language :: Python :: 3.11', - 'Programming Language :: Python :: 3.12', -] - -install_requires = ['six', - 'pytest', - 'gprof2dot', - ] - -tests_require = [ - 'pytest-virtualenv', - ] - -entry_points = { - 'pytest11': [ - 'profiling = pytest_profiling', - ] -} - -if __name__ == '__main__': - kwargs = common_setup('pytest_profiling') - kwargs.update(dict( - name='pytest-profiling', - description='Profiling plugin for py.test', - author='Ed Catmur', - author_email='ed@catmur.co.uk', - classifiers=classifiers, - install_requires=install_requires, - tests_require=tests_require, - py_modules=['pytest_profiling'], - entry_points=entry_points, - )) - setup(**kwargs) From 95c9e979cd5b449c4bdde756a2114f5851ec4eed Mon Sep 17 00:00:00 2001 From: Chris Rose Date: Fri, 18 Oct 2024 09:50:45 -0500 Subject: [PATCH 7/9] Lock dependencies for profiling --- uv.lock | 276 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 276 insertions(+) create mode 100644 uv.lock diff --git a/uv.lock b/uv.lock new file mode 100644 index 0000000..14627d5 --- /dev/null +++ b/uv.lock @@ -0,0 +1,276 @@ +version = 1 +requires-python = ">=3.10" + +[manifest] +members = [ + "pytest-plugins", + "pytest-profiling", +] + +[[package]] +name = "colorama" +version = "0.4.6" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335 }, +] + +[[package]] +name = "distlib" +version = "0.3.9" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/0d/dd/1bec4c5ddb504ca60fc29472f3d27e8d4da1257a854e1d96742f15c1d02d/distlib-0.3.9.tar.gz", hash = "sha256:a60f20dea646b8a33f3e7772f74dc0b2d0772d2837ee1342a00645c81edf9403", size = 613923 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/91/a1/cf2472db20f7ce4a6be1253a81cfdf85ad9c7885ffbed7047fb72c24cf87/distlib-0.3.9-py2.py3-none-any.whl", hash = "sha256:47f8c22fd27c27e25a65601af709b38e4f0a45ea4fc2e710f65755fa8caaaf87", size = 468973 }, +] + +[[package]] +name = "exceptiongroup" +version = "1.2.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/09/35/2495c4ac46b980e4ca1f6ad6db102322ef3ad2410b79fdde159a4b0f3b92/exceptiongroup-1.2.2.tar.gz", hash = "sha256:47c2edf7c6738fafb49fd34290706d1a1a2f4d1c6df275526b62cbb4aa5393cc", size = 28883 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/02/cc/b7e31358aac6ed1ef2bb790a9746ac2c69bcb3c8588b41616914eb106eaf/exceptiongroup-1.2.2-py3-none-any.whl", hash = "sha256:3111b9d131c238bec2f8f516e123e14ba243563fb135d3fe885990585aa7795b", size = 16453 }, +] + +[[package]] +name = "execnet" +version = "2.1.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/bb/ff/b4c0dc78fbe20c3e59c0c7334de0c27eb4001a2b2017999af398bf730817/execnet-2.1.1.tar.gz", hash = "sha256:5189b52c6121c24feae288166ab41b32549c7e2348652736540b9e6e7d4e72e3", size = 166524 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/43/09/2aea36ff60d16dd8879bdb2f5b3ee0ba8d08cbbdcdfe870e695ce3784385/execnet-2.1.1-py3-none-any.whl", hash = "sha256:26dee51f1b80cebd6d0ca8e74dd8745419761d3bef34163928cbebbdc4749fdc", size = 40612 }, +] + +[[package]] +name = "filelock" +version = "3.16.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/9d/db/3ef5bb276dae18d6ec2124224403d1d67bccdbefc17af4cc8f553e341ab1/filelock-3.16.1.tar.gz", hash = "sha256:c249fbfcd5db47e5e2d6d62198e565475ee65e4831e2561c8e313fa7eb961435", size = 18037 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b9/f8/feced7779d755758a52d1f6635d990b8d98dc0a29fa568bbe0625f18fdf3/filelock-3.16.1-py3-none-any.whl", hash = "sha256:2082e5703d51fbf98ea75855d9d5527e33d8ff23099bec374a134febee6946b0", size = 16163 }, +] + +[[package]] +name = "gprof2dot" +version = "2024.6.6" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/32/11/16fc5b985741378812223f2c6213b0a95cda333b797def622ac702d28e81/gprof2dot-2024.6.6.tar.gz", hash = "sha256:fa1420c60025a9eb7734f65225b4da02a10fc6dd741b37fa129bc6b41951e5ab", size = 36536 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ae/27/15c4d20871a86281e2bacde9e9f634225d1c2ed0db072f98acf201022411/gprof2dot-2024.6.6-py2.py3-none-any.whl", hash = "sha256:45b14ad7ce64e299c8f526881007b9eb2c6b75505d5613e96e66ee4d5ab33696", size = 34763 }, +] + +[[package]] +name = "importlib-metadata" +version = "8.5.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "zipp" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/cd/12/33e59336dca5be0c398a7482335911a33aa0e20776128f038019f1a95f1b/importlib_metadata-8.5.0.tar.gz", hash = "sha256:71522656f0abace1d072b9e5481a48f07c138e00f079c38c8f883823f9c26bd7", size = 55304 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a0/d9/a1e041c5e7caa9a05c925f4bdbdfb7f006d1f74996af53467bc394c97be7/importlib_metadata-8.5.0-py3-none-any.whl", hash = "sha256:45e54197d28b7a7f1559e60b95e7c567032b602131fbd588f1497f47880aa68b", size = 26514 }, +] + +[[package]] +name = "importlib-resources" +version = "6.4.5" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/98/be/f3e8c6081b684f176b761e6a2fef02a0be939740ed6f54109a2951d806f3/importlib_resources-6.4.5.tar.gz", hash = "sha256:980862a1d16c9e147a59603677fa2aa5fd82b87f223b6cb870695bcfce830065", size = 43372 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/e1/6a/4604f9ae2fa62ef47b9de2fa5ad599589d28c9fd1d335f32759813dfa91e/importlib_resources-6.4.5-py3-none-any.whl", hash = "sha256:ac29d5f956f01d5e4bb63102a5a19957f1b9175e45649977264a1416783bb717", size = 36115 }, +] + +[[package]] +name = "iniconfig" +version = "2.0.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d7/4b/cbd8e699e64a6f16ca3a8220661b5f83792b3017d0f79807cb8708d33913/iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3", size = 4646 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374", size = 5892 }, +] + +[[package]] +name = "packaging" +version = "24.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/51/65/50db4dda066951078f0a96cf12f4b9ada6e4b811516bf0262c0f4f7064d4/packaging-24.1.tar.gz", hash = "sha256:026ed72c8ed3fcce5bf8950572258698927fd1dbda10a5e981cdf0ac37f4f002", size = 148788 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/08/aa/cc0199a5f0ad350994d660967a8efb233fe0416e4639146c089643407ce6/packaging-24.1-py3-none-any.whl", hash = "sha256:5b8f2217dbdbd2f7f384c41c628544e6d52f2d0f53c6d0c3ea61aa5d1d7ff124", size = 53985 }, +] + +[[package]] +name = "platformdirs" +version = "4.3.6" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/13/fc/128cc9cb8f03208bdbf93d3aa862e16d376844a14f9a0ce5cf4507372de4/platformdirs-4.3.6.tar.gz", hash = "sha256:357fb2acbc885b0419afd3ce3ed34564c13c9b95c89360cd9563f73aa5e2b907", size = 21302 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/3c/a6/bc1012356d8ece4d66dd75c4b9fc6c1f6650ddd5991e421177d9f8f671be/platformdirs-4.3.6-py3-none-any.whl", hash = "sha256:73e575e1408ab8103900836b97580d5307456908a03e92031bab39e4554cc3fb", size = 18439 }, +] + +[[package]] +name = "pluggy" +version = "1.5.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/96/2d/02d4312c973c6050a18b314a5ad0b3210edb65a906f868e31c111dede4a6/pluggy-1.5.0.tar.gz", hash = "sha256:2cffa88e94fdc978c4c574f15f9e59b7f4201d439195c3715ca9e2486f1d0cf1", size = 67955 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/88/5f/e351af9a41f866ac3f1fac4ca0613908d9a41741cfcf2228f4ad853b697d/pluggy-1.5.0-py3-none-any.whl", hash = "sha256:44e1ad92c8ca002de6377e165f3e0f1be63266ab4d554740532335b9d75ea669", size = 20556 }, +] + +[[package]] +name = "pytest" +version = "8.3.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, + { name = "exceptiongroup", marker = "python_full_version < '3.11'" }, + { name = "iniconfig" }, + { name = "packaging" }, + { name = "pluggy" }, + { name = "tomli", marker = "python_full_version < '3.11'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/8b/6c/62bbd536103af674e227c41a8f3dcd022d591f6eed5facb5a0f31ee33bbc/pytest-8.3.3.tar.gz", hash = "sha256:70b98107bd648308a7952b06e6ca9a50bc660be218d53c257cc1fc94fda10181", size = 1442487 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6b/77/7440a06a8ead44c7757a64362dd22df5760f9b12dc5f11b6188cd2fc27a0/pytest-8.3.3-py3-none-any.whl", hash = "sha256:a6853c7375b2663155079443d2e45de913a911a11d669df02a50814944db57b2", size = 342341 }, +] + +[[package]] +name = "pytest-fixture-config" +version = "1.8.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pytest" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/8f/67/35e28bec68cc281fbe3d6b221c243a773374c6b677da6bb82552bb07d555/pytest-fixture-config-1.8.0.tar.gz", hash = "sha256:c739895fe20851bdba53f246d0599aa389bc1a1cba48db2ecac0130576dc1b0e", size = 9975 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f7/b2/906ebbe25072c791a6cbe13e0c7214e838ce84ad8b87c39f1573164c884f/pytest_fixture_config-1.8.0-py3-none-any.whl", hash = "sha256:2324a4381a57afd2ca03188eed3fcb0faf38311893f9fb0d11a92003c332050b", size = 7149 }, +] + +[[package]] +name = "pytest-plugins" +version = "0.1.0" +source = { virtual = "." } + +[[package]] +name = "pytest-profiling" +version = "1.8.0" +source = { editable = "pytest-profiling" } +dependencies = [ + { name = "gprof2dot" }, + { name = "pytest" }, + { name = "six" }, +] + +[package.optional-dependencies] +test = [ + { name = "pytest-virtualenv" }, +] + +[package.dev-dependencies] +dev = [ + { name = "importlib-metadata" }, + { name = "importlib-resources" }, + { name = "pytest-virtualenv" }, +] + +[package.metadata] +requires-dist = [ + { name = "gprof2dot" }, + { name = "pytest" }, + { name = "pytest-virtualenv", marker = "extra == 'test'", editable = "pytest-virtualenv" }, + { name = "six" }, +] + +[package.metadata.requires-dev] +dev = [ + { name = "importlib-metadata", specifier = ">=8.5.0" }, + { name = "importlib-resources", specifier = ">=6.4.5" }, + { name = "pytest-virtualenv", editable = "pytest-virtualenv" }, +] + +[[package]] +name = "pytest-shutil" +version = "1.8.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "execnet" }, + { name = "pytest" }, + { name = "six" }, + { name = "termcolor" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/1e/d7/537aca4cd4f06671d78a19bf12d7fde5833afeade8d9a1fbf53773288c80/pytest-shutil-1.8.0.tar.gz", hash = "sha256:aad006ef7b6efcbace1e6bdf90ea7870c4367ab917b85fbdbac1fca1df1f48a0", size = 37608 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/3d/64/b06f4c2dc4b8ae94721f529f3d9e0c7f27e534909b973a84b62aed9726aa/pytest_shutil-1.8.0-py3-none-any.whl", hash = "sha256:474371b7193818a6e59a2279505958533ef16609f27de05c6dc8ff720a4352e6", size = 15564 }, +] + +[[package]] +name = "pytest-virtualenv" +version = "1.8.0" +source = { editable = "pytest-virtualenv" } +dependencies = [ + { name = "importlib-metadata" }, + { name = "pytest" }, + { name = "pytest-fixture-config" }, + { name = "pytest-shutil" }, + { name = "virtualenv" }, +] + +[package.metadata] +requires-dist = [ + { name = "importlib-metadata" }, + { name = "pytest" }, + { name = "pytest-fixture-config" }, + { name = "pytest-shutil" }, + { name = "virtualenv" }, +] + +[[package]] +name = "six" +version = "1.16.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/71/39/171f1c67cd00715f190ba0b100d606d440a28c93c7714febeca8b79af85e/six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926", size = 34041 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d9/5a/e7c31adbe875f2abbb91bd84cf2dc52d792b5a01506781dbcf25c91daf11/six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254", size = 11053 }, +] + +[[package]] +name = "termcolor" +version = "2.5.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/37/72/88311445fd44c455c7d553e61f95412cf89054308a1aa2434ab835075fc5/termcolor-2.5.0.tar.gz", hash = "sha256:998d8d27da6d48442e8e1f016119076b690d962507531df4890fcd2db2ef8a6f", size = 13057 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/7f/be/df630c387a0a054815d60be6a97eb4e8f17385d5d6fe660e1c02750062b4/termcolor-2.5.0-py3-none-any.whl", hash = "sha256:37b17b5fc1e604945c2642c872a3764b5d547a48009871aea3edd3afa180afb8", size = 7755 }, +] + +[[package]] +name = "tomli" +version = "2.0.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/35/b9/de2a5c0144d7d75a57ff355c0c24054f965b2dc3036456ae03a51ea6264b/tomli-2.0.2.tar.gz", hash = "sha256:d46d457a85337051c36524bc5349dd91b1877838e2979ac5ced3e710ed8a60ed", size = 16096 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cf/db/ce8eda256fa131af12e0a76d481711abe4681b6923c27efb9a255c9e4594/tomli-2.0.2-py3-none-any.whl", hash = "sha256:2ebe24485c53d303f690b0ec092806a085f07af5a5aa1464f3931eec36caaa38", size = 13237 }, +] + +[[package]] +name = "virtualenv" +version = "20.26.6" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "distlib" }, + { name = "filelock" }, + { name = "platformdirs" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/3f/40/abc5a766da6b0b2457f819feab8e9203cbeae29327bd241359f866a3da9d/virtualenv-20.26.6.tar.gz", hash = "sha256:280aede09a2a5c317e409a00102e7077c6432c5a38f0ef938e643805a7ad2c48", size = 9372482 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/59/90/57b8ac0c8a231545adc7698c64c5a36fa7cd8e376c691b9bde877269f2eb/virtualenv-20.26.6-py3-none-any.whl", hash = "sha256:7345cc5b25405607a624d8418154577459c3e0277f5466dd79c49d5e492995f2", size = 5999862 }, +] + +[[package]] +name = "zipp" +version = "3.20.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/54/bf/5c0000c44ebc80123ecbdddba1f5dcd94a5ada602a9c225d84b5aaa55e86/zipp-3.20.2.tar.gz", hash = "sha256:bc9eb26f4506fda01b81bcde0ca78103b6e62f991b381fec825435c836edbc29", size = 24199 } +wheels = [ + { url = "https://files.pythonhosted.org/packages/62/8b/5ba542fa83c90e09eac972fc9baca7a88e7e7ca4b221a89251954019308b/zipp-3.20.2-py3-none-any.whl", hash = "sha256:a817ac80d6cf4b23bf7f2828b7cabf326f15a001bea8b1f9b49631780ba28350", size = 9200 }, +] From 1c2ea56776cb291120a712f2275bf60f19a2c311 Mon Sep 17 00:00:00 2001 From: Chris Rose Date: Fri, 18 Oct 2024 09:50:56 -0500 Subject: [PATCH 8/9] Drop pkg_resources dependency Update pytest-profiling and pytest-virtualenv to drop pkg_resources, which is not included in python 3.12+ This entailed identifying importlib equivalents, and finding their backports where appropriate. Additionally, one case where we were using importlib to find local files in the sdist isn't necessary when the code is checked out. --- .../integration/test_profile_integration.py | 22 +++++++++++++++---- pytest-virtualenv/pytest_virtualenv.py | 4 ++-- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/pytest-profiling/tests/integration/test_profile_integration.py b/pytest-profiling/tests/integration/test_profile_integration.py index f66d2e9..4062965 100644 --- a/pytest-profiling/tests/integration/test_profile_integration.py +++ b/pytest-profiling/tests/integration/test_profile_integration.py @@ -1,21 +1,35 @@ -from distutils.dir_util import copy_tree import shutil +from distutils.dir_util import copy_tree +from pathlib import Path -from pkg_resources import resource_filename, get_distribution import pytest +try: + from importlib.metadata import distribution +except ImportError: + from importlib_metadata import distribution + +try: + from importlib.resources import as_file, files +except ImportError: + from importlib_resources import as_file, files + + def resource_filename(package, resource): + return files(package) / resource + + from pytest_virtualenv import VirtualEnv @pytest.yield_fixture(scope="session") def virtualenv(): with VirtualEnv() as venv: - test_dir = resource_filename("pytest_profiling", "tests/integration/profile") + test_dir = Path(__file__).parent / "profile" venv.install_package("more-itertools") # Keep pytest version the same as what's running this test to ensure P27 keeps working - venv.install_package("pytest=={}".format(get_distribution("pytest").version)) + venv.install_package("pytest=={}".format(distribution("pytest").version)) venv.install_package("pytest-cov") venv.install_package("pytest-profiling") diff --git a/pytest-virtualenv/pytest_virtualenv.py b/pytest-virtualenv/pytest_virtualenv.py index dabc15b..0ca4c8b 100644 --- a/pytest-virtualenv/pytest_virtualenv.py +++ b/pytest-virtualenv/pytest_virtualenv.py @@ -8,7 +8,7 @@ from enum import Enum import importlib_metadata as metadata -import pkg_resources +import packaging.requirements from pytest import yield_fixture from pytest_shutil.workspace import Workspace @@ -273,7 +273,7 @@ def _install_editable_package(self, egg_link, package): pth.write("\n") for spec in package.requires: if not _is_extra_requirement(spec): - dependency = next(pkg_resources.parse_requirements(spec), None) + dependency = packaging.requirements.Requirement(spec) if dependency and (not dependency.marker or dependency.marker.evaluate()): self.install_package(dependency.name, version=PackageVersion.CURRENT) From ea0340633b0a88c3e2b9322332e40d7f47d155d6 Mon Sep 17 00:00:00 2001 From: Chris Rose Date: Fri, 18 Oct 2024 10:10:31 -0500 Subject: [PATCH 9/9] Corrected the extra name for tests --- pytest-profiling/pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytest-profiling/pyproject.toml b/pytest-profiling/pyproject.toml index a989d63..866690c 100644 --- a/pytest-profiling/pyproject.toml +++ b/pytest-profiling/pyproject.toml @@ -40,7 +40,7 @@ packages = ["src/pytest_profiling"] homepage = "https://github.com/man-group/pytest-plugins" [project.optional-dependencies] -test = ["pytest-virtualenv"] +tests = ["pytest-virtualenv"] [project.entry-points.pytest11] profiling = "pytest_profiling"