diff options
-rw-r--r-- | docs/build_meta.rst | 2 | ||||
-rw-r--r-- | docs/deprecated/distutils/commandref.rst | 2 | ||||
-rw-r--r-- | docs/deprecated/distutils/configfile.rst | 1 | ||||
-rw-r--r-- | docs/deprecated/distutils/extending.rst | 2 | ||||
-rw-r--r-- | docs/deprecated/zip_safe.rst | 2 | ||||
-rw-r--r-- | docs/userguide/development_mode.rst | 6 | ||||
-rw-r--r-- | docs/userguide/entry_point.rst | 2 | ||||
-rw-r--r-- | docs/userguide/quickstart.rst | 2 | ||||
-rw-r--r-- | launcher.c | 9 | ||||
-rw-r--r-- | setuptools/tests/test_build_meta.py | 4 | ||||
-rw-r--r-- | setuptools/tests/test_manifest.py | 118 |
11 files changed, 71 insertions, 79 deletions
diff --git a/docs/build_meta.rst b/docs/build_meta.rst index 4ec37453..37738b8f 100644 --- a/docs/build_meta.rst +++ b/docs/build_meta.rst @@ -161,7 +161,7 @@ requirements. and :pypi:`setuptools-svn`), or by correctly setting up :ref:`MANIFEST.in <manifest>`. - The generated ``.tar.gz`` and ``.whl`` files are compressed archives that + The generated ``.tar.gz`` and ``.whl`` files are compressed archives that can be inspected as follows: On POSIX systems, this can be done with ``tar -tf dist/*.tar.gz`` and ``unzip -l dist/*.whl``. diff --git a/docs/deprecated/distutils/commandref.rst b/docs/deprecated/distutils/commandref.rst index 3e247e68..d02b38c3 100644 --- a/docs/deprecated/distutils/commandref.rst +++ b/docs/deprecated/distutils/commandref.rst @@ -101,5 +101,3 @@ anything except backslash or colon. .. % \subsection{\protect\command{bdist}} .. % \subsection{\protect\command{bdist\_dumb}} .. % \subsection{\protect\command{bdist\_rpm}} - - diff --git a/docs/deprecated/distutils/configfile.rst b/docs/deprecated/distutils/configfile.rst index 2a0fbb31..ab199dca 100644 --- a/docs/deprecated/distutils/configfile.rst +++ b/docs/deprecated/distutils/configfile.rst @@ -142,4 +142,3 @@ split across multiple lines for readability. .. [#] This ideal probably won't be achieved until auto-configuration is fully supported by the Distutils. - diff --git a/docs/deprecated/distutils/extending.rst b/docs/deprecated/distutils/extending.rst index c99d3c79..fc494616 100644 --- a/docs/deprecated/distutils/extending.rst +++ b/docs/deprecated/distutils/extending.rst @@ -94,5 +94,3 @@ to add ``(command, filename)`` pairs to ``self.distribution.dist_files`` so that :command:`upload` can upload it to PyPI. The *filename* in the pair contains no path information, only the name of the file itself. In dry-run mode, pairs should still be added to represent what would have been created. - - diff --git a/docs/deprecated/zip_safe.rst b/docs/deprecated/zip_safe.rst index 08a13334..26b45662 100644 --- a/docs/deprecated/zip_safe.rst +++ b/docs/deprecated/zip_safe.rst @@ -62,7 +62,7 @@ Currently, popular Python package installers (such as :pypi:`pip`) and package indexes (such as PyPI_) consider that distribution packages are always installed as a directory. It is however still possible to load packages from zip files added to -:obj:`sys.path`, thanks to the :mod:`zipimport` module +:obj:`sys.path`, thanks to the :mod:`zipimport` module and the :mod:`importlib` machinery provided by Python standard library. When working with modules loaded from a zip file, it is important to keep in diff --git a/docs/userguide/development_mode.rst b/docs/userguide/development_mode.rst index 1716e0af..6f9f5417 100644 --- a/docs/userguide/development_mode.rst +++ b/docs/userguide/development_mode.rst @@ -17,7 +17,7 @@ without requiring a new installation. You can enter this "development mode" by performing an :doc:`editable installation <pip:topics/local-project-installs>` inside of a :term:`virtual environment`, -using :doc:`pip's <pip:cli/pip_install>` ``-e/--editable`` flag, as shown bellow: +using :doc:`pip's <pip:cli/pip_install>` ``-e/--editable`` flag, as shown below: .. code-block:: bash @@ -69,7 +69,7 @@ Please have a look on the following section if you are looking for a different b sudo apt install python3-venv - Alternatively, you can also try installing :pypi:`virtualená´ `. + Alternatively, you can also try installing :pypi:`virtualenv`. More information is available on the Python Packaging User Guide on :doc:`PyPUG:guides/installing-using-pip-and-virtual-environments`. @@ -93,7 +93,7 @@ expectations: Unfortunately these expectations are in conflict with each other. To solve this problem ``setuptools`` allows developers to choose a more *"strict"* mode for the editable installation. This can be done by passing -a special *configuration setting* via :pypi:`pip`, as indicated bellow: +a special *configuration setting* via :pypi:`pip`, as indicated below: .. code-block:: bash diff --git a/docs/userguide/entry_point.rst b/docs/userguide/entry_point.rst index 6ba00287..163ce1d9 100644 --- a/docs/userguide/entry_point.rst +++ b/docs/userguide/entry_point.rst @@ -89,7 +89,7 @@ configuration: .. tab:: setup.py .. code-block:: python - + from setuptools import setup setup( diff --git a/docs/userguide/quickstart.rst b/docs/userguide/quickstart.rst index fe5c5bc2..bf92f6a2 100644 --- a/docs/userguide/quickstart.rst +++ b/docs/userguide/quickstart.rst @@ -165,7 +165,7 @@ to specify to properly package your project. :doc:`setup.cfg <declarative_config>`, and keep the ``setup.py`` minimal with only the dynamic parts (or even omit it completely if applicable). - See `Why you shouldn't invoke setup.py directly`_ for more background. + See `Why you shouldn't invoke setup.py directly`_ for more background. .. _Why you shouldn't invoke setup.py directly: https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html @@ -180,7 +180,7 @@ void pass_control_to_child(DWORD control_type) { } BOOL control_handler(DWORD control_type) { - /* + /* * distribute-issue207 * control event handler callback function */ @@ -204,12 +204,12 @@ int create_and_wait_for_subprocess(char* command) { ZeroMemory(&p_info, sizeof(p_info)); ZeroMemory(&s_info, sizeof(s_info)); s_info.cb = sizeof(STARTUPINFO); - // set-up control handler callback funciotn + // set-up control handler callback function SetConsoleCtrlHandler((PHANDLER_ROUTINE) control_handler, TRUE); if (!CreateProcessA(NULL, commandline, NULL, NULL, TRUE, 0, NULL, NULL, &s_info, &p_info)) { fprintf(stderr, "failed to create process.\n"); return 0; - } + } child_pid = p_info.dwProcessId; // wait for Python to exit WaitForSingleObject(p_info.hProcess, INFINITE); @@ -229,7 +229,7 @@ char* join_executable_and_args(char *executable, char **args, int argc) */ int len,counter; char* cmdline; - + len=strlen(executable)+2; for (counter=1; counter<argc; counter++) { len+=strlen(args[counter])+1; @@ -333,4 +333,3 @@ int WINAPI WinMain(HINSTANCE hI, HINSTANCE hP, LPSTR lpCmd, int nShow) { int main(int argc, char** argv) { return run(argc, argv, GUI); } - diff --git a/setuptools/tests/test_build_meta.py b/setuptools/tests/test_build_meta.py index bf1c27ff..9e55a938 100644 --- a/setuptools/tests/test_build_meta.py +++ b/setuptools/tests/test_build_meta.py @@ -44,7 +44,7 @@ class BuildBackend(BuildBackendBase): self.pool = futures.ProcessPoolExecutor(max_workers=1) def __getattr__(self, name): - """Handles aribrary function invocations on the build backend.""" + """Handles arbitrary function invocations on the build backend.""" def method(*args, **kw): root = os.path.abspath(self.cwd) @@ -79,7 +79,7 @@ class BuildBackendCaller(BuildBackendBase): self.backend_obj) = self.backend_name.partition(':') def __call__(self, name, *args, **kw): - """Handles aribrary function invocations on the build backend.""" + """Handles arbitrary function invocations on the build backend.""" os.chdir(self.cwd) os.environ.update(self.env) mod = importlib.import_module(self.backend_name) diff --git a/setuptools/tests/test_manifest.py b/setuptools/tests/test_manifest.py index ecc83c2f..9301322f 100644 --- a/setuptools/tests/test_manifest.py +++ b/setuptools/tests/test_manifest.py @@ -8,6 +8,7 @@ import sys import tempfile import itertools import io +import logging from distutils import log from distutils.errors import DistutilsTemplateError @@ -18,6 +19,9 @@ from setuptools.tests.textwrap import DALS import pytest +IS_PYPY = '__pypy__' in sys.builtin_module_names + + def make_local_path(s): """Converts '/' in a string to os.sep""" return s.replace('/', os.sep) @@ -321,43 +325,29 @@ class TestFileListTest(TempDirTestCase): to ensure setuptools' version of FileList keeps parity with distutils. """ - def setup_method(self, method): - if not hasattr(log, 'Log'): - pytest.skip("These tests rely on old logging infra") - super(TestFileListTest, self).setup_method(method) - self.threshold = log.set_threshold(log.FATAL) - self._old_log = log.Log._log - log.Log._log = self._log - self.logs = [] + @pytest.fixture(autouse=os.getenv("SETUPTOOLS_USE_DISTUTILS") == "stdlib") + def _compat_record_logs(self, monkeypatch, caplog): + """Account for stdlib compatibility""" + def _log(_logger, level, msg, args): + exc = sys.exc_info() + rec = logging.LogRecord("distutils", level, "", 0, msg, args, exc) + caplog.records.append(rec) - def teardown_method(self, method): - log.set_threshold(self.threshold) - log.Log._log = self._old_log - super(TestFileListTest, self).teardown_method(method) - - def _log(self, level, msg, args): - if level not in (log.DEBUG, log.INFO, log.WARN, log.ERROR, log.FATAL): - raise ValueError('%s wrong log level' % str(level)) - self.logs.append((level, msg, args)) - - def get_logs(self, *levels): - def _format(msg, args): - if len(args) == 0: - return msg - return msg % args - return [_format(msg, args) for level, msg, args - in self.logs if level in levels] - - def clear_logs(self): - self.logs = [] - - def assertNoWarnings(self): - assert self.get_logs(log.WARN) == [] - self.clear_logs() - - def assertWarnings(self): - assert len(self.get_logs(log.WARN)) > 0 - self.clear_logs() + monkeypatch.setattr(log.Log, "_log", _log) + + def get_records(self, caplog, *levels): + return [r for r in caplog.records if r.levelno in levels] + + def assertNoWarnings(self, caplog): + assert self.get_records(caplog, log.WARN) == [] + caplog.clear() + + def assertWarnings(self, caplog): + if IS_PYPY and not caplog.records: + pytest.xfail("caplog checks may not work well in PyPy") + else: + assert len(self.get_records(caplog, log.WARN)) > 0 + caplog.clear() def make_files(self, files): for file in files: @@ -474,7 +464,8 @@ class TestFileListTest(TempDirTestCase): else: assert False, "Should have thrown an error" - def test_include(self): + def test_include(self, caplog): + caplog.set_level(logging.DEBUG) ml = make_local_path # include file_list = FileList() @@ -483,14 +474,15 @@ class TestFileListTest(TempDirTestCase): file_list.process_template_line('include *.py') file_list.sort() assert file_list.files == ['a.py'] - self.assertNoWarnings() + self.assertNoWarnings(caplog) file_list.process_template_line('include *.rb') file_list.sort() assert file_list.files == ['a.py'] - self.assertWarnings() + self.assertWarnings(caplog) - def test_exclude(self): + def test_exclude(self, caplog): + caplog.set_level(logging.DEBUG) ml = make_local_path # exclude file_list = FileList() @@ -499,14 +491,15 @@ class TestFileListTest(TempDirTestCase): file_list.process_template_line('exclude *.py') file_list.sort() assert file_list.files == ['b.txt', ml('d/c.py')] - self.assertNoWarnings() + self.assertNoWarnings(caplog) file_list.process_template_line('exclude *.rb') file_list.sort() assert file_list.files == ['b.txt', ml('d/c.py')] - self.assertWarnings() + self.assertWarnings(caplog) - def test_global_include(self): + def test_global_include(self, caplog): + caplog.set_level(logging.DEBUG) ml = make_local_path # global-include file_list = FileList() @@ -515,14 +508,15 @@ class TestFileListTest(TempDirTestCase): file_list.process_template_line('global-include *.py') file_list.sort() assert file_list.files == ['a.py', ml('d/c.py')] - self.assertNoWarnings() + self.assertNoWarnings(caplog) file_list.process_template_line('global-include *.rb') file_list.sort() assert file_list.files == ['a.py', ml('d/c.py')] - self.assertWarnings() + self.assertWarnings(caplog) - def test_global_exclude(self): + def test_global_exclude(self, caplog): + caplog.set_level(logging.DEBUG) ml = make_local_path # global-exclude file_list = FileList() @@ -531,14 +525,15 @@ class TestFileListTest(TempDirTestCase): file_list.process_template_line('global-exclude *.py') file_list.sort() assert file_list.files == ['b.txt'] - self.assertNoWarnings() + self.assertNoWarnings(caplog) file_list.process_template_line('global-exclude *.rb') file_list.sort() assert file_list.files == ['b.txt'] - self.assertWarnings() + self.assertWarnings(caplog) - def test_recursive_include(self): + def test_recursive_include(self, caplog): + caplog.set_level(logging.DEBUG) ml = make_local_path # recursive-include file_list = FileList() @@ -547,14 +542,15 @@ class TestFileListTest(TempDirTestCase): file_list.process_template_line('recursive-include d *.py') file_list.sort() assert file_list.files == [ml('d/b.py'), ml('d/d/e.py')] - self.assertNoWarnings() + self.assertNoWarnings(caplog) file_list.process_template_line('recursive-include e *.py') file_list.sort() assert file_list.files == [ml('d/b.py'), ml('d/d/e.py')] - self.assertWarnings() + self.assertWarnings(caplog) - def test_recursive_exclude(self): + def test_recursive_exclude(self, caplog): + caplog.set_level(logging.DEBUG) ml = make_local_path # recursive-exclude file_list = FileList() @@ -563,14 +559,15 @@ class TestFileListTest(TempDirTestCase): file_list.process_template_line('recursive-exclude d *.py') file_list.sort() assert file_list.files == ['a.py', ml('d/c.txt')] - self.assertNoWarnings() + self.assertNoWarnings(caplog) file_list.process_template_line('recursive-exclude e *.py') file_list.sort() assert file_list.files == ['a.py', ml('d/c.txt')] - self.assertWarnings() + self.assertWarnings(caplog) - def test_graft(self): + def test_graft(self, caplog): + caplog.set_level(logging.DEBUG) ml = make_local_path # graft file_list = FileList() @@ -579,14 +576,15 @@ class TestFileListTest(TempDirTestCase): file_list.process_template_line('graft d') file_list.sort() assert file_list.files == [ml('d/b.py'), ml('d/d/e.py')] - self.assertNoWarnings() + self.assertNoWarnings(caplog) file_list.process_template_line('graft e') file_list.sort() assert file_list.files == [ml('d/b.py'), ml('d/d/e.py')] - self.assertWarnings() + self.assertWarnings(caplog) - def test_prune(self): + def test_prune(self, caplog): + caplog.set_level(logging.DEBUG) ml = make_local_path # prune file_list = FileList() @@ -595,9 +593,9 @@ class TestFileListTest(TempDirTestCase): file_list.process_template_line('prune d') file_list.sort() assert file_list.files == ['a.py', ml('f/f.py')] - self.assertNoWarnings() + self.assertNoWarnings(caplog) file_list.process_template_line('prune e') file_list.sort() assert file_list.files == ['a.py', ml('f/f.py')] - self.assertWarnings() + self.assertWarnings(caplog) |