Skip to content

Commit

Permalink
chore: remove pkg_resources and test command (scikit-build#1014)
Browse files Browse the repository at this point in the history
* fix: drop pkg_resources

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* fix: drop custom test command

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

---------

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
  • Loading branch information
henryiii authored Jul 21, 2023
1 parent bd8802f commit 9fb550b
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 94 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ filterwarnings = [
"ignore:Config variable 'WITH_PYMALLOC' is unset, Python ABI tag may be incorrect:RuntimeWarning",
'default:shell/Perl-style subs.* are deprecated:DeprecationWarning',
'default:subprocess .* is still running:ResourceWarning',
'ignore: pkg_resources is deprecated as an API:DeprecationWarning',
'ignore: pkg_resources is deprecated as an API:DeprecationWarning:setuptools',
'ignore:onerror argument is deprecated, use onexc instead:DeprecationWarning', # Caused by wheel and Python 3.12
'ignore:(ast.Str|Attribute s|ast.NameConstant|ast.Num) is deprecated:DeprecationWarning:_pytest',
]
Expand Down
16 changes: 0 additions & 16 deletions skbuild/command/test.py

This file was deleted.

5 changes: 1 addition & 4 deletions skbuild/setuptools_wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
install_lib,
install_scripts,
sdist,
test,
)
from .constants import (
CMAKE_DEFAULT_EXECUTABLE,
Expand Down Expand Up @@ -342,7 +341,6 @@ def _should_run_cmake(commands: Sequence[str], cmake_with_sdist: bool) -> bool:
"bdist_rpm",
"bdist_wininst",
"bdist_wheel",
"test",
}

