Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/contexts.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/environment.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/fixtures.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/namespaces.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_bdist_deprecations.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_build_meta.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_dist.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_distutils_adoption.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_easy_install.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_editable_install.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_egg_info.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_find_py_modules.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_glob.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_logging.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_packageindex.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_sdist.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_setuptools.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_shutil_wrapper.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_unicode_utils.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/text.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/textwrap.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/setuptools/tests/config/__pycache__/test_apply_pyprojecttoml.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/setuptools/tests/config/__pycache__/test_setupcfg.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/setuptools/tests/config/downloads/__init__.py +59 -0
- llava/lib/python3.10/site-packages/setuptools/tests/config/downloads/__pycache__/__init__.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/setuptools/tests/config/downloads/__pycache__/preload.cpython-310.pyc +0 -0
- llava/lib/python3.10/site-packages/setuptools/tests/config/downloads/preload.py +18 -0
- llava/lib/python3.10/site-packages/setuptools/tests/config/setupcfg_examples.txt +22 -0
- llava/lib/python3.10/site-packages/setuptools/tests/config/test_apply_pyprojecttoml.py +539 -0
- llava/lib/python3.10/site-packages/setuptools/tests/config/test_pyprojecttoml_dynamic_deps.py +109 -0
- llava/lib/python3.10/site-packages/setuptools/tests/config/test_setupcfg.py +965 -0
- minigpt2/lib/python3.10/site-packages/dockerpycreds/__pycache__/__init__.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/dockerpycreds/__pycache__/errors.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/dockerpycreds/__pycache__/store.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/dockerpycreds/__pycache__/utils.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/dockerpycreds/__pycache__/version.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/dockerpycreds/errors.py +25 -0
- minigpt2/lib/python3.10/site-packages/dockerpycreds/version.py +2 -0
- minigpt2/lib/python3.10/site-packages/open_flamingo/src/__pycache__/factory.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/open_flamingo/src/__pycache__/flamingo_lm.cpython-310.pyc +0 -0
- minigpt2/lib/python3.10/site-packages/tzdata/__init__.py +6 -0
- minigpt2/lib/python3.10/site-packages/tzdata/zoneinfo/Cuba +0 -0
- minigpt2/lib/python3.10/site-packages/tzdata/zoneinfo/EST +0 -0
- minigpt2/lib/python3.10/site-packages/tzdata/zoneinfo/EST5EDT +0 -0
- minigpt2/lib/python3.10/site-packages/tzdata/zoneinfo/Egypt +0 -0
- minigpt2/lib/python3.10/site-packages/tzdata/zoneinfo/Factory +0 -0
- minigpt2/lib/python3.10/site-packages/tzdata/zoneinfo/GB +0 -0
- minigpt2/lib/python3.10/site-packages/tzdata/zoneinfo/GMT +0 -0
- minigpt2/lib/python3.10/site-packages/tzdata/zoneinfo/GMT-0 +0 -0
- minigpt2/lib/python3.10/site-packages/tzdata/zoneinfo/HST +0 -0
llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/contexts.cpython-310.pyc
ADDED
|
Binary file (3.93 kB). View file
|
|
|
llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/environment.cpython-310.pyc
ADDED
|
Binary file (2.09 kB). View file
|
|
|
llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/fixtures.cpython-310.pyc
ADDED
|
Binary file (4.11 kB). View file
|
|
|
llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/namespaces.cpython-310.pyc
ADDED
|
Binary file (2.73 kB). View file
|
|
|
llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_bdist_deprecations.cpython-310.pyc
ADDED
|
Binary file (1.03 kB). View file
|
|
|
llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_build_meta.cpython-310.pyc
ADDED
|
Binary file (28.8 kB). View file
|
|
|
llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_dist.cpython-310.pyc
ADDED
|
Binary file (6.93 kB). View file
|
|
|
llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_distutils_adoption.cpython-310.pyc
ADDED
|
Binary file (5.62 kB). View file
|
|
|
llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_easy_install.cpython-310.pyc
ADDED
|
Binary file (44.4 kB). View file
|
|
|
llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_editable_install.cpython-310.pyc
ADDED
|
Binary file (36.9 kB). View file
|
|
|
llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_egg_info.cpython-310.pyc
ADDED
|
Binary file (30.7 kB). View file
|
|
|
llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_find_py_modules.cpython-310.pyc
ADDED
|
Binary file (2.67 kB). View file
|
|
|
llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_glob.cpython-310.pyc
ADDED
|
Binary file (964 Bytes). View file
|
|
|
llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_logging.cpython-310.pyc
ADDED
|
Binary file (2.04 kB). View file
|
|
|
llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_packageindex.cpython-310.pyc
ADDED
|
Binary file (13.9 kB). View file
|
|
|
llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_sdist.cpython-310.pyc
ADDED
|
Binary file (28.2 kB). View file
|
|
|
llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_setuptools.cpython-310.pyc
ADDED
|
Binary file (9.93 kB). View file
|
|
|
llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_shutil_wrapper.cpython-310.pyc
ADDED
|
Binary file (830 Bytes). View file
|
|
|
llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/test_unicode_utils.cpython-310.pyc
ADDED
|
Binary file (686 Bytes). View file
|
|
|
llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/text.cpython-310.pyc
ADDED
|
Binary file (394 Bytes). View file
|
|
|
llava/lib/python3.10/site-packages/setuptools/tests/__pycache__/textwrap.cpython-310.pyc
ADDED
|
Binary file (319 Bytes). View file
|
|
|
llava/lib/python3.10/site-packages/setuptools/tests/config/__pycache__/test_apply_pyprojecttoml.cpython-310.pyc
ADDED
|
Binary file (19.1 kB). View file
|
|
|
llava/lib/python3.10/site-packages/setuptools/tests/config/__pycache__/test_setupcfg.cpython-310.pyc
ADDED
|
Binary file (27.9 kB). View file
|
|
|
llava/lib/python3.10/site-packages/setuptools/tests/config/downloads/__init__.py
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from __future__ import annotations
|
| 2 |
+
|
| 3 |
+
import re
|
| 4 |
+
import time
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
from urllib.error import HTTPError
|
| 7 |
+
from urllib.request import urlopen
|
| 8 |
+
|
| 9 |
+
__all__ = ["DOWNLOAD_DIR", "retrieve_file", "output_file", "urls_from_file"]
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
NAME_REMOVE = ("http://", "https://", "github.com/", "/raw/")
|
| 13 |
+
DOWNLOAD_DIR = Path(__file__).parent
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
# ----------------------------------------------------------------------
|
| 17 |
+
# Please update ./preload.py accordingly when modifying this file
|
| 18 |
+
# ----------------------------------------------------------------------
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def output_file(url: str, download_dir: Path = DOWNLOAD_DIR) -> Path:
|
| 22 |
+
file_name = url.strip()
|
| 23 |
+
for part in NAME_REMOVE:
|
| 24 |
+
file_name = file_name.replace(part, '').strip().strip('/:').strip()
|
| 25 |
+
return Path(download_dir, re.sub(r"[^\-_\.\w\d]+", "_", file_name))
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def retrieve_file(url: str, download_dir: Path = DOWNLOAD_DIR, wait: float = 5) -> Path:
|
| 29 |
+
path = output_file(url, download_dir)
|
| 30 |
+
if path.exists():
|
| 31 |
+
print(f"Skipping {url} (already exists: {path})")
|
| 32 |
+
else:
|
| 33 |
+
download_dir.mkdir(exist_ok=True, parents=True)
|
| 34 |
+
print(f"Downloading {url} to {path}")
|
| 35 |
+
try:
|
| 36 |
+
download(url, path)
|
| 37 |
+
except HTTPError:
|
| 38 |
+
time.sleep(wait) # wait a few seconds and try again.
|
| 39 |
+
download(url, path)
|
| 40 |
+
return path
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def urls_from_file(list_file: Path) -> list[str]:
|
| 44 |
+
"""``list_file`` should be a text file where each line corresponds to a URL to
|
| 45 |
+
download.
|
| 46 |
+
"""
|
| 47 |
+
print(f"file: {list_file}")
|
| 48 |
+
content = list_file.read_text(encoding="utf-8")
|
| 49 |
+
return [url for url in content.splitlines() if not url.startswith("#")]
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def download(url: str, dest: Path):
|
| 53 |
+
with urlopen(url) as f:
|
| 54 |
+
data = f.read()
|
| 55 |
+
|
| 56 |
+
with open(dest, "wb") as f:
|
| 57 |
+
f.write(data)
|
| 58 |
+
|
| 59 |
+
assert Path(dest).exists()
|
llava/lib/python3.10/site-packages/setuptools/tests/config/downloads/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (2.15 kB). View file
|
|
|
llava/lib/python3.10/site-packages/setuptools/tests/config/downloads/__pycache__/preload.cpython-310.pyc
ADDED
|
Binary file (650 Bytes). View file
|
|
|
llava/lib/python3.10/site-packages/setuptools/tests/config/downloads/preload.py
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""This file can be used to preload files needed for testing.
|
| 2 |
+
|
| 3 |
+
For example you can use::
|
| 4 |
+
|
| 5 |
+
cd setuptools/tests/config
|
| 6 |
+
python -m downloads.preload setupcfg_examples.txt
|
| 7 |
+
|
| 8 |
+
to make sure the `setup.cfg` examples are downloaded before starting the tests.
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
import sys
|
| 12 |
+
from pathlib import Path
|
| 13 |
+
|
| 14 |
+
from . import retrieve_file, urls_from_file
|
| 15 |
+
|
| 16 |
+
if __name__ == "__main__":
|
| 17 |
+
urls = urls_from_file(Path(sys.argv[1]))
|
| 18 |
+
list(map(retrieve_file, urls))
|
llava/lib/python3.10/site-packages/setuptools/tests/config/setupcfg_examples.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ====================================================================
|
| 2 |
+
# Some popular packages that use setup.cfg (and others not so popular)
|
| 3 |
+
# Reference: https://hugovk.github.io/top-pypi-packages/
|
| 4 |
+
# ====================================================================
|
| 5 |
+
https://github.com/pypa/setuptools/raw/52c990172fec37766b3566679724aa8bf70ae06d/setup.cfg
|
| 6 |
+
https://github.com/pypa/wheel/raw/0acd203cd896afec7f715aa2ff5980a403459a3b/setup.cfg
|
| 7 |
+
https://github.com/python/importlib_metadata/raw/2f05392ca980952a6960d82b2f2d2ea10aa53239/setup.cfg
|
| 8 |
+
https://github.com/jaraco/skeleton/raw/d9008b5c510cd6969127a6a2ab6f832edddef296/setup.cfg
|
| 9 |
+
https://github.com/jaraco/zipp/raw/700d3a96390e970b6b962823bfea78b4f7e1c537/setup.cfg
|
| 10 |
+
https://github.com/pallets/jinja/raw/7d72eb7fefb7dce065193967f31f805180508448/setup.cfg
|
| 11 |
+
https://github.com/tkem/cachetools/raw/2fd87a94b8d3861d80e9e4236cd480bfdd21c90d/setup.cfg
|
| 12 |
+
https://github.com/aio-libs/aiohttp/raw/5e0e6b7080f2408d5f1dd544c0e1cf88378b7b10/setup.cfg
|
| 13 |
+
https://github.com/pallets/flask/raw/9486b6cf57bd6a8a261f67091aca8ca78eeec1e3/setup.cfg
|
| 14 |
+
https://github.com/pallets/click/raw/6411f425fae545f42795665af4162006b36c5e4a/setup.cfg
|
| 15 |
+
https://github.com/sqlalchemy/sqlalchemy/raw/533f5718904b620be8d63f2474229945d6f8ba5d/setup.cfg
|
| 16 |
+
https://github.com/pytest-dev/pluggy/raw/461ef63291d13589c4e21aa182cd1529257e9a0a/setup.cfg
|
| 17 |
+
https://github.com/pytest-dev/pytest/raw/c7be96dae487edbd2f55b561b31b68afac1dabe6/setup.cfg
|
| 18 |
+
https://github.com/platformdirs/platformdirs/raw/7b7852128dd6f07511b618d6edea35046bd0c6ff/setup.cfg
|
| 19 |
+
https://github.com/pandas-dev/pandas/raw/bc17343f934a33dc231c8c74be95d8365537c376/setup.cfg
|
| 20 |
+
https://github.com/django/django/raw/4e249d11a6e56ca8feb4b055b681cec457ef3a3d/setup.cfg
|
| 21 |
+
https://github.com/pyscaffold/pyscaffold/raw/de7aa5dc059fbd04307419c667cc4961bc9df4b8/setup.cfg
|
| 22 |
+
https://github.com/pypa/virtualenv/raw/f92eda6e3da26a4d28c2663ffb85c4960bdb990c/setup.cfg
|
llava/lib/python3.10/site-packages/setuptools/tests/config/test_apply_pyprojecttoml.py
ADDED
|
@@ -0,0 +1,539 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Make sure that applying the configuration from pyproject.toml is equivalent to
|
| 2 |
+
applying a similar configuration from setup.cfg
|
| 3 |
+
|
| 4 |
+
To run these tests offline, please have a look on ``./downloads/preload.py``
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
import io
|
| 10 |
+
import re
|
| 11 |
+
import tarfile
|
| 12 |
+
from inspect import cleandoc
|
| 13 |
+
from pathlib import Path
|
| 14 |
+
from unittest.mock import Mock
|
| 15 |
+
|
| 16 |
+
import pytest
|
| 17 |
+
from ini2toml.api import LiteTranslator
|
| 18 |
+
from packaging.metadata import Metadata
|
| 19 |
+
|
| 20 |
+
import setuptools # noqa: F401 # ensure monkey patch to metadata
|
| 21 |
+
from setuptools._static import is_static
|
| 22 |
+
from setuptools.command.egg_info import write_requirements
|
| 23 |
+
from setuptools.config import expand, pyprojecttoml, setupcfg
|
| 24 |
+
from setuptools.config._apply_pyprojecttoml import _MissingDynamic, _some_attrgetter
|
| 25 |
+
from setuptools.dist import Distribution
|
| 26 |
+
from setuptools.errors import RemovedConfigError
|
| 27 |
+
|
| 28 |
+
from .downloads import retrieve_file, urls_from_file
|
| 29 |
+
|
| 30 |
+
HERE = Path(__file__).parent
|
| 31 |
+
EXAMPLES_FILE = "setupcfg_examples.txt"
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
def makedist(path, **attrs):
|
| 35 |
+
return Distribution({"src_root": path, **attrs})
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
@pytest.mark.parametrize("url", urls_from_file(HERE / EXAMPLES_FILE))
|
| 39 |
+
@pytest.mark.filterwarnings("ignore")
|
| 40 |
+
@pytest.mark.uses_network
|
| 41 |
+
def test_apply_pyproject_equivalent_to_setupcfg(url, monkeypatch, tmp_path):
|
| 42 |
+
monkeypatch.setattr(expand, "read_attr", Mock(return_value="0.0.1"))
|
| 43 |
+
setupcfg_example = retrieve_file(url)
|
| 44 |
+
pyproject_example = Path(tmp_path, "pyproject.toml")
|
| 45 |
+
setupcfg_text = setupcfg_example.read_text(encoding="utf-8")
|
| 46 |
+
toml_config = LiteTranslator().translate(setupcfg_text, "setup.cfg")
|
| 47 |
+
pyproject_example.write_text(toml_config, encoding="utf-8")
|
| 48 |
+
|
| 49 |
+
dist_toml = pyprojecttoml.apply_configuration(makedist(tmp_path), pyproject_example)
|
| 50 |
+
dist_cfg = setupcfg.apply_configuration(makedist(tmp_path), setupcfg_example)
|
| 51 |
+
|
| 52 |
+
pkg_info_toml = core_metadata(dist_toml)
|
| 53 |
+
pkg_info_cfg = core_metadata(dist_cfg)
|
| 54 |
+
assert pkg_info_toml == pkg_info_cfg
|
| 55 |
+
|
| 56 |
+
if any(getattr(d, "license_files", None) for d in (dist_toml, dist_cfg)):
|
| 57 |
+
assert set(dist_toml.license_files) == set(dist_cfg.license_files)
|
| 58 |
+
|
| 59 |
+
if any(getattr(d, "entry_points", None) for d in (dist_toml, dist_cfg)):
|
| 60 |
+
print(dist_cfg.entry_points)
|
| 61 |
+
ep_toml = {
|
| 62 |
+
(k, *sorted(i.replace(" ", "") for i in v))
|
| 63 |
+
for k, v in dist_toml.entry_points.items()
|
| 64 |
+
}
|
| 65 |
+
ep_cfg = {
|
| 66 |
+
(k, *sorted(i.replace(" ", "") for i in v))
|
| 67 |
+
for k, v in dist_cfg.entry_points.items()
|
| 68 |
+
}
|
| 69 |
+
assert ep_toml == ep_cfg
|
| 70 |
+
|
| 71 |
+
if any(getattr(d, "package_data", None) for d in (dist_toml, dist_cfg)):
|
| 72 |
+
pkg_data_toml = {(k, *sorted(v)) for k, v in dist_toml.package_data.items()}
|
| 73 |
+
pkg_data_cfg = {(k, *sorted(v)) for k, v in dist_cfg.package_data.items()}
|
| 74 |
+
assert pkg_data_toml == pkg_data_cfg
|
| 75 |
+
|
| 76 |
+
if any(getattr(d, "data_files", None) for d in (dist_toml, dist_cfg)):
|
| 77 |
+
data_files_toml = {(k, *sorted(v)) for k, v in dist_toml.data_files}
|
| 78 |
+
data_files_cfg = {(k, *sorted(v)) for k, v in dist_cfg.data_files}
|
| 79 |
+
assert data_files_toml == data_files_cfg
|
| 80 |
+
|
| 81 |
+
assert set(dist_toml.install_requires) == set(dist_cfg.install_requires)
|
| 82 |
+
if any(getattr(d, "extras_require", None) for d in (dist_toml, dist_cfg)):
|
| 83 |
+
extra_req_toml = {(k, *sorted(v)) for k, v in dist_toml.extras_require.items()}
|
| 84 |
+
extra_req_cfg = {(k, *sorted(v)) for k, v in dist_cfg.extras_require.items()}
|
| 85 |
+
assert extra_req_toml == extra_req_cfg
|
| 86 |
+
|
| 87 |
+
|
| 88 |
+
PEP621_EXAMPLE = """\
|
| 89 |
+
[project]
|
| 90 |
+
name = "spam"
|
| 91 |
+
version = "2020.0.0"
|
| 92 |
+
description = "Lovely Spam! Wonderful Spam!"
|
| 93 |
+
readme = "README.rst"
|
| 94 |
+
requires-python = ">=3.8"
|
| 95 |
+
license = {file = "LICENSE.txt"}
|
| 96 |
+
keywords = ["egg", "bacon", "sausage", "tomatoes", "Lobster Thermidor"]
|
| 97 |
+
authors = [
|
| 98 |
+
{email = "hi@pradyunsg.me"},
|
| 99 |
+
{name = "Tzu-Ping Chung"}
|
| 100 |
+
]
|
| 101 |
+
maintainers = [
|
| 102 |
+
{name = "Brett Cannon", email = "brett@python.org"},
|
| 103 |
+
{name = "John X. Ãørçeč", email = "john@utf8.org"},
|
| 104 |
+
{name = "Γαμα קּ 東", email = "gama@utf8.org"},
|
| 105 |
+
]
|
| 106 |
+
classifiers = [
|
| 107 |
+
"Development Status :: 4 - Beta",
|
| 108 |
+
"Programming Language :: Python"
|
| 109 |
+
]
|
| 110 |
+
|
| 111 |
+
dependencies = [
|
| 112 |
+
"httpx",
|
| 113 |
+
"gidgethub[httpx]>4.0.0",
|
| 114 |
+
"django>2.1; os_name != 'nt'",
|
| 115 |
+
"django>2.0; os_name == 'nt'"
|
| 116 |
+
]
|
| 117 |
+
|
| 118 |
+
[project.optional-dependencies]
|
| 119 |
+
test = [
|
| 120 |
+
"pytest < 5.0.0",
|
| 121 |
+
"pytest-cov[all]"
|
| 122 |
+
]
|
| 123 |
+
|
| 124 |
+
[project.urls]
|
| 125 |
+
homepage = "http://example.com"
|
| 126 |
+
documentation = "http://readthedocs.org"
|
| 127 |
+
repository = "http://github.com"
|
| 128 |
+
changelog = "http://github.com/me/spam/blob/master/CHANGELOG.md"
|
| 129 |
+
|
| 130 |
+
[project.scripts]
|
| 131 |
+
spam-cli = "spam:main_cli"
|
| 132 |
+
|
| 133 |
+
[project.gui-scripts]
|
| 134 |
+
spam-gui = "spam:main_gui"
|
| 135 |
+
|
| 136 |
+
[project.entry-points."spam.magical"]
|
| 137 |
+
tomatoes = "spam:main_tomatoes"
|
| 138 |
+
"""
|
| 139 |
+
|
| 140 |
+
PEP621_INTERNATIONAL_EMAIL_EXAMPLE = """\
|
| 141 |
+
[project]
|
| 142 |
+
name = "spam"
|
| 143 |
+
version = "2020.0.0"
|
| 144 |
+
authors = [
|
| 145 |
+
{email = "hi@pradyunsg.me"},
|
| 146 |
+
{name = "Tzu-Ping Chung"}
|
| 147 |
+
]
|
| 148 |
+
maintainers = [
|
| 149 |
+
{name = "Степан Бандера", email = "криївка@оун-упа.укр"},
|
| 150 |
+
]
|
| 151 |
+
"""
|
| 152 |
+
|
| 153 |
+
PEP621_EXAMPLE_SCRIPT = """
|
| 154 |
+
def main_cli(): pass
|
| 155 |
+
def main_gui(): pass
|
| 156 |
+
def main_tomatoes(): pass
|
| 157 |
+
"""
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
def _pep621_example_project(
|
| 161 |
+
tmp_path,
|
| 162 |
+
readme="README.rst",
|
| 163 |
+
pyproject_text=PEP621_EXAMPLE,
|
| 164 |
+
):
|
| 165 |
+
pyproject = tmp_path / "pyproject.toml"
|
| 166 |
+
text = pyproject_text
|
| 167 |
+
replacements = {'readme = "README.rst"': f'readme = "{readme}"'}
|
| 168 |
+
for orig, subst in replacements.items():
|
| 169 |
+
text = text.replace(orig, subst)
|
| 170 |
+
pyproject.write_text(text, encoding="utf-8")
|
| 171 |
+
|
| 172 |
+
(tmp_path / readme).write_text("hello world", encoding="utf-8")
|
| 173 |
+
(tmp_path / "LICENSE.txt").write_text("--- LICENSE stub ---", encoding="utf-8")
|
| 174 |
+
(tmp_path / "spam.py").write_text(PEP621_EXAMPLE_SCRIPT, encoding="utf-8")
|
| 175 |
+
return pyproject
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
def test_pep621_example(tmp_path):
|
| 179 |
+
"""Make sure the example in PEP 621 works"""
|
| 180 |
+
pyproject = _pep621_example_project(tmp_path)
|
| 181 |
+
dist = pyprojecttoml.apply_configuration(makedist(tmp_path), pyproject)
|
| 182 |
+
assert dist.metadata.license == "--- LICENSE stub ---"
|
| 183 |
+
assert set(dist.metadata.license_files) == {"LICENSE.txt"}
|
| 184 |
+
|
| 185 |
+
|
| 186 |
+
@pytest.mark.parametrize(
|
| 187 |
+
("readme", "ctype"),
|
| 188 |
+
[
|
| 189 |
+
("Readme.txt", "text/plain"),
|
| 190 |
+
("readme.md", "text/markdown"),
|
| 191 |
+
("text.rst", "text/x-rst"),
|
| 192 |
+
],
|
| 193 |
+
)
|
| 194 |
+
def test_readme_content_type(tmp_path, readme, ctype):
|
| 195 |
+
pyproject = _pep621_example_project(tmp_path, readme)
|
| 196 |
+
dist = pyprojecttoml.apply_configuration(makedist(tmp_path), pyproject)
|
| 197 |
+
assert dist.metadata.long_description_content_type == ctype
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
def test_undefined_content_type(tmp_path):
|
| 201 |
+
pyproject = _pep621_example_project(tmp_path, "README.tex")
|
| 202 |
+
with pytest.raises(ValueError, match="Undefined content type for README.tex"):
|
| 203 |
+
pyprojecttoml.apply_configuration(makedist(tmp_path), pyproject)
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
def test_no_explicit_content_type_for_missing_extension(tmp_path):
|
| 207 |
+
pyproject = _pep621_example_project(tmp_path, "README")
|
| 208 |
+
dist = pyprojecttoml.apply_configuration(makedist(tmp_path), pyproject)
|
| 209 |
+
assert dist.metadata.long_description_content_type is None
|
| 210 |
+
|
| 211 |
+
|
| 212 |
+
@pytest.mark.parametrize(
|
| 213 |
+
("pyproject_text", "expected_maintainers_meta_value"),
|
| 214 |
+
(
|
| 215 |
+
pytest.param(
|
| 216 |
+
PEP621_EXAMPLE,
|
| 217 |
+
(
|
| 218 |
+
'Brett Cannon <brett@python.org>, "John X. Ãørçeč" <john@utf8.org>, '
|
| 219 |
+
'Γαμα קּ 東 <gama@utf8.org>'
|
| 220 |
+
),
|
| 221 |
+
id='non-international-emails',
|
| 222 |
+
),
|
| 223 |
+
pytest.param(
|
| 224 |
+
PEP621_INTERNATIONAL_EMAIL_EXAMPLE,
|
| 225 |
+
'Степан Бандера <криївка@оун-упа.укр>',
|
| 226 |
+
marks=pytest.mark.xfail(
|
| 227 |
+
reason="CPython's `email.headerregistry.Address` only supports "
|
| 228 |
+
'RFC 5322, as of Nov 10, 2022 and latest Python 3.11.0',
|
| 229 |
+
strict=True,
|
| 230 |
+
),
|
| 231 |
+
id='international-email',
|
| 232 |
+
),
|
| 233 |
+
),
|
| 234 |
+
)
|
| 235 |
+
def test_utf8_maintainer_in_metadata( # issue-3663
|
| 236 |
+
expected_maintainers_meta_value,
|
| 237 |
+
pyproject_text,
|
| 238 |
+
tmp_path,
|
| 239 |
+
):
|
| 240 |
+
pyproject = _pep621_example_project(
|
| 241 |
+
tmp_path,
|
| 242 |
+
"README",
|
| 243 |
+
pyproject_text=pyproject_text,
|
| 244 |
+
)
|
| 245 |
+
dist = pyprojecttoml.apply_configuration(makedist(tmp_path), pyproject)
|
| 246 |
+
assert dist.metadata.maintainer_email == expected_maintainers_meta_value
|
| 247 |
+
pkg_file = tmp_path / "PKG-FILE"
|
| 248 |
+
with open(pkg_file, "w", encoding="utf-8") as fh:
|
| 249 |
+
dist.metadata.write_pkg_file(fh)
|
| 250 |
+
content = pkg_file.read_text(encoding="utf-8")
|
| 251 |
+
assert f"Maintainer-email: {expected_maintainers_meta_value}" in content
|
| 252 |
+
|
| 253 |
+
|
| 254 |
+
class TestLicenseFiles:
|
| 255 |
+
# TODO: After PEP 639 is accepted, we have to move the license-files
|
| 256 |
+
# to the `project` table instead of `tool.setuptools`
|
| 257 |
+
|
| 258 |
+
def base_pyproject(self, tmp_path, additional_text):
|
| 259 |
+
pyproject = _pep621_example_project(tmp_path, "README")
|
| 260 |
+
text = pyproject.read_text(encoding="utf-8")
|
| 261 |
+
|
| 262 |
+
# Sanity-check
|
| 263 |
+
assert 'license = {file = "LICENSE.txt"}' in text
|
| 264 |
+
assert "[tool.setuptools]" not in text
|
| 265 |
+
|
| 266 |
+
text = f"{text}\n{additional_text}\n"
|
| 267 |
+
pyproject.write_text(text, encoding="utf-8")
|
| 268 |
+
return pyproject
|
| 269 |
+
|
| 270 |
+
def test_both_license_and_license_files_defined(self, tmp_path):
|
| 271 |
+
setuptools_config = '[tool.setuptools]\nlicense-files = ["_FILE*"]'
|
| 272 |
+
pyproject = self.base_pyproject(tmp_path, setuptools_config)
|
| 273 |
+
|
| 274 |
+
(tmp_path / "_FILE.txt").touch()
|
| 275 |
+
(tmp_path / "_FILE.rst").touch()
|
| 276 |
+
|
| 277 |
+
# Would normally match the `license_files` patterns, but we want to exclude it
|
| 278 |
+
# by being explicit. On the other hand, contents should be added to `license`
|
| 279 |
+
license = tmp_path / "LICENSE.txt"
|
| 280 |
+
license.write_text("LicenseRef-Proprietary\n", encoding="utf-8")
|
| 281 |
+
|
| 282 |
+
dist = pyprojecttoml.apply_configuration(makedist(tmp_path), pyproject)
|
| 283 |
+
assert set(dist.metadata.license_files) == {"_FILE.rst", "_FILE.txt"}
|
| 284 |
+
assert dist.metadata.license == "LicenseRef-Proprietary\n"
|
| 285 |
+
|
| 286 |
+
def test_default_patterns(self, tmp_path):
|
| 287 |
+
setuptools_config = '[tool.setuptools]\nzip-safe = false'
|
| 288 |
+
# ^ used just to trigger section validation
|
| 289 |
+
pyproject = self.base_pyproject(tmp_path, setuptools_config)
|
| 290 |
+
|
| 291 |
+
license_files = "LICENCE-a.html COPYING-abc.txt AUTHORS-xyz NOTICE,def".split()
|
| 292 |
+
|
| 293 |
+
for fname in license_files:
|
| 294 |
+
(tmp_path / fname).write_text(f"{fname}\n", encoding="utf-8")
|
| 295 |
+
|
| 296 |
+
dist = pyprojecttoml.apply_configuration(makedist(tmp_path), pyproject)
|
| 297 |
+
assert (tmp_path / "LICENSE.txt").exists() # from base example
|
| 298 |
+
assert set(dist.metadata.license_files) == {*license_files, "LICENSE.txt"}
|
| 299 |
+
|
| 300 |
+
|
| 301 |
+
class TestPyModules:
|
| 302 |
+
# https://github.com/pypa/setuptools/issues/4316
|
| 303 |
+
|
| 304 |
+
def dist(self, name):
|
| 305 |
+
toml_config = f"""
|
| 306 |
+
[project]
|
| 307 |
+
name = "test"
|
| 308 |
+
version = "42.0"
|
| 309 |
+
[tool.setuptools]
|
| 310 |
+
py-modules = [{name!r}]
|
| 311 |
+
"""
|
| 312 |
+
pyproject = Path("pyproject.toml")
|
| 313 |
+
pyproject.write_text(cleandoc(toml_config), encoding="utf-8")
|
| 314 |
+
return pyprojecttoml.apply_configuration(Distribution({}), pyproject)
|
| 315 |
+
|
| 316 |
+
@pytest.mark.parametrize("module", ["pip-run", "abc-d.λ-xyz-e"])
|
| 317 |
+
def test_valid_module_name(self, tmp_path, monkeypatch, module):
|
| 318 |
+
monkeypatch.chdir(tmp_path)
|
| 319 |
+
assert module in self.dist(module).py_modules
|
| 320 |
+
|
| 321 |
+
@pytest.mark.parametrize("module", ["pip run", "-pip-run", "pip-run-stubs"])
|
| 322 |
+
def test_invalid_module_name(self, tmp_path, monkeypatch, module):
|
| 323 |
+
monkeypatch.chdir(tmp_path)
|
| 324 |
+
with pytest.raises(ValueError, match="py-modules"):
|
| 325 |
+
self.dist(module).py_modules
|
| 326 |
+
|
| 327 |
+
|
| 328 |
+
class TestExtModules:
|
| 329 |
+
def test_pyproject_sets_attribute(self, tmp_path, monkeypatch):
|
| 330 |
+
monkeypatch.chdir(tmp_path)
|
| 331 |
+
pyproject = Path("pyproject.toml")
|
| 332 |
+
toml_config = """
|
| 333 |
+
[project]
|
| 334 |
+
name = "test"
|
| 335 |
+
version = "42.0"
|
| 336 |
+
[tool.setuptools]
|
| 337 |
+
ext-modules = [
|
| 338 |
+
{name = "my.ext", sources = ["hello.c", "world.c"]}
|
| 339 |
+
]
|
| 340 |
+
"""
|
| 341 |
+
pyproject.write_text(cleandoc(toml_config), encoding="utf-8")
|
| 342 |
+
with pytest.warns(pyprojecttoml._ExperimentalConfiguration):
|
| 343 |
+
dist = pyprojecttoml.apply_configuration(Distribution({}), pyproject)
|
| 344 |
+
assert len(dist.ext_modules) == 1
|
| 345 |
+
assert dist.ext_modules[0].name == "my.ext"
|
| 346 |
+
assert set(dist.ext_modules[0].sources) == {"hello.c", "world.c"}
|
| 347 |
+
|
| 348 |
+
|
| 349 |
+
class TestDeprecatedFields:
|
| 350 |
+
def test_namespace_packages(self, tmp_path):
|
| 351 |
+
pyproject = tmp_path / "pyproject.toml"
|
| 352 |
+
config = """
|
| 353 |
+
[project]
|
| 354 |
+
name = "myproj"
|
| 355 |
+
version = "42"
|
| 356 |
+
[tool.setuptools]
|
| 357 |
+
namespace-packages = ["myproj.pkg"]
|
| 358 |
+
"""
|
| 359 |
+
pyproject.write_text(cleandoc(config), encoding="utf-8")
|
| 360 |
+
with pytest.raises(RemovedConfigError, match="namespace-packages"):
|
| 361 |
+
pyprojecttoml.apply_configuration(makedist(tmp_path), pyproject)
|
| 362 |
+
|
| 363 |
+
|
| 364 |
+
class TestPresetField:
|
| 365 |
+
def pyproject(self, tmp_path, dynamic, extra_content=""):
|
| 366 |
+
content = f"[project]\nname = 'proj'\ndynamic = {dynamic!r}\n"
|
| 367 |
+
if "version" not in dynamic:
|
| 368 |
+
content += "version = '42'\n"
|
| 369 |
+
file = tmp_path / "pyproject.toml"
|
| 370 |
+
file.write_text(content + extra_content, encoding="utf-8")
|
| 371 |
+
return file
|
| 372 |
+
|
| 373 |
+
@pytest.mark.parametrize(
|
| 374 |
+
("attr", "field", "value"),
|
| 375 |
+
[
|
| 376 |
+
("classifiers", "classifiers", ["Private :: Classifier"]),
|
| 377 |
+
("entry_points", "scripts", {"console_scripts": ["foobar=foobar:main"]}),
|
| 378 |
+
("entry_points", "gui-scripts", {"gui_scripts": ["bazquux=bazquux:main"]}),
|
| 379 |
+
pytest.param(
|
| 380 |
+
*("install_requires", "dependencies", ["six"]),
|
| 381 |
+
marks=[
|
| 382 |
+
pytest.mark.filterwarnings("ignore:.*install_requires. overwritten")
|
| 383 |
+
],
|
| 384 |
+
),
|
| 385 |
+
],
|
| 386 |
+
)
|
| 387 |
+
def test_not_listed_in_dynamic(self, tmp_path, attr, field, value):
|
| 388 |
+
"""Setuptools cannot set a field if not listed in ``dynamic``"""
|
| 389 |
+
pyproject = self.pyproject(tmp_path, [])
|
| 390 |
+
dist = makedist(tmp_path, **{attr: value})
|
| 391 |
+
msg = re.compile(f"defined outside of `pyproject.toml`:.*{field}", re.S)
|
| 392 |
+
with pytest.warns(_MissingDynamic, match=msg):
|
| 393 |
+
dist = pyprojecttoml.apply_configuration(dist, pyproject)
|
| 394 |
+
|
| 395 |
+
dist_value = _some_attrgetter(f"metadata.{attr}", attr)(dist)
|
| 396 |
+
assert not dist_value
|
| 397 |
+
|
| 398 |
+
@pytest.mark.parametrize(
|
| 399 |
+
("attr", "field", "value"),
|
| 400 |
+
[
|
| 401 |
+
("install_requires", "dependencies", []),
|
| 402 |
+
("extras_require", "optional-dependencies", {}),
|
| 403 |
+
("install_requires", "dependencies", ["six"]),
|
| 404 |
+
("classifiers", "classifiers", ["Private :: Classifier"]),
|
| 405 |
+
],
|
| 406 |
+
)
|
| 407 |
+
def test_listed_in_dynamic(self, tmp_path, attr, field, value):
|
| 408 |
+
pyproject = self.pyproject(tmp_path, [field])
|
| 409 |
+
dist = makedist(tmp_path, **{attr: value})
|
| 410 |
+
dist = pyprojecttoml.apply_configuration(dist, pyproject)
|
| 411 |
+
dist_value = _some_attrgetter(f"metadata.{attr}", attr)(dist)
|
| 412 |
+
assert dist_value == value
|
| 413 |
+
|
| 414 |
+
def test_warning_overwritten_dependencies(self, tmp_path):
|
| 415 |
+
src = "[project]\nname='pkg'\nversion='0.1'\ndependencies=['click']\n"
|
| 416 |
+
pyproject = tmp_path / "pyproject.toml"
|
| 417 |
+
pyproject.write_text(src, encoding="utf-8")
|
| 418 |
+
dist = makedist(tmp_path, install_requires=["wheel"])
|
| 419 |
+
with pytest.warns(match="`install_requires` overwritten"):
|
| 420 |
+
dist = pyprojecttoml.apply_configuration(dist, pyproject)
|
| 421 |
+
assert "wheel" not in dist.install_requires
|
| 422 |
+
|
| 423 |
+
def test_optional_dependencies_dont_remove_env_markers(self, tmp_path):
|
| 424 |
+
"""
|
| 425 |
+
Internally setuptools converts dependencies with markers to "extras".
|
| 426 |
+
If ``install_requires`` is given by ``setup.py``, we have to ensure that
|
| 427 |
+
applying ``optional-dependencies`` does not overwrite the mandatory
|
| 428 |
+
dependencies with markers (see #3204).
|
| 429 |
+
"""
|
| 430 |
+
# If setuptools replace its internal mechanism that uses `requires.txt`
|
| 431 |
+
# this test has to be rewritten to adapt accordingly
|
| 432 |
+
extra = "\n[project.optional-dependencies]\nfoo = ['bar>1']\n"
|
| 433 |
+
pyproject = self.pyproject(tmp_path, ["dependencies"], extra)
|
| 434 |
+
install_req = ['importlib-resources (>=3.0.0) ; python_version < "3.7"']
|
| 435 |
+
dist = makedist(tmp_path, install_requires=install_req)
|
| 436 |
+
dist = pyprojecttoml.apply_configuration(dist, pyproject)
|
| 437 |
+
assert "foo" in dist.extras_require
|
| 438 |
+
egg_info = dist.get_command_obj("egg_info")
|
| 439 |
+
write_requirements(egg_info, tmp_path, tmp_path / "requires.txt")
|
| 440 |
+
reqs = (tmp_path / "requires.txt").read_text(encoding="utf-8")
|
| 441 |
+
assert "importlib-resources" in reqs
|
| 442 |
+
assert "bar" in reqs
|
| 443 |
+
assert ':python_version < "3.7"' in reqs
|
| 444 |
+
|
| 445 |
+
@pytest.mark.parametrize(
|
| 446 |
+
("field", "group"),
|
| 447 |
+
[("scripts", "console_scripts"), ("gui-scripts", "gui_scripts")],
|
| 448 |
+
)
|
| 449 |
+
@pytest.mark.filterwarnings("error")
|
| 450 |
+
def test_scripts_dont_require_dynamic_entry_points(self, tmp_path, field, group):
|
| 451 |
+
# Issue 3862
|
| 452 |
+
pyproject = self.pyproject(tmp_path, [field])
|
| 453 |
+
dist = makedist(tmp_path, entry_points={group: ["foobar=foobar:main"]})
|
| 454 |
+
dist = pyprojecttoml.apply_configuration(dist, pyproject)
|
| 455 |
+
assert group in dist.entry_points
|
| 456 |
+
|
| 457 |
+
|
| 458 |
+
class TestMeta:
|
| 459 |
+
def test_example_file_in_sdist(self, setuptools_sdist):
|
| 460 |
+
"""Meta test to ensure tests can run from sdist"""
|
| 461 |
+
with tarfile.open(setuptools_sdist) as tar:
|
| 462 |
+
assert any(name.endswith(EXAMPLES_FILE) for name in tar.getnames())
|
| 463 |
+
|
| 464 |
+
|
| 465 |
+
class TestInteropCommandLineParsing:
|
| 466 |
+
def test_version(self, tmp_path, monkeypatch, capsys):
|
| 467 |
+
# See pypa/setuptools#4047
|
| 468 |
+
# This test can be removed once the CLI interface of setup.py is removed
|
| 469 |
+
monkeypatch.chdir(tmp_path)
|
| 470 |
+
toml_config = """
|
| 471 |
+
[project]
|
| 472 |
+
name = "test"
|
| 473 |
+
version = "42.0"
|
| 474 |
+
"""
|
| 475 |
+
pyproject = Path(tmp_path, "pyproject.toml")
|
| 476 |
+
pyproject.write_text(cleandoc(toml_config), encoding="utf-8")
|
| 477 |
+
opts = {"script_args": ["--version"]}
|
| 478 |
+
dist = pyprojecttoml.apply_configuration(Distribution(opts), pyproject)
|
| 479 |
+
dist.parse_command_line() # <-- there should be no exception here.
|
| 480 |
+
captured = capsys.readouterr()
|
| 481 |
+
assert "42.0" in captured.out
|
| 482 |
+
|
| 483 |
+
|
| 484 |
+
class TestStaticConfig:
|
| 485 |
+
def test_mark_static_fields(self, tmp_path, monkeypatch):
|
| 486 |
+
monkeypatch.chdir(tmp_path)
|
| 487 |
+
toml_config = """
|
| 488 |
+
[project]
|
| 489 |
+
name = "test"
|
| 490 |
+
version = "42.0"
|
| 491 |
+
dependencies = ["hello"]
|
| 492 |
+
keywords = ["world"]
|
| 493 |
+
classifiers = ["private :: hello world"]
|
| 494 |
+
[tool.setuptools]
|
| 495 |
+
obsoletes = ["abcd"]
|
| 496 |
+
provides = ["abcd"]
|
| 497 |
+
platforms = ["abcd"]
|
| 498 |
+
"""
|
| 499 |
+
pyproject = Path(tmp_path, "pyproject.toml")
|
| 500 |
+
pyproject.write_text(cleandoc(toml_config), encoding="utf-8")
|
| 501 |
+
dist = pyprojecttoml.apply_configuration(Distribution({}), pyproject)
|
| 502 |
+
assert is_static(dist.install_requires)
|
| 503 |
+
assert is_static(dist.metadata.keywords)
|
| 504 |
+
assert is_static(dist.metadata.classifiers)
|
| 505 |
+
assert is_static(dist.metadata.obsoletes)
|
| 506 |
+
assert is_static(dist.metadata.provides)
|
| 507 |
+
assert is_static(dist.metadata.platforms)
|
| 508 |
+
|
| 509 |
+
|
| 510 |
+
# --- Auxiliary Functions ---
|
| 511 |
+
|
| 512 |
+
|
| 513 |
+
def core_metadata(dist) -> str:
|
| 514 |
+
with io.StringIO() as buffer:
|
| 515 |
+
dist.metadata.write_pkg_file(buffer)
|
| 516 |
+
pkg_file_txt = buffer.getvalue()
|
| 517 |
+
|
| 518 |
+
# Make sure core metadata is valid
|
| 519 |
+
Metadata.from_email(pkg_file_txt, validate=True) # can raise exceptions
|
| 520 |
+
|
| 521 |
+
skip_prefixes: tuple[str, ...] = ()
|
| 522 |
+
skip_lines = set()
|
| 523 |
+
# ---- DIFF NORMALISATION ----
|
| 524 |
+
# PEP 621 is very particular about author/maintainer metadata conversion, so skip
|
| 525 |
+
skip_prefixes += ("Author:", "Author-email:", "Maintainer:", "Maintainer-email:")
|
| 526 |
+
# May be redundant with Home-page
|
| 527 |
+
skip_prefixes += ("Project-URL: Homepage,", "Home-page:")
|
| 528 |
+
# May be missing in original (relying on default) but backfilled in the TOML
|
| 529 |
+
skip_prefixes += ("Description-Content-Type:",)
|
| 530 |
+
# Remove empty lines
|
| 531 |
+
skip_lines.add("")
|
| 532 |
+
|
| 533 |
+
result = []
|
| 534 |
+
for line in pkg_file_txt.splitlines():
|
| 535 |
+
if line.startswith(skip_prefixes) or line in skip_lines:
|
| 536 |
+
continue
|
| 537 |
+
result.append(line + "\n")
|
| 538 |
+
|
| 539 |
+
return "".join(result)
|
llava/lib/python3.10/site-packages/setuptools/tests/config/test_pyprojecttoml_dynamic_deps.py
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from inspect import cleandoc
|
| 2 |
+
|
| 3 |
+
import pytest
|
| 4 |
+
from jaraco import path
|
| 5 |
+
|
| 6 |
+
from setuptools.config.pyprojecttoml import apply_configuration
|
| 7 |
+
from setuptools.dist import Distribution
|
| 8 |
+
from setuptools.warnings import SetuptoolsWarning
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def test_dynamic_dependencies(tmp_path):
|
| 12 |
+
files = {
|
| 13 |
+
"requirements.txt": "six\n # comment\n",
|
| 14 |
+
"pyproject.toml": cleandoc(
|
| 15 |
+
"""
|
| 16 |
+
[project]
|
| 17 |
+
name = "myproj"
|
| 18 |
+
version = "1.0"
|
| 19 |
+
dynamic = ["dependencies"]
|
| 20 |
+
|
| 21 |
+
[build-system]
|
| 22 |
+
requires = ["setuptools", "wheel"]
|
| 23 |
+
build-backend = "setuptools.build_meta"
|
| 24 |
+
|
| 25 |
+
[tool.setuptools.dynamic.dependencies]
|
| 26 |
+
file = ["requirements.txt"]
|
| 27 |
+
"""
|
| 28 |
+
),
|
| 29 |
+
}
|
| 30 |
+
path.build(files, prefix=tmp_path)
|
| 31 |
+
dist = Distribution()
|
| 32 |
+
dist = apply_configuration(dist, tmp_path / "pyproject.toml")
|
| 33 |
+
assert dist.install_requires == ["six"]
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def test_dynamic_optional_dependencies(tmp_path):
|
| 37 |
+
files = {
|
| 38 |
+
"requirements-docs.txt": "sphinx\n # comment\n",
|
| 39 |
+
"pyproject.toml": cleandoc(
|
| 40 |
+
"""
|
| 41 |
+
[project]
|
| 42 |
+
name = "myproj"
|
| 43 |
+
version = "1.0"
|
| 44 |
+
dynamic = ["optional-dependencies"]
|
| 45 |
+
|
| 46 |
+
[tool.setuptools.dynamic.optional-dependencies.docs]
|
| 47 |
+
file = ["requirements-docs.txt"]
|
| 48 |
+
|
| 49 |
+
[build-system]
|
| 50 |
+
requires = ["setuptools", "wheel"]
|
| 51 |
+
build-backend = "setuptools.build_meta"
|
| 52 |
+
"""
|
| 53 |
+
),
|
| 54 |
+
}
|
| 55 |
+
path.build(files, prefix=tmp_path)
|
| 56 |
+
dist = Distribution()
|
| 57 |
+
dist = apply_configuration(dist, tmp_path / "pyproject.toml")
|
| 58 |
+
assert dist.extras_require == {"docs": ["sphinx"]}
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
def test_mixed_dynamic_optional_dependencies(tmp_path):
|
| 62 |
+
"""
|
| 63 |
+
Test that if PEP 621 was loosened to allow mixing of dynamic and static
|
| 64 |
+
configurations in the case of fields containing sub-fields (groups),
|
| 65 |
+
things would work out.
|
| 66 |
+
"""
|
| 67 |
+
files = {
|
| 68 |
+
"requirements-images.txt": "pillow~=42.0\n # comment\n",
|
| 69 |
+
"pyproject.toml": cleandoc(
|
| 70 |
+
"""
|
| 71 |
+
[project]
|
| 72 |
+
name = "myproj"
|
| 73 |
+
version = "1.0"
|
| 74 |
+
dynamic = ["optional-dependencies"]
|
| 75 |
+
|
| 76 |
+
[project.optional-dependencies]
|
| 77 |
+
docs = ["sphinx"]
|
| 78 |
+
|
| 79 |
+
[tool.setuptools.dynamic.optional-dependencies.images]
|
| 80 |
+
file = ["requirements-images.txt"]
|
| 81 |
+
"""
|
| 82 |
+
),
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
path.build(files, prefix=tmp_path)
|
| 86 |
+
pyproject = tmp_path / "pyproject.toml"
|
| 87 |
+
with pytest.raises(ValueError, match="project.optional-dependencies"):
|
| 88 |
+
apply_configuration(Distribution(), pyproject)
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
def test_mixed_extras_require_optional_dependencies(tmp_path):
|
| 92 |
+
files = {
|
| 93 |
+
"pyproject.toml": cleandoc(
|
| 94 |
+
"""
|
| 95 |
+
[project]
|
| 96 |
+
name = "myproj"
|
| 97 |
+
version = "1.0"
|
| 98 |
+
optional-dependencies.docs = ["sphinx"]
|
| 99 |
+
"""
|
| 100 |
+
),
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
path.build(files, prefix=tmp_path)
|
| 104 |
+
pyproject = tmp_path / "pyproject.toml"
|
| 105 |
+
|
| 106 |
+
with pytest.warns(SetuptoolsWarning, match=".extras_require. overwritten"):
|
| 107 |
+
dist = Distribution({"extras_require": {"hello": ["world"]}})
|
| 108 |
+
dist = apply_configuration(dist, pyproject)
|
| 109 |
+
assert dist.extras_require == {"docs": ["sphinx"]}
|
llava/lib/python3.10/site-packages/setuptools/tests/config/test_setupcfg.py
ADDED
|
@@ -0,0 +1,965 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import configparser
|
| 2 |
+
import contextlib
|
| 3 |
+
import inspect
|
| 4 |
+
from pathlib import Path
|
| 5 |
+
from unittest.mock import Mock, patch
|
| 6 |
+
|
| 7 |
+
import pytest
|
| 8 |
+
from packaging.requirements import InvalidRequirement
|
| 9 |
+
|
| 10 |
+
from setuptools.config.setupcfg import ConfigHandler, Target, read_configuration
|
| 11 |
+
from setuptools.dist import Distribution, _Distribution
|
| 12 |
+
from setuptools.warnings import SetuptoolsDeprecationWarning
|
| 13 |
+
|
| 14 |
+
from ..textwrap import DALS
|
| 15 |
+
|
| 16 |
+
from distutils.errors import DistutilsFileError, DistutilsOptionError
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
class ErrConfigHandler(ConfigHandler[Target]):
|
| 20 |
+
"""Erroneous handler. Fails to implement required methods."""
|
| 21 |
+
|
| 22 |
+
section_prefix = "**err**"
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
def make_package_dir(name, base_dir, ns=False):
|
| 26 |
+
dir_package = base_dir
|
| 27 |
+
for dir_name in name.split('/'):
|
| 28 |
+
dir_package = dir_package.mkdir(dir_name)
|
| 29 |
+
init_file = None
|
| 30 |
+
if not ns:
|
| 31 |
+
init_file = dir_package.join('__init__.py')
|
| 32 |
+
init_file.write('')
|
| 33 |
+
return dir_package, init_file
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def fake_env(
|
| 37 |
+
tmpdir, setup_cfg, setup_py=None, encoding='ascii', package_path='fake_package'
|
| 38 |
+
):
|
| 39 |
+
if setup_py is None:
|
| 40 |
+
setup_py = 'from setuptools import setup\nsetup()\n'
|
| 41 |
+
|
| 42 |
+
tmpdir.join('setup.py').write(setup_py)
|
| 43 |
+
config = tmpdir.join('setup.cfg')
|
| 44 |
+
config.write(setup_cfg.encode(encoding), mode='wb')
|
| 45 |
+
|
| 46 |
+
package_dir, init_file = make_package_dir(package_path, tmpdir)
|
| 47 |
+
|
| 48 |
+
init_file.write(
|
| 49 |
+
'VERSION = (1, 2, 3)\n'
|
| 50 |
+
'\n'
|
| 51 |
+
'VERSION_MAJOR = 1'
|
| 52 |
+
'\n'
|
| 53 |
+
'def get_version():\n'
|
| 54 |
+
' return [3, 4, 5, "dev"]\n'
|
| 55 |
+
'\n'
|
| 56 |
+
)
|
| 57 |
+
|
| 58 |
+
return package_dir, config
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
@contextlib.contextmanager
|
| 62 |
+
def get_dist(tmpdir, kwargs_initial=None, parse=True):
|
| 63 |
+
kwargs_initial = kwargs_initial or {}
|
| 64 |
+
|
| 65 |
+
with tmpdir.as_cwd():
|
| 66 |
+
dist = Distribution(kwargs_initial)
|
| 67 |
+
dist.script_name = 'setup.py'
|
| 68 |
+
parse and dist.parse_config_files()
|
| 69 |
+
|
| 70 |
+
yield dist
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
def test_parsers_implemented():
|
| 74 |
+
with pytest.raises(NotImplementedError):
|
| 75 |
+
handler = ErrConfigHandler(None, {}, False, Mock())
|
| 76 |
+
handler.parsers
|
| 77 |
+
|
| 78 |
+
|
| 79 |
+
class TestConfigurationReader:
|
| 80 |
+
def test_basic(self, tmpdir):
|
| 81 |
+
_, config = fake_env(
|
| 82 |
+
tmpdir,
|
| 83 |
+
'[metadata]\n'
|
| 84 |
+
'version = 10.1.1\n'
|
| 85 |
+
'keywords = one, two\n'
|
| 86 |
+
'\n'
|
| 87 |
+
'[options]\n'
|
| 88 |
+
'scripts = bin/a.py, bin/b.py\n',
|
| 89 |
+
)
|
| 90 |
+
config_dict = read_configuration(str(config))
|
| 91 |
+
assert config_dict['metadata']['version'] == '10.1.1'
|
| 92 |
+
assert config_dict['metadata']['keywords'] == ['one', 'two']
|
| 93 |
+
assert config_dict['options']['scripts'] == ['bin/a.py', 'bin/b.py']
|
| 94 |
+
|
| 95 |
+
def test_no_config(self, tmpdir):
|
| 96 |
+
with pytest.raises(DistutilsFileError):
|
| 97 |
+
read_configuration(str(tmpdir.join('setup.cfg')))
|
| 98 |
+
|
| 99 |
+
def test_ignore_errors(self, tmpdir):
|
| 100 |
+
_, config = fake_env(
|
| 101 |
+
tmpdir,
|
| 102 |
+
'[metadata]\nversion = attr: none.VERSION\nkeywords = one, two\n',
|
| 103 |
+
)
|
| 104 |
+
with pytest.raises(ImportError):
|
| 105 |
+
read_configuration(str(config))
|
| 106 |
+
|
| 107 |
+
config_dict = read_configuration(str(config), ignore_option_errors=True)
|
| 108 |
+
|
| 109 |
+
assert config_dict['metadata']['keywords'] == ['one', 'two']
|
| 110 |
+
assert 'version' not in config_dict['metadata']
|
| 111 |
+
|
| 112 |
+
config.remove()
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
class TestMetadata:
|
| 116 |
+
def test_basic(self, tmpdir):
|
| 117 |
+
fake_env(
|
| 118 |
+
tmpdir,
|
| 119 |
+
'[metadata]\n'
|
| 120 |
+
'version = 10.1.1\n'
|
| 121 |
+
'description = Some description\n'
|
| 122 |
+
'long_description_content_type = text/something\n'
|
| 123 |
+
'long_description = file: README\n'
|
| 124 |
+
'name = fake_name\n'
|
| 125 |
+
'keywords = one, two\n'
|
| 126 |
+
'provides = package, package.sub\n'
|
| 127 |
+
'license = otherlic\n'
|
| 128 |
+
'download_url = http://test.test.com/test/\n'
|
| 129 |
+
'maintainer_email = test@test.com\n',
|
| 130 |
+
)
|
| 131 |
+
|
| 132 |
+
tmpdir.join('README').write('readme contents\nline2')
|
| 133 |
+
|
| 134 |
+
meta_initial = {
|
| 135 |
+
# This will be used so `otherlic` won't replace it.
|
| 136 |
+
'license': 'BSD 3-Clause License',
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
with get_dist(tmpdir, meta_initial) as dist:
|
| 140 |
+
metadata = dist.metadata
|
| 141 |
+
|
| 142 |
+
assert metadata.version == '10.1.1'
|
| 143 |
+
assert metadata.description == 'Some description'
|
| 144 |
+
assert metadata.long_description_content_type == 'text/something'
|
| 145 |
+
assert metadata.long_description == 'readme contents\nline2'
|
| 146 |
+
assert metadata.provides == ['package', 'package.sub']
|
| 147 |
+
assert metadata.license == 'BSD 3-Clause License'
|
| 148 |
+
assert metadata.name == 'fake_name'
|
| 149 |
+
assert metadata.keywords == ['one', 'two']
|
| 150 |
+
assert metadata.download_url == 'http://test.test.com/test/'
|
| 151 |
+
assert metadata.maintainer_email == 'test@test.com'
|
| 152 |
+
|
| 153 |
+
def test_license_cfg(self, tmpdir):
|
| 154 |
+
fake_env(
|
| 155 |
+
tmpdir,
|
| 156 |
+
DALS(
|
| 157 |
+
"""
|
| 158 |
+
[metadata]
|
| 159 |
+
name=foo
|
| 160 |
+
version=0.0.1
|
| 161 |
+
license=Apache 2.0
|
| 162 |
+
"""
|
| 163 |
+
),
|
| 164 |
+
)
|
| 165 |
+
|
| 166 |
+
with get_dist(tmpdir) as dist:
|
| 167 |
+
metadata = dist.metadata
|
| 168 |
+
|
| 169 |
+
assert metadata.name == "foo"
|
| 170 |
+
assert metadata.version == "0.0.1"
|
| 171 |
+
assert metadata.license == "Apache 2.0"
|
| 172 |
+
|
| 173 |
+
def test_file_mixed(self, tmpdir):
|
| 174 |
+
fake_env(
|
| 175 |
+
tmpdir,
|
| 176 |
+
'[metadata]\nlong_description = file: README.rst, CHANGES.rst\n\n',
|
| 177 |
+
)
|
| 178 |
+
|
| 179 |
+
tmpdir.join('README.rst').write('readme contents\nline2')
|
| 180 |
+
tmpdir.join('CHANGES.rst').write('changelog contents\nand stuff')
|
| 181 |
+
|
| 182 |
+
with get_dist(tmpdir) as dist:
|
| 183 |
+
assert dist.metadata.long_description == (
|
| 184 |
+
'readme contents\nline2\nchangelog contents\nand stuff'
|
| 185 |
+
)
|
| 186 |
+
|
| 187 |
+
def test_file_sandboxed(self, tmpdir):
|
| 188 |
+
tmpdir.ensure("README")
|
| 189 |
+
project = tmpdir.join('depth1', 'depth2')
|
| 190 |
+
project.ensure(dir=True)
|
| 191 |
+
fake_env(project, '[metadata]\nlong_description = file: ../../README\n')
|
| 192 |
+
|
| 193 |
+
with get_dist(project, parse=False) as dist:
|
| 194 |
+
with pytest.raises(DistutilsOptionError):
|
| 195 |
+
dist.parse_config_files() # file: out of sandbox
|
| 196 |
+
|
| 197 |
+
def test_aliases(self, tmpdir):
|
| 198 |
+
fake_env(
|
| 199 |
+
tmpdir,
|
| 200 |
+
'[metadata]\n'
|
| 201 |
+
'author_email = test@test.com\n'
|
| 202 |
+
'home_page = http://test.test.com/test/\n'
|
| 203 |
+
'summary = Short summary\n'
|
| 204 |
+
'platform = a, b\n'
|
| 205 |
+
'classifier =\n'
|
| 206 |
+
' Framework :: Django\n'
|
| 207 |
+
' Programming Language :: Python :: 3.5\n',
|
| 208 |
+
)
|
| 209 |
+
|
| 210 |
+
with get_dist(tmpdir) as dist:
|
| 211 |
+
metadata = dist.metadata
|
| 212 |
+
assert metadata.author_email == 'test@test.com'
|
| 213 |
+
assert metadata.url == 'http://test.test.com/test/'
|
| 214 |
+
assert metadata.description == 'Short summary'
|
| 215 |
+
assert metadata.platforms == ['a', 'b']
|
| 216 |
+
assert metadata.classifiers == [
|
| 217 |
+
'Framework :: Django',
|
| 218 |
+
'Programming Language :: Python :: 3.5',
|
| 219 |
+
]
|
| 220 |
+
|
| 221 |
+
def test_multiline(self, tmpdir):
|
| 222 |
+
fake_env(
|
| 223 |
+
tmpdir,
|
| 224 |
+
'[metadata]\n'
|
| 225 |
+
'name = fake_name\n'
|
| 226 |
+
'keywords =\n'
|
| 227 |
+
' one\n'
|
| 228 |
+
' two\n'
|
| 229 |
+
'classifiers =\n'
|
| 230 |
+
' Framework :: Django\n'
|
| 231 |
+
' Programming Language :: Python :: 3.5\n',
|
| 232 |
+
)
|
| 233 |
+
with get_dist(tmpdir) as dist:
|
| 234 |
+
metadata = dist.metadata
|
| 235 |
+
assert metadata.keywords == ['one', 'two']
|
| 236 |
+
assert metadata.classifiers == [
|
| 237 |
+
'Framework :: Django',
|
| 238 |
+
'Programming Language :: Python :: 3.5',
|
| 239 |
+
]
|
| 240 |
+
|
| 241 |
+
def test_dict(self, tmpdir):
|
| 242 |
+
fake_env(
|
| 243 |
+
tmpdir,
|
| 244 |
+
'[metadata]\n'
|
| 245 |
+
'project_urls =\n'
|
| 246 |
+
' Link One = https://example.com/one/\n'
|
| 247 |
+
' Link Two = https://example.com/two/\n',
|
| 248 |
+
)
|
| 249 |
+
with get_dist(tmpdir) as dist:
|
| 250 |
+
metadata = dist.metadata
|
| 251 |
+
assert metadata.project_urls == {
|
| 252 |
+
'Link One': 'https://example.com/one/',
|
| 253 |
+
'Link Two': 'https://example.com/two/',
|
| 254 |
+
}
|
| 255 |
+
|
| 256 |
+
def test_version(self, tmpdir):
|
| 257 |
+
package_dir, config = fake_env(
|
| 258 |
+
tmpdir, '[metadata]\nversion = attr: fake_package.VERSION\n'
|
| 259 |
+
)
|
| 260 |
+
|
| 261 |
+
sub_a = package_dir.mkdir('subpkg_a')
|
| 262 |
+
sub_a.join('__init__.py').write('')
|
| 263 |
+
sub_a.join('mod.py').write('VERSION = (2016, 11, 26)')
|
| 264 |
+
|
| 265 |
+
sub_b = package_dir.mkdir('subpkg_b')
|
| 266 |
+
sub_b.join('__init__.py').write('')
|
| 267 |
+
sub_b.join('mod.py').write(
|
| 268 |
+
'import third_party_module\nVERSION = (2016, 11, 26)'
|
| 269 |
+
)
|
| 270 |
+
|
| 271 |
+
with get_dist(tmpdir) as dist:
|
| 272 |
+
assert dist.metadata.version == '1.2.3'
|
| 273 |
+
|
| 274 |
+
config.write('[metadata]\nversion = attr: fake_package.get_version\n')
|
| 275 |
+
with get_dist(tmpdir) as dist:
|
| 276 |
+
assert dist.metadata.version == '3.4.5.dev'
|
| 277 |
+
|
| 278 |
+
config.write('[metadata]\nversion = attr: fake_package.VERSION_MAJOR\n')
|
| 279 |
+
with get_dist(tmpdir) as dist:
|
| 280 |
+
assert dist.metadata.version == '1'
|
| 281 |
+
|
| 282 |
+
config.write('[metadata]\nversion = attr: fake_package.subpkg_a.mod.VERSION\n')
|
| 283 |
+
with get_dist(tmpdir) as dist:
|
| 284 |
+
assert dist.metadata.version == '2016.11.26'
|
| 285 |
+
|
| 286 |
+
config.write('[metadata]\nversion = attr: fake_package.subpkg_b.mod.VERSION\n')
|
| 287 |
+
with get_dist(tmpdir) as dist:
|
| 288 |
+
assert dist.metadata.version == '2016.11.26'
|
| 289 |
+
|
| 290 |
+
def test_version_file(self, tmpdir):
|
| 291 |
+
fake_env(tmpdir, '[metadata]\nversion = file: fake_package/version.txt\n')
|
| 292 |
+
tmpdir.join('fake_package', 'version.txt').write('1.2.3\n')
|
| 293 |
+
|
| 294 |
+
with get_dist(tmpdir) as dist:
|
| 295 |
+
assert dist.metadata.version == '1.2.3'
|
| 296 |
+
|
| 297 |
+
tmpdir.join('fake_package', 'version.txt').write('1.2.3\n4.5.6\n')
|
| 298 |
+
with pytest.raises(DistutilsOptionError):
|
| 299 |
+
with get_dist(tmpdir) as dist:
|
| 300 |
+
dist.metadata.version
|
| 301 |
+
|
| 302 |
+
def test_version_with_package_dir_simple(self, tmpdir):
|
| 303 |
+
fake_env(
|
| 304 |
+
tmpdir,
|
| 305 |
+
'[metadata]\n'
|
| 306 |
+
'version = attr: fake_package_simple.VERSION\n'
|
| 307 |
+
'[options]\n'
|
| 308 |
+
'package_dir =\n'
|
| 309 |
+
' = src\n',
|
| 310 |
+
package_path='src/fake_package_simple',
|
| 311 |
+
)
|
| 312 |
+
|
| 313 |
+
with get_dist(tmpdir) as dist:
|
| 314 |
+
assert dist.metadata.version == '1.2.3'
|
| 315 |
+
|
| 316 |
+
def test_version_with_package_dir_rename(self, tmpdir):
|
| 317 |
+
fake_env(
|
| 318 |
+
tmpdir,
|
| 319 |
+
'[metadata]\n'
|
| 320 |
+
'version = attr: fake_package_rename.VERSION\n'
|
| 321 |
+
'[options]\n'
|
| 322 |
+
'package_dir =\n'
|
| 323 |
+
' fake_package_rename = fake_dir\n',
|
| 324 |
+
package_path='fake_dir',
|
| 325 |
+
)
|
| 326 |
+
|
| 327 |
+
with get_dist(tmpdir) as dist:
|
| 328 |
+
assert dist.metadata.version == '1.2.3'
|
| 329 |
+
|
| 330 |
+
def test_version_with_package_dir_complex(self, tmpdir):
|
| 331 |
+
fake_env(
|
| 332 |
+
tmpdir,
|
| 333 |
+
'[metadata]\n'
|
| 334 |
+
'version = attr: fake_package_complex.VERSION\n'
|
| 335 |
+
'[options]\n'
|
| 336 |
+
'package_dir =\n'
|
| 337 |
+
' fake_package_complex = src/fake_dir\n',
|
| 338 |
+
package_path='src/fake_dir',
|
| 339 |
+
)
|
| 340 |
+
|
| 341 |
+
with get_dist(tmpdir) as dist:
|
| 342 |
+
assert dist.metadata.version == '1.2.3'
|
| 343 |
+
|
| 344 |
+
def test_unknown_meta_item(self, tmpdir):
|
| 345 |
+
fake_env(tmpdir, '[metadata]\nname = fake_name\nunknown = some\n')
|
| 346 |
+
with get_dist(tmpdir, parse=False) as dist:
|
| 347 |
+
dist.parse_config_files() # Skip unknown.
|
| 348 |
+
|
| 349 |
+
def test_usupported_section(self, tmpdir):
|
| 350 |
+
fake_env(tmpdir, '[metadata.some]\nkey = val\n')
|
| 351 |
+
with get_dist(tmpdir, parse=False) as dist:
|
| 352 |
+
with pytest.raises(DistutilsOptionError):
|
| 353 |
+
dist.parse_config_files()
|
| 354 |
+
|
| 355 |
+
def test_classifiers(self, tmpdir):
|
| 356 |
+
expected = set([
|
| 357 |
+
'Framework :: Django',
|
| 358 |
+
'Programming Language :: Python :: 3',
|
| 359 |
+
'Programming Language :: Python :: 3.5',
|
| 360 |
+
])
|
| 361 |
+
|
| 362 |
+
# From file.
|
| 363 |
+
_, config = fake_env(tmpdir, '[metadata]\nclassifiers = file: classifiers\n')
|
| 364 |
+
|
| 365 |
+
tmpdir.join('classifiers').write(
|
| 366 |
+
'Framework :: Django\n'
|
| 367 |
+
'Programming Language :: Python :: 3\n'
|
| 368 |
+
'Programming Language :: Python :: 3.5\n'
|
| 369 |
+
)
|
| 370 |
+
|
| 371 |
+
with get_dist(tmpdir) as dist:
|
| 372 |
+
assert set(dist.metadata.classifiers) == expected
|
| 373 |
+
|
| 374 |
+
# From list notation
|
| 375 |
+
config.write(
|
| 376 |
+
'[metadata]\n'
|
| 377 |
+
'classifiers =\n'
|
| 378 |
+
' Framework :: Django\n'
|
| 379 |
+
' Programming Language :: Python :: 3\n'
|
| 380 |
+
' Programming Language :: Python :: 3.5\n'
|
| 381 |
+
)
|
| 382 |
+
with get_dist(tmpdir) as dist:
|
| 383 |
+
assert set(dist.metadata.classifiers) == expected
|
| 384 |
+
|
| 385 |
+
def test_interpolation(self, tmpdir):
|
| 386 |
+
fake_env(tmpdir, '[metadata]\ndescription = %(message)s\n')
|
| 387 |
+
with pytest.raises(configparser.InterpolationMissingOptionError):
|
| 388 |
+
with get_dist(tmpdir):
|
| 389 |
+
pass
|
| 390 |
+
|
| 391 |
+
def test_non_ascii_1(self, tmpdir):
|
| 392 |
+
fake_env(tmpdir, '[metadata]\ndescription = éàïôñ\n', encoding='utf-8')
|
| 393 |
+
with get_dist(tmpdir):
|
| 394 |
+
pass
|
| 395 |
+
|
| 396 |
+
def test_non_ascii_3(self, tmpdir):
|
| 397 |
+
fake_env(tmpdir, '\n# -*- coding: invalid\n')
|
| 398 |
+
with get_dist(tmpdir):
|
| 399 |
+
pass
|
| 400 |
+
|
| 401 |
+
def test_non_ascii_4(self, tmpdir):
|
| 402 |
+
fake_env(
|
| 403 |
+
tmpdir,
|
| 404 |
+
'# -*- coding: utf-8\n[metadata]\ndescription = éàïôñ\n',
|
| 405 |
+
encoding='utf-8',
|
| 406 |
+
)
|
| 407 |
+
with get_dist(tmpdir) as dist:
|
| 408 |
+
assert dist.metadata.description == 'éàïôñ'
|
| 409 |
+
|
| 410 |
+
def test_not_utf8(self, tmpdir):
|
| 411 |
+
"""
|
| 412 |
+
Config files encoded not in UTF-8 will fail
|
| 413 |
+
"""
|
| 414 |
+
fake_env(
|
| 415 |
+
tmpdir,
|
| 416 |
+
'# vim: set fileencoding=iso-8859-15 :\n[metadata]\ndescription = éàïôñ\n',
|
| 417 |
+
encoding='iso-8859-15',
|
| 418 |
+
)
|
| 419 |
+
with pytest.raises(UnicodeDecodeError):
|
| 420 |
+
with get_dist(tmpdir):
|
| 421 |
+
pass
|
| 422 |
+
|
| 423 |
+
def test_warn_dash_deprecation(self, tmpdir):
|
| 424 |
+
# warn_dash_deprecation() is a method in setuptools.dist
|
| 425 |
+
# remove this test and the method when no longer needed
|
| 426 |
+
fake_env(
|
| 427 |
+
tmpdir,
|
| 428 |
+
'[metadata]\n'
|
| 429 |
+
'author-email = test@test.com\n'
|
| 430 |
+
'maintainer_email = foo@foo.com\n',
|
| 431 |
+
)
|
| 432 |
+
msg = "Usage of dash-separated 'author-email' will not be supported"
|
| 433 |
+
with pytest.warns(SetuptoolsDeprecationWarning, match=msg):
|
| 434 |
+
with get_dist(tmpdir) as dist:
|
| 435 |
+
metadata = dist.metadata
|
| 436 |
+
|
| 437 |
+
assert metadata.author_email == 'test@test.com'
|
| 438 |
+
assert metadata.maintainer_email == 'foo@foo.com'
|
| 439 |
+
|
| 440 |
+
def test_make_option_lowercase(self, tmpdir):
|
| 441 |
+
# remove this test and the method make_option_lowercase() in setuptools.dist
|
| 442 |
+
# when no longer needed
|
| 443 |
+
fake_env(tmpdir, '[metadata]\nName = foo\ndescription = Some description\n')
|
| 444 |
+
msg = "Usage of uppercase key 'Name' in 'metadata' will not be supported"
|
| 445 |
+
with pytest.warns(SetuptoolsDeprecationWarning, match=msg):
|
| 446 |
+
with get_dist(tmpdir) as dist:
|
| 447 |
+
metadata = dist.metadata
|
| 448 |
+
|
| 449 |
+
assert metadata.name == 'foo'
|
| 450 |
+
assert metadata.description == 'Some description'
|
| 451 |
+
|
| 452 |
+
|
| 453 |
+
class TestOptions:
|
| 454 |
+
def test_basic(self, tmpdir):
|
| 455 |
+
fake_env(
|
| 456 |
+
tmpdir,
|
| 457 |
+
'[options]\n'
|
| 458 |
+
'zip_safe = True\n'
|
| 459 |
+
'include_package_data = yes\n'
|
| 460 |
+
'package_dir = b=c, =src\n'
|
| 461 |
+
'packages = pack_a, pack_b.subpack\n'
|
| 462 |
+
'namespace_packages = pack1, pack2\n'
|
| 463 |
+
'scripts = bin/one.py, bin/two.py\n'
|
| 464 |
+
'eager_resources = bin/one.py, bin/two.py\n'
|
| 465 |
+
'install_requires = docutils>=0.3; pack ==1.1, ==1.3; hey\n'
|
| 466 |
+
'setup_requires = docutils>=0.3; spack ==1.1, ==1.3; there\n'
|
| 467 |
+
'dependency_links = http://some.com/here/1, '
|
| 468 |
+
'http://some.com/there/2\n'
|
| 469 |
+
'python_requires = >=1.0, !=2.8\n'
|
| 470 |
+
'py_modules = module1, module2\n',
|
| 471 |
+
)
|
| 472 |
+
deprec = pytest.warns(SetuptoolsDeprecationWarning, match="namespace_packages")
|
| 473 |
+
with deprec, get_dist(tmpdir) as dist:
|
| 474 |
+
assert dist.zip_safe
|
| 475 |
+
assert dist.include_package_data
|
| 476 |
+
assert dist.package_dir == {'': 'src', 'b': 'c'}
|
| 477 |
+
assert dist.packages == ['pack_a', 'pack_b.subpack']
|
| 478 |
+
assert dist.namespace_packages == ['pack1', 'pack2']
|
| 479 |
+
assert dist.scripts == ['bin/one.py', 'bin/two.py']
|
| 480 |
+
assert dist.dependency_links == ([
|
| 481 |
+
'http://some.com/here/1',
|
| 482 |
+
'http://some.com/there/2',
|
| 483 |
+
])
|
| 484 |
+
assert dist.install_requires == ([
|
| 485 |
+
'docutils>=0.3',
|
| 486 |
+
'pack==1.1,==1.3',
|
| 487 |
+
'hey',
|
| 488 |
+
])
|
| 489 |
+
assert dist.setup_requires == ([
|
| 490 |
+
'docutils>=0.3',
|
| 491 |
+
'spack ==1.1, ==1.3',
|
| 492 |
+
'there',
|
| 493 |
+
])
|
| 494 |
+
assert dist.python_requires == '>=1.0, !=2.8'
|
| 495 |
+
assert dist.py_modules == ['module1', 'module2']
|
| 496 |
+
|
| 497 |
+
def test_multiline(self, tmpdir):
|
| 498 |
+
fake_env(
|
| 499 |
+
tmpdir,
|
| 500 |
+
'[options]\n'
|
| 501 |
+
'package_dir = \n'
|
| 502 |
+
' b=c\n'
|
| 503 |
+
' =src\n'
|
| 504 |
+
'packages = \n'
|
| 505 |
+
' pack_a\n'
|
| 506 |
+
' pack_b.subpack\n'
|
| 507 |
+
'namespace_packages = \n'
|
| 508 |
+
' pack1\n'
|
| 509 |
+
' pack2\n'
|
| 510 |
+
'scripts = \n'
|
| 511 |
+
' bin/one.py\n'
|
| 512 |
+
' bin/two.py\n'
|
| 513 |
+
'eager_resources = \n'
|
| 514 |
+
' bin/one.py\n'
|
| 515 |
+
' bin/two.py\n'
|
| 516 |
+
'install_requires = \n'
|
| 517 |
+
' docutils>=0.3\n'
|
| 518 |
+
' pack ==1.1, ==1.3\n'
|
| 519 |
+
' hey\n'
|
| 520 |
+
'setup_requires = \n'
|
| 521 |
+
' docutils>=0.3\n'
|
| 522 |
+
' spack ==1.1, ==1.3\n'
|
| 523 |
+
' there\n'
|
| 524 |
+
'dependency_links = \n'
|
| 525 |
+
' http://some.com/here/1\n'
|
| 526 |
+
' http://some.com/there/2\n',
|
| 527 |
+
)
|
| 528 |
+
deprec = pytest.warns(SetuptoolsDeprecationWarning, match="namespace_packages")
|
| 529 |
+
with deprec, get_dist(tmpdir) as dist:
|
| 530 |
+
assert dist.package_dir == {'': 'src', 'b': 'c'}
|
| 531 |
+
assert dist.packages == ['pack_a', 'pack_b.subpack']
|
| 532 |
+
assert dist.namespace_packages == ['pack1', 'pack2']
|
| 533 |
+
assert dist.scripts == ['bin/one.py', 'bin/two.py']
|
| 534 |
+
assert dist.dependency_links == ([
|
| 535 |
+
'http://some.com/here/1',
|
| 536 |
+
'http://some.com/there/2',
|
| 537 |
+
])
|
| 538 |
+
assert dist.install_requires == ([
|
| 539 |
+
'docutils>=0.3',
|
| 540 |
+
'pack==1.1,==1.3',
|
| 541 |
+
'hey',
|
| 542 |
+
])
|
| 543 |
+
assert dist.setup_requires == ([
|
| 544 |
+
'docutils>=0.3',
|
| 545 |
+
'spack ==1.1, ==1.3',
|
| 546 |
+
'there',
|
| 547 |
+
])
|
| 548 |
+
|
| 549 |
+
def test_package_dir_fail(self, tmpdir):
|
| 550 |
+
fake_env(tmpdir, '[options]\npackage_dir = a b\n')
|
| 551 |
+
with get_dist(tmpdir, parse=False) as dist:
|
| 552 |
+
with pytest.raises(DistutilsOptionError):
|
| 553 |
+
dist.parse_config_files()
|
| 554 |
+
|
| 555 |
+
def test_package_data(self, tmpdir):
|
| 556 |
+
fake_env(
|
| 557 |
+
tmpdir,
|
| 558 |
+
'[options.package_data]\n'
|
| 559 |
+
'* = *.txt, *.rst\n'
|
| 560 |
+
'hello = *.msg\n'
|
| 561 |
+
'\n'
|
| 562 |
+
'[options.exclude_package_data]\n'
|
| 563 |
+
'* = fake1.txt, fake2.txt\n'
|
| 564 |
+
'hello = *.dat\n',
|
| 565 |
+
)
|
| 566 |
+
|
| 567 |
+
with get_dist(tmpdir) as dist:
|
| 568 |
+
assert dist.package_data == {
|
| 569 |
+
'': ['*.txt', '*.rst'],
|
| 570 |
+
'hello': ['*.msg'],
|
| 571 |
+
}
|
| 572 |
+
assert dist.exclude_package_data == {
|
| 573 |
+
'': ['fake1.txt', 'fake2.txt'],
|
| 574 |
+
'hello': ['*.dat'],
|
| 575 |
+
}
|
| 576 |
+
|
| 577 |
+
def test_packages(self, tmpdir):
|
| 578 |
+
fake_env(tmpdir, '[options]\npackages = find:\n')
|
| 579 |
+
|
| 580 |
+
with get_dist(tmpdir) as dist:
|
| 581 |
+
assert dist.packages == ['fake_package']
|
| 582 |
+
|
| 583 |
+
def test_find_directive(self, tmpdir):
|
| 584 |
+
dir_package, config = fake_env(tmpdir, '[options]\npackages = find:\n')
|
| 585 |
+
|
| 586 |
+
make_package_dir('sub_one', dir_package)
|
| 587 |
+
make_package_dir('sub_two', dir_package)
|
| 588 |
+
|
| 589 |
+
with get_dist(tmpdir) as dist:
|
| 590 |
+
assert set(dist.packages) == set([
|
| 591 |
+
'fake_package',
|
| 592 |
+
'fake_package.sub_two',
|
| 593 |
+
'fake_package.sub_one',
|
| 594 |
+
])
|
| 595 |
+
|
| 596 |
+
config.write(
|
| 597 |
+
'[options]\n'
|
| 598 |
+
'packages = find:\n'
|
| 599 |
+
'\n'
|
| 600 |
+
'[options.packages.find]\n'
|
| 601 |
+
'where = .\n'
|
| 602 |
+
'include =\n'
|
| 603 |
+
' fake_package.sub_one\n'
|
| 604 |
+
' two\n'
|
| 605 |
+
)
|
| 606 |
+
with get_dist(tmpdir) as dist:
|
| 607 |
+
assert dist.packages == ['fake_package.sub_one']
|
| 608 |
+
|
| 609 |
+
config.write(
|
| 610 |
+
'[options]\n'
|
| 611 |
+
'packages = find:\n'
|
| 612 |
+
'\n'
|
| 613 |
+
'[options.packages.find]\n'
|
| 614 |
+
'exclude =\n'
|
| 615 |
+
' fake_package.sub_one\n'
|
| 616 |
+
)
|
| 617 |
+
with get_dist(tmpdir) as dist:
|
| 618 |
+
assert set(dist.packages) == set(['fake_package', 'fake_package.sub_two'])
|
| 619 |
+
|
| 620 |
+
def test_find_namespace_directive(self, tmpdir):
|
| 621 |
+
dir_package, config = fake_env(
|
| 622 |
+
tmpdir, '[options]\npackages = find_namespace:\n'
|
| 623 |
+
)
|
| 624 |
+
|
| 625 |
+
make_package_dir('sub_one', dir_package)
|
| 626 |
+
make_package_dir('sub_two', dir_package, ns=True)
|
| 627 |
+
|
| 628 |
+
with get_dist(tmpdir) as dist:
|
| 629 |
+
assert set(dist.packages) == {
|
| 630 |
+
'fake_package',
|
| 631 |
+
'fake_package.sub_two',
|
| 632 |
+
'fake_package.sub_one',
|
| 633 |
+
}
|
| 634 |
+
|
| 635 |
+
config.write(
|
| 636 |
+
'[options]\n'
|
| 637 |
+
'packages = find_namespace:\n'
|
| 638 |
+
'\n'
|
| 639 |
+
'[options.packages.find]\n'
|
| 640 |
+
'where = .\n'
|
| 641 |
+
'include =\n'
|
| 642 |
+
' fake_package.sub_one\n'
|
| 643 |
+
' two\n'
|
| 644 |
+
)
|
| 645 |
+
with get_dist(tmpdir) as dist:
|
| 646 |
+
assert dist.packages == ['fake_package.sub_one']
|
| 647 |
+
|
| 648 |
+
config.write(
|
| 649 |
+
'[options]\n'
|
| 650 |
+
'packages = find_namespace:\n'
|
| 651 |
+
'\n'
|
| 652 |
+
'[options.packages.find]\n'
|
| 653 |
+
'exclude =\n'
|
| 654 |
+
' fake_package.sub_one\n'
|
| 655 |
+
)
|
| 656 |
+
with get_dist(tmpdir) as dist:
|
| 657 |
+
assert set(dist.packages) == {'fake_package', 'fake_package.sub_two'}
|
| 658 |
+
|
| 659 |
+
def test_extras_require(self, tmpdir):
|
| 660 |
+
fake_env(
|
| 661 |
+
tmpdir,
|
| 662 |
+
'[options.extras_require]\n'
|
| 663 |
+
'pdf = ReportLab>=1.2; RXP\n'
|
| 664 |
+
'rest = \n'
|
| 665 |
+
' docutils>=0.3\n'
|
| 666 |
+
' pack ==1.1, ==1.3\n',
|
| 667 |
+
)
|
| 668 |
+
|
| 669 |
+
with get_dist(tmpdir) as dist:
|
| 670 |
+
assert dist.extras_require == {
|
| 671 |
+
'pdf': ['ReportLab>=1.2', 'RXP'],
|
| 672 |
+
'rest': ['docutils>=0.3', 'pack==1.1,==1.3'],
|
| 673 |
+
}
|
| 674 |
+
assert set(dist.metadata.provides_extras) == {'pdf', 'rest'}
|
| 675 |
+
|
| 676 |
+
@pytest.mark.parametrize(
|
| 677 |
+
"config",
|
| 678 |
+
[
|
| 679 |
+
"[options.extras_require]\nfoo = bar;python_version<'3'",
|
| 680 |
+
"[options.extras_require]\nfoo = bar;os_name=='linux'",
|
| 681 |
+
"[options.extras_require]\nfoo = bar;python_version<'3'\n",
|
| 682 |
+
"[options.extras_require]\nfoo = bar;os_name=='linux'\n",
|
| 683 |
+
"[options]\ninstall_requires = bar;python_version<'3'",
|
| 684 |
+
"[options]\ninstall_requires = bar;os_name=='linux'",
|
| 685 |
+
"[options]\ninstall_requires = bar;python_version<'3'\n",
|
| 686 |
+
"[options]\ninstall_requires = bar;os_name=='linux'\n",
|
| 687 |
+
],
|
| 688 |
+
)
|
| 689 |
+
def test_raises_accidental_env_marker_misconfig(self, config, tmpdir):
|
| 690 |
+
fake_env(tmpdir, config)
|
| 691 |
+
match = (
|
| 692 |
+
r"One of the parsed requirements in `(install_requires|extras_require.+)` "
|
| 693 |
+
"looks like a valid environment marker.*"
|
| 694 |
+
)
|
| 695 |
+
with pytest.raises(InvalidRequirement, match=match):
|
| 696 |
+
with get_dist(tmpdir) as _:
|
| 697 |
+
pass
|
| 698 |
+
|
| 699 |
+
@pytest.mark.parametrize(
|
| 700 |
+
"config",
|
| 701 |
+
[
|
| 702 |
+
"[options.extras_require]\nfoo = bar;python_version<3",
|
| 703 |
+
"[options.extras_require]\nfoo = bar;python_version<3\n",
|
| 704 |
+
"[options]\ninstall_requires = bar;python_version<3",
|
| 705 |
+
"[options]\ninstall_requires = bar;python_version<3\n",
|
| 706 |
+
],
|
| 707 |
+
)
|
| 708 |
+
def test_warn_accidental_env_marker_misconfig(self, config, tmpdir):
|
| 709 |
+
fake_env(tmpdir, config)
|
| 710 |
+
match = (
|
| 711 |
+
r"One of the parsed requirements in `(install_requires|extras_require.+)` "
|
| 712 |
+
"looks like a valid environment marker.*"
|
| 713 |
+
)
|
| 714 |
+
with pytest.warns(SetuptoolsDeprecationWarning, match=match):
|
| 715 |
+
with get_dist(tmpdir) as _:
|
| 716 |
+
pass
|
| 717 |
+
|
| 718 |
+
@pytest.mark.parametrize(
|
| 719 |
+
"config",
|
| 720 |
+
[
|
| 721 |
+
"[options.extras_require]\nfoo =\n bar;python_version<'3'",
|
| 722 |
+
"[options.extras_require]\nfoo = bar;baz\nboo = xxx;yyy",
|
| 723 |
+
"[options.extras_require]\nfoo =\n bar;python_version<'3'\n",
|
| 724 |
+
"[options.extras_require]\nfoo = bar;baz\nboo = xxx;yyy\n",
|
| 725 |
+
"[options.extras_require]\nfoo =\n bar\n python_version<3\n",
|
| 726 |
+
"[options]\ninstall_requires =\n bar;python_version<'3'",
|
| 727 |
+
"[options]\ninstall_requires = bar;baz\nboo = xxx;yyy",
|
| 728 |
+
"[options]\ninstall_requires =\n bar;python_version<'3'\n",
|
| 729 |
+
"[options]\ninstall_requires = bar;baz\nboo = xxx;yyy\n",
|
| 730 |
+
"[options]\ninstall_requires =\n bar\n python_version<3\n",
|
| 731 |
+
],
|
| 732 |
+
)
|
| 733 |
+
@pytest.mark.filterwarnings("error::setuptools.SetuptoolsDeprecationWarning")
|
| 734 |
+
def test_nowarn_accidental_env_marker_misconfig(self, config, tmpdir, recwarn):
|
| 735 |
+
fake_env(tmpdir, config)
|
| 736 |
+
num_warnings = len(recwarn)
|
| 737 |
+
with get_dist(tmpdir) as _:
|
| 738 |
+
pass
|
| 739 |
+
# The examples are valid, no warnings shown
|
| 740 |
+
assert len(recwarn) == num_warnings
|
| 741 |
+
|
| 742 |
+
def test_dash_preserved_extras_require(self, tmpdir):
|
| 743 |
+
fake_env(tmpdir, '[options.extras_require]\nfoo-a = foo\nfoo_b = test\n')
|
| 744 |
+
|
| 745 |
+
with get_dist(tmpdir) as dist:
|
| 746 |
+
assert dist.extras_require == {'foo-a': ['foo'], 'foo_b': ['test']}
|
| 747 |
+
|
| 748 |
+
def test_entry_points(self, tmpdir):
|
| 749 |
+
_, config = fake_env(
|
| 750 |
+
tmpdir,
|
| 751 |
+
'[options.entry_points]\n'
|
| 752 |
+
'group1 = point1 = pack.module:func, '
|
| 753 |
+
'.point2 = pack.module2:func_rest [rest]\n'
|
| 754 |
+
'group2 = point3 = pack.module:func2\n',
|
| 755 |
+
)
|
| 756 |
+
|
| 757 |
+
with get_dist(tmpdir) as dist:
|
| 758 |
+
assert dist.entry_points == {
|
| 759 |
+
'group1': [
|
| 760 |
+
'point1 = pack.module:func',
|
| 761 |
+
'.point2 = pack.module2:func_rest [rest]',
|
| 762 |
+
],
|
| 763 |
+
'group2': ['point3 = pack.module:func2'],
|
| 764 |
+
}
|
| 765 |
+
|
| 766 |
+
expected = (
|
| 767 |
+
'[blogtool.parsers]\n'
|
| 768 |
+
'.rst = some.nested.module:SomeClass.some_classmethod[reST]\n'
|
| 769 |
+
)
|
| 770 |
+
|
| 771 |
+
tmpdir.join('entry_points').write(expected)
|
| 772 |
+
|
| 773 |
+
# From file.
|
| 774 |
+
config.write('[options]\nentry_points = file: entry_points\n')
|
| 775 |
+
|
| 776 |
+
with get_dist(tmpdir) as dist:
|
| 777 |
+
assert dist.entry_points == expected
|
| 778 |
+
|
| 779 |
+
def test_case_sensitive_entry_points(self, tmpdir):
|
| 780 |
+
fake_env(
|
| 781 |
+
tmpdir,
|
| 782 |
+
'[options.entry_points]\n'
|
| 783 |
+
'GROUP1 = point1 = pack.module:func, '
|
| 784 |
+
'.point2 = pack.module2:func_rest [rest]\n'
|
| 785 |
+
'group2 = point3 = pack.module:func2\n',
|
| 786 |
+
)
|
| 787 |
+
|
| 788 |
+
with get_dist(tmpdir) as dist:
|
| 789 |
+
assert dist.entry_points == {
|
| 790 |
+
'GROUP1': [
|
| 791 |
+
'point1 = pack.module:func',
|
| 792 |
+
'.point2 = pack.module2:func_rest [rest]',
|
| 793 |
+
],
|
| 794 |
+
'group2': ['point3 = pack.module:func2'],
|
| 795 |
+
}
|
| 796 |
+
|
| 797 |
+
def test_data_files(self, tmpdir):
|
| 798 |
+
fake_env(
|
| 799 |
+
tmpdir,
|
| 800 |
+
'[options.data_files]\n'
|
| 801 |
+
'cfg =\n'
|
| 802 |
+
' a/b.conf\n'
|
| 803 |
+
' c/d.conf\n'
|
| 804 |
+
'data = e/f.dat, g/h.dat\n',
|
| 805 |
+
)
|
| 806 |
+
|
| 807 |
+
with get_dist(tmpdir) as dist:
|
| 808 |
+
expected = [
|
| 809 |
+
('cfg', ['a/b.conf', 'c/d.conf']),
|
| 810 |
+
('data', ['e/f.dat', 'g/h.dat']),
|
| 811 |
+
]
|
| 812 |
+
assert sorted(dist.data_files) == sorted(expected)
|
| 813 |
+
|
| 814 |
+
def test_data_files_globby(self, tmpdir):
|
| 815 |
+
fake_env(
|
| 816 |
+
tmpdir,
|
| 817 |
+
'[options.data_files]\n'
|
| 818 |
+
'cfg =\n'
|
| 819 |
+
' a/b.conf\n'
|
| 820 |
+
' c/d.conf\n'
|
| 821 |
+
'data = *.dat\n'
|
| 822 |
+
'icons = \n'
|
| 823 |
+
' *.ico\n'
|
| 824 |
+
'audio = \n'
|
| 825 |
+
' *.wav\n'
|
| 826 |
+
' sounds.db\n',
|
| 827 |
+
)
|
| 828 |
+
|
| 829 |
+
# Create dummy files for glob()'s sake:
|
| 830 |
+
tmpdir.join('a.dat').write('')
|
| 831 |
+
tmpdir.join('b.dat').write('')
|
| 832 |
+
tmpdir.join('c.dat').write('')
|
| 833 |
+
tmpdir.join('a.ico').write('')
|
| 834 |
+
tmpdir.join('b.ico').write('')
|
| 835 |
+
tmpdir.join('c.ico').write('')
|
| 836 |
+
tmpdir.join('beep.wav').write('')
|
| 837 |
+
tmpdir.join('boop.wav').write('')
|
| 838 |
+
tmpdir.join('sounds.db').write('')
|
| 839 |
+
|
| 840 |
+
with get_dist(tmpdir) as dist:
|
| 841 |
+
expected = [
|
| 842 |
+
('cfg', ['a/b.conf', 'c/d.conf']),
|
| 843 |
+
('data', ['a.dat', 'b.dat', 'c.dat']),
|
| 844 |
+
('icons', ['a.ico', 'b.ico', 'c.ico']),
|
| 845 |
+
('audio', ['beep.wav', 'boop.wav', 'sounds.db']),
|
| 846 |
+
]
|
| 847 |
+
assert sorted(dist.data_files) == sorted(expected)
|
| 848 |
+
|
| 849 |
+
def test_python_requires_simple(self, tmpdir):
|
| 850 |
+
fake_env(
|
| 851 |
+
tmpdir,
|
| 852 |
+
DALS(
|
| 853 |
+
"""
|
| 854 |
+
[options]
|
| 855 |
+
python_requires=>=2.7
|
| 856 |
+
"""
|
| 857 |
+
),
|
| 858 |
+
)
|
| 859 |
+
with get_dist(tmpdir) as dist:
|
| 860 |
+
dist.parse_config_files()
|
| 861 |
+
|
| 862 |
+
def test_python_requires_compound(self, tmpdir):
|
| 863 |
+
fake_env(
|
| 864 |
+
tmpdir,
|
| 865 |
+
DALS(
|
| 866 |
+
"""
|
| 867 |
+
[options]
|
| 868 |
+
python_requires=>=2.7,!=3.0.*
|
| 869 |
+
"""
|
| 870 |
+
),
|
| 871 |
+
)
|
| 872 |
+
with get_dist(tmpdir) as dist:
|
| 873 |
+
dist.parse_config_files()
|
| 874 |
+
|
| 875 |
+
def test_python_requires_invalid(self, tmpdir):
|
| 876 |
+
fake_env(
|
| 877 |
+
tmpdir,
|
| 878 |
+
DALS(
|
| 879 |
+
"""
|
| 880 |
+
[options]
|
| 881 |
+
python_requires=invalid
|
| 882 |
+
"""
|
| 883 |
+
),
|
| 884 |
+
)
|
| 885 |
+
with pytest.raises(Exception):
|
| 886 |
+
with get_dist(tmpdir) as dist:
|
| 887 |
+
dist.parse_config_files()
|
| 888 |
+
|
| 889 |
+
def test_cmdclass(self, tmpdir):
|
| 890 |
+
module_path = Path(tmpdir, "src/custom_build.py") # auto discovery for src
|
| 891 |
+
module_path.parent.mkdir(parents=True, exist_ok=True)
|
| 892 |
+
module_path.write_text(
|
| 893 |
+
"from distutils.core import Command\nclass CustomCmd(Command): pass\n",
|
| 894 |
+
encoding="utf-8",
|
| 895 |
+
)
|
| 896 |
+
|
| 897 |
+
setup_cfg = """
|
| 898 |
+
[options]
|
| 899 |
+
cmdclass =
|
| 900 |
+
customcmd = custom_build.CustomCmd
|
| 901 |
+
"""
|
| 902 |
+
fake_env(tmpdir, inspect.cleandoc(setup_cfg))
|
| 903 |
+
|
| 904 |
+
with get_dist(tmpdir) as dist:
|
| 905 |
+
cmdclass = dist.cmdclass['customcmd']
|
| 906 |
+
assert cmdclass.__name__ == "CustomCmd"
|
| 907 |
+
assert cmdclass.__module__ == "custom_build"
|
| 908 |
+
assert module_path.samefile(inspect.getfile(cmdclass))
|
| 909 |
+
|
| 910 |
+
def test_requirements_file(self, tmpdir):
|
| 911 |
+
fake_env(
|
| 912 |
+
tmpdir,
|
| 913 |
+
DALS(
|
| 914 |
+
"""
|
| 915 |
+
[options]
|
| 916 |
+
install_requires = file:requirements.txt
|
| 917 |
+
[options.extras_require]
|
| 918 |
+
colors = file:requirements-extra.txt
|
| 919 |
+
"""
|
| 920 |
+
),
|
| 921 |
+
)
|
| 922 |
+
|
| 923 |
+
tmpdir.join('requirements.txt').write('\ndocutils>=0.3\n\n')
|
| 924 |
+
tmpdir.join('requirements-extra.txt').write('colorama')
|
| 925 |
+
|
| 926 |
+
with get_dist(tmpdir) as dist:
|
| 927 |
+
assert dist.install_requires == ['docutils>=0.3']
|
| 928 |
+
assert dist.extras_require == {'colors': ['colorama']}
|
| 929 |
+
|
| 930 |
+
|
| 931 |
+
saved_dist_init = _Distribution.__init__
|
| 932 |
+
|
| 933 |
+
|
| 934 |
+
class TestExternalSetters:
|
| 935 |
+
# During creation of the setuptools Distribution() object, we call
|
| 936 |
+
# the init of the parent distutils Distribution object via
|
| 937 |
+
# _Distribution.__init__ ().
|
| 938 |
+
#
|
| 939 |
+
# It's possible distutils calls out to various keyword
|
| 940 |
+
# implementations (i.e. distutils.setup_keywords entry points)
|
| 941 |
+
# that may set a range of variables.
|
| 942 |
+
#
|
| 943 |
+
# This wraps distutil's Distribution.__init__ and simulates
|
| 944 |
+
# pbr or something else setting these values.
|
| 945 |
+
def _fake_distribution_init(self, dist, attrs):
|
| 946 |
+
saved_dist_init(dist, attrs)
|
| 947 |
+
# see self._DISTUTILS_UNSUPPORTED_METADATA
|
| 948 |
+
dist.metadata.long_description_content_type = 'text/something'
|
| 949 |
+
# Test overwrite setup() args
|
| 950 |
+
dist.metadata.project_urls = {
|
| 951 |
+
'Link One': 'https://example.com/one/',
|
| 952 |
+
'Link Two': 'https://example.com/two/',
|
| 953 |
+
}
|
| 954 |
+
|
| 955 |
+
@patch.object(_Distribution, '__init__', autospec=True)
|
| 956 |
+
def test_external_setters(self, mock_parent_init, tmpdir):
|
| 957 |
+
mock_parent_init.side_effect = self._fake_distribution_init
|
| 958 |
+
|
| 959 |
+
dist = Distribution(attrs={'project_urls': {'will_be': 'ignored'}})
|
| 960 |
+
|
| 961 |
+
assert dist.metadata.long_description_content_type == 'text/something'
|
| 962 |
+
assert dist.metadata.project_urls == {
|
| 963 |
+
'Link One': 'https://example.com/one/',
|
| 964 |
+
'Link Two': 'https://example.com/two/',
|
| 965 |
+
}
|
minigpt2/lib/python3.10/site-packages/dockerpycreds/__pycache__/__init__.cpython-310.pyc
ADDED
|
Binary file (299 Bytes). View file
|
|
|
minigpt2/lib/python3.10/site-packages/dockerpycreds/__pycache__/errors.cpython-310.pyc
ADDED
|
Binary file (952 Bytes). View file
|
|
|
minigpt2/lib/python3.10/site-packages/dockerpycreds/__pycache__/store.cpython-310.pyc
ADDED
|
Binary file (3.2 kB). View file
|
|
|
minigpt2/lib/python3.10/site-packages/dockerpycreds/__pycache__/utils.cpython-310.pyc
ADDED
|
Binary file (1.12 kB). View file
|
|
|
minigpt2/lib/python3.10/site-packages/dockerpycreds/__pycache__/version.cpython-310.pyc
ADDED
|
Binary file (372 Bytes). View file
|
|
|
minigpt2/lib/python3.10/site-packages/dockerpycreds/errors.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class StoreError(RuntimeError):
|
| 2 |
+
pass
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
class CredentialsNotFound(StoreError):
|
| 6 |
+
pass
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
class InitializationError(StoreError):
|
| 10 |
+
pass
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def process_store_error(cpe, program):
|
| 14 |
+
message = cpe.output.decode('utf-8')
|
| 15 |
+
if 'credentials not found in native keychain' in message:
|
| 16 |
+
return CredentialsNotFound(
|
| 17 |
+
'No matching credentials in {0}'.format(
|
| 18 |
+
program
|
| 19 |
+
)
|
| 20 |
+
)
|
| 21 |
+
return StoreError(
|
| 22 |
+
'Credentials store {0} exited with "{1}".'.format(
|
| 23 |
+
program, cpe.output.decode('utf-8').strip()
|
| 24 |
+
)
|
| 25 |
+
)
|
minigpt2/lib/python3.10/site-packages/dockerpycreds/version.py
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version = "0.4.0"
|
| 2 |
+
version_info = tuple([int(d) for d in version.split("-")[0].split(".")])
|
minigpt2/lib/python3.10/site-packages/open_flamingo/src/__pycache__/factory.cpython-310.pyc
ADDED
|
Binary file (3.67 kB). View file
|
|
|
minigpt2/lib/python3.10/site-packages/open_flamingo/src/__pycache__/flamingo_lm.cpython-310.pyc
ADDED
|
Binary file (4.93 kB). View file
|
|
|
minigpt2/lib/python3.10/site-packages/tzdata/__init__.py
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# IANA versions like 2020a are not valid PEP 440 identifiers; the recommended
|
| 2 |
+
# way to translate the version is to use YYYY.n where `n` is a 0-based index.
|
| 3 |
+
__version__ = "2024.2"
|
| 4 |
+
|
| 5 |
+
# This exposes the original IANA version number.
|
| 6 |
+
IANA_VERSION = "2024b"
|
minigpt2/lib/python3.10/site-packages/tzdata/zoneinfo/Cuba
ADDED
|
Binary file (1.12 kB). View file
|
|
|
minigpt2/lib/python3.10/site-packages/tzdata/zoneinfo/EST
ADDED
|
Binary file (149 Bytes). View file
|
|
|
minigpt2/lib/python3.10/site-packages/tzdata/zoneinfo/EST5EDT
ADDED
|
Binary file (1.74 kB). View file
|
|
|
minigpt2/lib/python3.10/site-packages/tzdata/zoneinfo/Egypt
ADDED
|
Binary file (1.31 kB). View file
|
|
|
minigpt2/lib/python3.10/site-packages/tzdata/zoneinfo/Factory
ADDED
|
Binary file (113 Bytes). View file
|
|
|
minigpt2/lib/python3.10/site-packages/tzdata/zoneinfo/GB
ADDED
|
Binary file (1.6 kB). View file
|
|
|
minigpt2/lib/python3.10/site-packages/tzdata/zoneinfo/GMT
ADDED
|
Binary file (111 Bytes). View file
|
|
|
minigpt2/lib/python3.10/site-packages/tzdata/zoneinfo/GMT-0
ADDED
|
Binary file (111 Bytes). View file
|
|
|
minigpt2/lib/python3.10/site-packages/tzdata/zoneinfo/HST
ADDED
|
Binary file (221 Bytes). View file
|
|
|