diff options
Diffstat (limited to 'tests/packages')
30 files changed, 248 insertions, 0 deletions
diff --git a/tests/packages/inline/build.py b/tests/packages/inline/build.py new file mode 100644 index 0000000..a8e0dcb --- /dev/null +++ b/tests/packages/inline/build.py @@ -0,0 +1,63 @@ +import os +import sys + +from textwrap import dedent +from zipfile import ZipFile + + +name = 'demo_pkg_inline' +pkg_name = name.replace('_', '-') + +version = '1.0.0' +dist_info = f'{name}-{version}.dist-info' + +metadata = f'{dist_info}/METADATA' +wheel = f'{dist_info}/WHEEL' +entry_points = f'{dist_info}/entry_points.txt' +record = f'{dist_info}/RECORD' +init = f'{name}/__init__.py' +content = { + init: f"def do():\n print('greetings from {name}')", + metadata: f""" + Metadata-Version: 2.1 + Name: {pkg_name} + Version: {version} + Summary: Summary of package + Home-page: Does not exists + Author: someone + Author-email: a@o.com + License: MIT + Platform: ANY + + Desc + """, + wheel: f""" + Wheel-Version: 1.0 + Generator: {name}-{version} + Root-Is-Purelib: true + Tag: py3-none-any + """, + f'{dist_info}/top_level.txt': name, + entry_points: '\n[console_scripts]\ndemo-pkg-inline = demo_pkg_inline:do', + record: f""" + {name}/__init__.py,, + {dist_info}/METADATA,, + {dist_info}/WHEEL,, + {dist_info}/top_level.txt,, + {dist_info}/RECORD,, + """, +} + + +def build_wheel(wheel_directory, metadata_directory=None, config_settings=None): + base_name = f'{name}-{version}-py{sys.version_info.major}-none-any.whl' + path = os.path.join(wheel_directory, base_name) + with ZipFile(str(path), 'w') as zip_file_handler: + for arc_name, data in content.items(): + zip_file_handler.writestr(arc_name, dedent(data).strip()) + print(f'created wheel {path}') + return base_name + + +def get_requires_for_build_wheel(config_settings): + return [] diff --git a/tests/packages/inline/pyproject.toml b/tests/packages/inline/pyproject.toml new file mode 100644 index 0000000..dc9ecbb --- /dev/null +++ b/tests/packages/inline/pyproject.toml @@ -0,0 +1,4 @@ +[build-system] +requires = [] +build-backend = "build" +backend-path = ["."] diff --git a/tests/packages/legacy/legacy/__init__.py b/tests/packages/legacy/legacy/__init__.py new file mode 100644 index 0000000..d5a030b --- /dev/null +++ b/tests/packages/legacy/legacy/__init__.py @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: MIT + +""" +legacy - Example legacy package +""" +__version__ = '1.0.0' diff --git a/tests/packages/legacy/setup.py b/tests/packages/legacy/setup.py new file mode 100644 index 0000000..9feee16 --- /dev/null +++ b/tests/packages/legacy/setup.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python + +from setuptools import setup + + +setup( + name='legacy', + version='1.0.0', + author='Filipe Laíns', + author_email='lains@archlinux.org', + classifiers=[ + 'License :: OSI Approved :: MIT License', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + ], + packages=['legacy'], +) diff --git a/tests/packages/test-bad-backend/pyproject.toml b/tests/packages/test-bad-backend/pyproject.toml new file mode 100644 index 0000000..c199a33 --- /dev/null +++ b/tests/packages/test-bad-backend/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = [] +build-backend = "nonsense_package" diff --git a/tests/packages/test-bad-syntax/pyproject.toml b/tests/packages/test-bad-syntax/pyproject.toml new file mode 100644 index 0000000..cb84496 --- /dev/null +++ b/tests/packages/test-bad-syntax/pyproject.toml @@ -0,0 +1,2 @@ +[build-system] +requires = ['bad' 'syntax'] diff --git a/tests/packages/test-bad-wheel/backend_bad_wheel.py b/tests/packages/test-bad-wheel/backend_bad_wheel.py new file mode 100644 index 0000000..039cae0 --- /dev/null +++ b/tests/packages/test-bad-wheel/backend_bad_wheel.py @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: MIT + +from setuptools.build_meta import build_sdist # noqa: F401 + + +def build_wheel(wheel_directory, config_settings=None, metadata_directory=None): + return 'not a wheel' diff --git a/tests/packages/test-bad-wheel/pyproject.toml b/tests/packages/test-bad-wheel/pyproject.toml new file mode 100644 index 0000000..77de5df --- /dev/null +++ b/tests/packages/test-bad-wheel/pyproject.toml @@ -0,0 +1,4 @@ +[build-system] +build-backend = 'backend_bad_wheel' +backend-path = ['.'] +requires = ['setuptools >= 42.0.0'] diff --git a/tests/packages/test-bad-wheel/setup.cfg b/tests/packages/test-bad-wheel/setup.cfg new file mode 100644 index 0000000..1a4be2f --- /dev/null +++ b/tests/packages/test-bad-wheel/setup.cfg @@ -0,0 +1,3 @@ +[metadata] +name = test_bad_wheel +version = 0.0.1 diff --git a/tests/packages/test-cant-build-via-sdist/backend_bad_sdist.py b/tests/packages/test-cant-build-via-sdist/backend_bad_sdist.py new file mode 100644 index 0000000..2afdb3d --- /dev/null +++ b/tests/packages/test-cant-build-via-sdist/backend_bad_sdist.py @@ -0,0 +1,23 @@ +# SPDX-License-Identifier: MIT + +import os.path +import tarfile +import zipfile + + +def build_sdist(sdist_directory, config_settings=None): + name = 'test_cant_build_via_sdist-1.0.0' + file = f'{name}.tar.gz' + with tarfile.open(os.path.join(sdist_directory, file), 'w') as t: + t.add('pyproject.toml', f'{name}/pyproject.toml') + t.add('backend_bad_sdist.py', f'{name}/backend_bad_sdist.py') + return file + + +def build_wheel(wheel_directory, config_settings=None, metadata_directory=None): + if not os.path.isfile('some-file-that-is-needed-for-build.txt'): + raise FileNotFoundError('some-file-that-is-needed-for-build.txt is missing!') + # pragma: no cover + file = 'test_cant_build_via_sdist-1.0.0-py2.py3-none-any.whl' + zipfile.ZipFile(os.path.join(wheel_directory, file), 'w').close() + return file diff --git a/tests/packages/test-cant-build-via-sdist/pyproject.toml b/tests/packages/test-cant-build-via-sdist/pyproject.toml new file mode 100644 index 0000000..e74afad --- /dev/null +++ b/tests/packages/test-cant-build-via-sdist/pyproject.toml @@ -0,0 +1,4 @@ +[build-system] +build-backend = 'backend_bad_sdist' +backend-path = ['.'] +requires = [] diff --git a/tests/packages/test-cant-build-via-sdist/some-file-that-is-needed-for-build.txt b/tests/packages/test-cant-build-via-sdist/some-file-that-is-needed-for-build.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/packages/test-cant-build-via-sdist/some-file-that-is-needed-for-build.txt diff --git a/tests/packages/test-flit/pyproject.toml b/tests/packages/test-flit/pyproject.toml new file mode 100644 index 0000000..9758b57 --- /dev/null +++ b/tests/packages/test-flit/pyproject.toml @@ -0,0 +1,13 @@ +[build-system] +requires = ['flit_core >=2,<3'] +build-backend = 'flit_core.buildapi' + +[tool.flit.metadata] +module = 'test_flit' +author = 'Filipe Laíns' +author-email = 'lains@archlinux.org' +classifiers = [ + 'License :: OSI Approved :: MIT License', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', +] diff --git a/tests/packages/test-flit/test_flit/__init__.py b/tests/packages/test-flit/test_flit/__init__.py new file mode 100644 index 0000000..264c2e3 --- /dev/null +++ b/tests/packages/test-flit/test_flit/__init__.py @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: MIT + +""" +test_flit - Example flit package +""" +__version__ = '1.0.0' diff --git a/tests/packages/test-invalid-requirements/pyproject.toml b/tests/packages/test-invalid-requirements/pyproject.toml new file mode 100644 index 0000000..11974a0 --- /dev/null +++ b/tests/packages/test-invalid-requirements/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ['setuptools >= 42.0.0', 'wheel >= 0.36.0', 'this is invalid'] +build-backend = 'setuptools.build_meta' diff --git a/tests/packages/test-invalid-requirements/setup.cfg b/tests/packages/test-invalid-requirements/setup.cfg new file mode 100644 index 0000000..aa22d23 --- /dev/null +++ b/tests/packages/test-invalid-requirements/setup.cfg @@ -0,0 +1,3 @@ +[metadata] +name = test_invalid_requirements +version = 1.0.0 diff --git a/tests/packages/test-metadata/backend.py b/tests/packages/test-metadata/backend.py new file mode 100644 index 0000000..727dab9 --- /dev/null +++ b/tests/packages/test-metadata/backend.py @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: MIT + +import pathlib +import textwrap + + +def get_requires_for_build_wheel(config_settings=None): + return ['tomli'] + + +def prepare_metadata_for_build_wheel(metadata_directory, config_settings=None): + import tomli + + with open('pyproject.toml', 'rb') as f: + metadata = tomli.load(f) + + distinfo = pathlib.Path( + metadata_directory, + '{}-{}.dist-info'.format( + metadata['project']['name'].replace('-', '-'), + metadata['project']['version'], + ), + ) + distinfo.mkdir(parents=True, exist_ok=True) + distinfo.joinpath('METADATA').write_text( + textwrap.dedent( + f''' + Metadata-Version: 2.2 + Name: {metadata['project']['name']} + Version: {metadata['project']['version']} + Summary: {metadata['project']['description']} + ''' + ).strip() + ) + return distinfo.name + + +def build_wheel(wheel_directory, config_settings=None, metadata_directory=None): + raise NotImplementedError + + +def build_sdist(sdist_directory, config_settings=None): + raise NotImplementedError diff --git a/tests/packages/test-metadata/pyproject.toml b/tests/packages/test-metadata/pyproject.toml new file mode 100644 index 0000000..3900263 --- /dev/null +++ b/tests/packages/test-metadata/pyproject.toml @@ -0,0 +1,14 @@ +[build-system] +requires = [] +build-backend = 'backend' +backend-path = ['.'] + +[project] +name = 'test-metadata' +version = '1.0.0' +description = 'hello!' + +[tool.black] +line-length = 127 +skip-string-normalization = true +target-version = ['py39', 'py38', 'py37', 'py36'] diff --git a/tests/packages/test-no-backend/pyproject.toml b/tests/packages/test-no-backend/pyproject.toml new file mode 100644 index 0000000..024e9e6 --- /dev/null +++ b/tests/packages/test-no-backend/pyproject.toml @@ -0,0 +1,2 @@ +[build-system] +requires = [] diff --git a/tests/packages/test-no-permission/pyproject.toml b/tests/packages/test-no-permission/pyproject.toml new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/packages/test-no-permission/pyproject.toml diff --git a/tests/packages/test-no-prepare/backend_no_prepare.py b/tests/packages/test-no-prepare/backend_no_prepare.py new file mode 100644 index 0000000..206de1a --- /dev/null +++ b/tests/packages/test-no-prepare/backend_no_prepare.py @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: MIT + +from setuptools.build_meta import build_sdist, build_wheel # noqa: F401 diff --git a/tests/packages/test-no-prepare/pyproject.toml b/tests/packages/test-no-prepare/pyproject.toml new file mode 100644 index 0000000..c6ca5f8 --- /dev/null +++ b/tests/packages/test-no-prepare/pyproject.toml @@ -0,0 +1,4 @@ +[build-system] +build-backend = 'backend_no_prepare' +backend-path = ['.'] +requires = ['setuptools >= 42.0.0', 'wheel >= 0.36.0'] diff --git a/tests/packages/test-no-prepare/setup.cfg b/tests/packages/test-no-prepare/setup.cfg new file mode 100644 index 0000000..c9e0a96 --- /dev/null +++ b/tests/packages/test-no-prepare/setup.cfg @@ -0,0 +1,3 @@ +[metadata] +name = test_no_prepare +version = 1.0.0 diff --git a/tests/packages/test-no-project/empty.txt b/tests/packages/test-no-project/empty.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/packages/test-no-project/empty.txt diff --git a/tests/packages/test-no-requires/pyproject.toml b/tests/packages/test-no-requires/pyproject.toml new file mode 100644 index 0000000..4f25948 --- /dev/null +++ b/tests/packages/test-no-requires/pyproject.toml @@ -0,0 +1,2 @@ +[build-system] +build-backend = 'something' diff --git a/tests/packages/test-optional-hooks/hookless_backend.py b/tests/packages/test-optional-hooks/hookless_backend.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/packages/test-optional-hooks/hookless_backend.py diff --git a/tests/packages/test-optional-hooks/pyproject.toml b/tests/packages/test-optional-hooks/pyproject.toml new file mode 100644 index 0000000..2796891 --- /dev/null +++ b/tests/packages/test-optional-hooks/pyproject.toml @@ -0,0 +1,4 @@ +[build-system] +requires = [] +build-backend = 'hookless_backend' +backend-path = ['.'] diff --git a/tests/packages/test-setuptools/pyproject.toml b/tests/packages/test-setuptools/pyproject.toml new file mode 100644 index 0000000..b00a27a --- /dev/null +++ b/tests/packages/test-setuptools/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ['setuptools >= 42.0.0', 'wheel >= 0.36.0'] +build-backend = 'setuptools.build_meta' diff --git a/tests/packages/test-setuptools/setup.cfg b/tests/packages/test-setuptools/setup.cfg new file mode 100644 index 0000000..bf198b6 --- /dev/null +++ b/tests/packages/test-setuptools/setup.cfg @@ -0,0 +1,6 @@ +[metadata] +name = test_setuptools +version = 1.0.0 + +[bdist_wheel] +universal = 1 diff --git a/tests/packages/test-typo/pyproject.toml b/tests/packages/test-typo/pyproject.toml new file mode 100644 index 0000000..02d1af2 --- /dev/null +++ b/tests/packages/test-typo/pyproject.toml @@ -0,0 +1,3 @@ +[build_sytem] +requires = ['setuptools >= 40.8.0', 'wheel'] +build-backend = 'setuptools.build_meta' |