Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix breakage due to setuptools 72.0.0 #302

Merged
merged 3 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#### Date TBD

* Use forkserver start method for multiprocessing by @eltoder in https://github.com/CleanCut/green/pull/296
* Adjust to breaking changes in `setuptools` 72.0.0

# Version 4.0.2
#### 18 Apr 2024
Expand Down
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ super-clean: super-clean-message clean-silent
@rm -rf venv*


test: test-versions test-installed test-coverage
test: test-mypy test-black test-versions test-installed test-coverage
@# test-coverage needs to be last in deps, don't clean after it runs!
@echo "\n(test) completed\n"

test-mypy:
mypy green example

test-black:
black --check --diff green example

test-local:
@pip3 install --upgrade -e '.[dev]'
@make test-installed
Expand Down
15 changes: 13 additions & 2 deletions green/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,22 @@ def run(self) -> None:

if self.distribution.install_requires:
self.distribution.fetch_build_eggs(self.distribution.install_requires)
if self.distribution.tests_require:

# TODO: Remove this once setuptools >= 72.0.0 is ubiquitous, since it no longer supports the
# "test" subcommand
if (
hasattr(self.distribution, "tests_require")
and self.distribution.tests_require
):
self.distribution.fetch_build_eggs(self.distribution.tests_require)

# TODO: Remove this once setuptools >= 72.0.0 is ubiquitous, since it no longer supports the
# "test" subcommand
script_args = self.distribution.script_args[1:]
if self.distribution.test_suite is not None:
if (
hasattr(self.distribution, "test_suite")
and self.distribution.test_suite is not None
):
script_args.append(self.distribution.test_suite)

error_code = main(script_args)
Expand Down
4 changes: 2 additions & 2 deletions green/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ def ddebug(msg: str, err: ExcInfoType | None = None) -> None: # pragma: no cove
error_string = "".join(traceback.format_exception(*err))
else:
error_string = ""
sys.__stdout__.write(f"({os.getpid()}) {msg} {error_string}\n")
sys.__stdout__.flush()
sys.__stdout__.write(f"({os.getpid()}) {msg} {error_string}\n") # type: ignore
sys.__stdout__.flush() # type: ignore


class ProcessLogger:
Expand Down
35 changes: 0 additions & 35 deletions green/test/test_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,6 @@ def test_initialize_options(self):
for attr in ["completion_file", "clear_omit", "debug", "processes"]:
self.assertTrue(hasattr(cmd, attr), attr)

@patch("green.command.main", return_value=0)
def test_run(self, main):
d = Distribution(
{
"script_name": "setup.py",
"script_args": ["green"],
"test_suite": "green.test.test_version",
}
)

cmd = command.green(d)
cmd.run()
main.assert_called_once_with(["green.test.test_version"])

@patch("green.command.main", return_value=125)
def test_run_exits(self, main):
d = Distribution({"script_name": "setup.py", "script_args": ["green"]})
Expand All @@ -115,24 +101,3 @@ def test_run_exits(self, main):
with self.assertRaises(SystemExit) as se:
cmd.run()
self.assertEqual(se.exception.code, 125)

@patch("green.command.main", return_value=0)
def test_requires(self, main):
d = Distribution(
{
"script_name": "setup.py",
"script_args": ["green"],
"install_requires": ["six"],
"tests_require": ["mock", "unittest2"],
}
)
d.fetch_build_eggs = MagicMock()
cmd = command.green(d)
cmd.run()

d.fetch_build_eggs.assert_has_calls(
[
call(["six"]),
call(["mock", "unittest2"]),
]
)
9 changes: 2 additions & 7 deletions test_versions
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,8 @@ for PYTHON_VERSION in ${PYTHON_VERSIONS} ; do
exit 7
fi
hash -r
REQUIREMENTS_FILE="requirements-optional.txt"
if [ "${PYTHON}" == "pypy3" ] ; then
# `black` depends on `typed_ast` which isn't supported by pypy3. We can remove this once
# `black` starts depending on built-in `ast`
REQUIREMENTS_FILE="requirements.txt"
fi
${VENV_DIR}/bin/pip install -r requirements-optional.txt | grep -Ev "Requirement already|however version|consider upgrading"
${VENV_DIR}/bin/pip install -r requirements.txt | grep -Ev "Requirement already|however version|consider upgrading"
${VENV_DIR}/bin/pip install -r requirements-dev.txt | grep -Ev "Requirement already|however version|consider upgrading"
deactivate
done

Expand Down
Loading