if expected_commands & given_commands:
Expand Down Expand Up @@ -440,7 +438,6 @@ def setup(
cmdclass["generate_source_manifest"] = cmdclass.get(
"generate_source_manifest", generate_source_manifest.generate_source_manifest
)
cmdclass["test"] = cmdclass.get("test", test.test)
kw["cmdclass"] = cmdclass

# Extract setup keywords specific to scikit-build and remove them from kw.
Expand Down Expand Up @@ -512,7 +509,7 @@ def setup(
print(flush=True)
return setuptools.setup(**kw) # type: ignore[no-any-return, func-returns-value]

developer_mode = "develop" in commands or "test" in commands or build_ext_inplace
developer_mode = "develop" in commands or build_ext_inplace

packages = kw.get("packages", [])
package_dir = kw.get("package_dir", {})
Expand Down
5 changes: 0 additions & 5 deletions tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from unittest.mock import patch

import _pytest.tmpdir
import pkg_resources
import py.path
import requests

Expand Down Expand Up @@ -225,10 +224,6 @@ def execute_setup_py(project_dir, setup_args, disable_languages_test=False):
del os.environ["_PYTHON_HOST_PLATFORM"]

with push_dir(str(project_dir)), push_argv(["setup.py", *setup_args]), prepend_sys_path([str(project_dir)]):
# Restore master working set that is reset following call to "python setup.py test"
# See function "project_on_sys_path()" in setuptools.command.test
pkg_resources._initialize_master_working_set() # type: ignore[attr-defined]

with open("setup.py") as fp:
setup_code = compile(fp.read(), "setup.py", mode="exec")

Expand Down
14 changes: 10 additions & 4 deletions tests/pytest_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
import tarfile
from zipfile import ZipFile

import wheel
from pkg_resources import parse_version
from packaging.version import Version

from skbuild import __version__ as skbuild_version

from . import list_ancestors

if sys.version_info < (3, 8):
import importlib_metadata as metadata
else:
from importlib import metadata


def check_sdist_content(sdist_archive, expected_distribution_name, expected_content, package_dir=""):
"""This function raises an AssertionError if the given sdist_archive
Expand Down Expand Up @@ -71,15 +75,17 @@ def check_wheel_content(wheel_archive, expected_distribution_name, expected_cont
f"{expected_distribution_name}.dist-info/METADATA",
}

if parse_version(wheel.__version__) < parse_version("0.31.0"):
wheel_version = Version(metadata.version("wheel"))

if wheel_version < Version("0.31.0"):
# These files were specified in the now-withdrawn PEP 426
# See https://github.com/pypa/wheel/issues/195
expected_content |= {
f"{expected_distribution_name}.dist-info/DESCRIPTION.rst",
f"{expected_distribution_name}.dist-info/metadata.json",
}

if parse_version("0.33.1") < parse_version(wheel.__version__) < parse_version("0.33.4"):
if Version("0.33.1") < wheel_version < Version("0.33.4"):
# Include directory entries when building wheel
# See https://github.com/pypa/wheel/issues/287 and https://github.com/pypa/wheel/issues/294
for entry in expected_content:
Expand Down
5 changes: 0 additions & 5 deletions tests/test_hello_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ def another_run():
another_run()


# @project_setup_py_test("hello-cpp", ["test"])
# def test_hello_works():
# pass


@project_setup_py_test("hello-cpp", ["sdist"])
def test_hello_sdist():
sdists_tar = glob.glob("dist/*.tar.gz")
Expand Down
5 changes: 0 additions & 5 deletions tests/test_hello_cython.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ def test_hello_cython_builds():
pass


# @project_setup_py_test("hello-cython", ["test"])
# def test_hello_cython_works():
# pass


@project_setup_py_test("hello-cython", ["sdist"])
def test_hello_cython_sdist():
sdists_tar = glob.glob("dist/*.tar.gz")
Expand Down
5 changes: 0 additions & 5 deletions tests/test_hello_pure.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ def test_hello_pure_builds(capsys):
assert "skipping skbuild (no CMakeLists.txt found)" in out


# @project_setup_py_test("hello-pure", ["test"])
# def test_hello_cython_works():
# pass


@project_setup_py_test("hello-pure", ["sdist"], disable_languages_test=True)
def test_hello_pure_sdist():
sdists_tar = glob.glob("dist/*.tar.gz")
Expand Down
22 changes: 0 additions & 22 deletions tests/test_issue274_support_default_package_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,11 @@
import pytest

from . import (
_tmpdir,
execute_setup_py,
initialize_git_repo_and_commit,
prepare_project,
project_setup_py_test,
push_dir,
)


@pytest.mark.deprecated()
@project_setup_py_test("issue-274-support-default-package-dir", ["install"], disable_languages_test=True)
def test_install_command():
pass


@pytest.mark.deprecated()
def test_test_command():
with push_dir():
tmp_dir = _tmpdir("test_test_command")
project = "issue-274-support-default-package-dir"
prepare_project(project, tmp_dir)
initialize_git_repo_and_commit(tmp_dir, verbose=True)

try:
with execute_setup_py(tmp_dir, ["test"], disable_languages_test=True):
pass
except SystemExit as exc:
assert exc.code == 0 # noqa: PT017

assert tmp_dir.join("test_hello.completed.txt").exists()
22 changes: 0 additions & 22 deletions tests/test_issue274_support_one_package_without_package_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,11 @@
import pytest

from . import (
_tmpdir,
execute_setup_py,
initialize_git_repo_and_commit,
prepare_project,
project_setup_py_test,
push_dir,
)


@pytest.mark.deprecated()
@project_setup_py_test("issue-274-support-one-package-without-package-dir", ["install"], disable_languages_test=True)
def test_install_command():
pass


@pytest.mark.deprecated()
def test_test_command():
with push_dir():
tmp_dir = _tmpdir("test_test_command")
project = "issue-274-support-one-package-without-package-dir"
prepare_project(project, tmp_dir)
initialize_git_repo_and_commit(tmp_dir, verbose=True)

try:
with execute_setup_py(tmp_dir, ["test"], disable_languages_test=True):
pass
except SystemExit as exc:
assert exc.code == 0 # noqa: PT017

assert tmp_dir.join("test_hello.completed.txt").exists()
5 changes: 0 additions & 5 deletions tests/test_skbuild_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ def test_skbuild_variable_builds():
pass


# @project_setup_py_test("fail-unless-skbuild-set", ["test"], disable_languages_test=True)
# def test_skbuild_variable_works():
# pass


@project_setup_py_test("fail-unless-skbuild-set", ["sdist"], disable_languages_test=True)
def test_skbuild_variable_sdist():
pass
Expand Down

0 comments on commit 9fb550b

Please sign in to comment.