diff --git a/README.md b/README.md
index e3c786cd..11f88bd6 100644
--- a/README.md
+++ b/README.md
@@ -2065,9 +2065,9 @@ optional.
### nixpkgs_python_configure
-nixpkgs_python_configure(name, python2_attribute_path, python2_bin_path, python3_attribute_path,
- python3_bin_path, repository, repositories, nix_file_deps, nixopts,
- fail_not_supported, quiet, exec_constraints, target_constraints, register)
+nixpkgs_python_configure(name, python3_attribute_path, python3_bin_path, repository, repositories,
+ nix_file_deps, nixopts, fail_not_supported, quiet, exec_constraints,
+ target_constraints, register)
Define and register a Python toolchain provided by nixpkgs.
@@ -2100,34 +2100,6 @@ default is "nixpkgs_python_toolchain"
The name-prefix for the created external repositories.
-
-
-
-
-python2_attribute_path |
-
-
-optional.
-default is None
-
-
-
-The nixpkgs attribute path for python2.
-
-
- |
-
-
-python2_bin_path |
-
-
-optional.
-default is "bin/python"
-
-
-
-The path to the interpreter within the package.
-
|
diff --git a/testing/python/tests/BUILD.bazel b/testing/python/tests/BUILD.bazel
index f0509210..7af723b2 100644
--- a/testing/python/tests/BUILD.bazel
+++ b/testing/python/tests/BUILD.bazel
@@ -7,7 +7,6 @@ package(default_testonly = 1)
test_suite(
name = "python-test",
tests = [
- "@nixpkgs_python_configure_test//:python2-test",
"@nixpkgs_python_configure_test//:python3-test",
],
)
diff --git a/testing/python/tests/nixpkgs_repositories.bzl b/testing/python/tests/nixpkgs_repositories.bzl
index 451b0746..2b8c7ccb 100644
--- a/testing/python/tests/nixpkgs_repositories.bzl
+++ b/testing/python/tests/nixpkgs_repositories.bzl
@@ -35,16 +35,16 @@ def nixpkgs_repositories(*, bzlmod):
register = not bzlmod,
)
- nixpkgs_package(
- name = "nixpkgs_python_configure_test",
- nix_file = "//tests:python-test.nix",
+ nixpkgs_python_configure(
+ python3_attribute_path = "python3",
repository = "@nixpkgs",
+ register = not bzlmod,
)
- nixpkgs_python_configure(
- python2_attribute_path = "python2",
+ nixpkgs_package(
+ name = "nixpkgs_python_configure_test",
+ nix_file = "//tests:python-test.nix",
repository = "@nixpkgs",
- register = not bzlmod,
)
nixpkgs_python_repository(
diff --git a/testing/python/tests/python-test.nix b/testing/python/tests/python-test.nix
index 8e953a43..7e1ab239 100644
--- a/testing/python/tests/python-test.nix
+++ b/testing/python/tests/python-test.nix
@@ -5,14 +5,6 @@ runCommand "test-nixpkgs-python-toolchain"
mkdir -p $out
cat >$out/BUILD.bazel <<'EOF_BUILD'
- py_test(
- name = "python2-test",
- main = "python-test.py",
- srcs = ["python-test.py"],
- python_version = "PY2",
- srcs_version = "PY2",
- visibility = ["//visibility:public"],
- )
py_test(
name = "python3-test",
main = "python-test.py",
@@ -34,10 +26,8 @@ runCommand "test-nixpkgs-python-toolchain"
"""
if __name__ == "__main__":
- if sys.version_info.major == 2:
- python_bin = "${python2}/bin/python"
- else:
- python_bin = "${python3}/bin/python"
+ python_bin = "${python3}/bin/python"
+
if not sys.executable == python_bin:
sys.stderr.write(_failure_message.format(
expected = python_bin,
diff --git a/toolchains/python/README.md b/toolchains/python/README.md
index 23d78f56..7f359eb1 100644
--- a/toolchains/python/README.md
+++ b/toolchains/python/README.md
@@ -17,9 +17,9 @@ Rules to import Python toolchains and packages from Nixpkgs.
### nixpkgs_python_configure
-nixpkgs_python_configure(name, python2_attribute_path, python2_bin_path, python3_attribute_path,
- python3_bin_path, repository, repositories, nix_file_deps, nixopts,
- fail_not_supported, quiet, exec_constraints, target_constraints, register)
+nixpkgs_python_configure(name, python3_attribute_path, python3_bin_path, repository, repositories,
+ nix_file_deps, nixopts, fail_not_supported, quiet, exec_constraints,
+ target_constraints, register)
Define and register a Python toolchain provided by nixpkgs.
@@ -52,34 +52,6 @@ default is "nixpkgs_python_toolchain"
The name-prefix for the created external repositories.
-
-
-
-
-python2_attribute_path |
-
-
-optional.
-default is None
-
-
-
-The nixpkgs attribute path for python2.
-
-
- |
-
-
-python2_bin_path |
-
-
-optional.
-default is "bin/python"
-
-
-
-The path to the interpreter within the package.
-
|
diff --git a/toolchains/python/python.bzl b/toolchains/python/python.bzl
index 0503cd9b..e9086cce 100644
--- a/toolchains/python/python.bzl
+++ b/toolchains/python/python.bzl
@@ -22,10 +22,6 @@ load(
def _nixpkgs_python_toolchain_impl(repository_ctx):
exec_constraints, target_constraints = ensure_constraints(repository_ctx)
- python2_runtime = ""
- if repository_ctx.attr.python2_repo:
- python2_runtime = repository_ctx.attr.python2_repo + ":runtime"
-
python3_runtime = ""
if repository_ctx.attr.python3_repo:
python3_runtime = repository_ctx.attr.python3_repo + ":runtime"
@@ -34,7 +30,6 @@ def _nixpkgs_python_toolchain_impl(repository_ctx):
load("@bazel_tools//tools/python:toolchain.bzl", "py_runtime_pair")
py_runtime_pair(
name = "py_runtime_pair",
- py2_runtime = {python2_runtime},
py3_runtime = {python3_runtime},
)
toolchain(
@@ -45,7 +40,6 @@ toolchain(
target_compatible_with = {target_constraints},
)
""".format(
- python2_runtime = label_string(python2_runtime),
python3_runtime = label_string(python3_runtime),
exec_constraints = exec_constraints,
target_constraints = target_constraints,
@@ -53,7 +47,7 @@ toolchain(
python_repo = repository_ctx.attr.python3_repo
if not python_repo:
- python_repo = repository_ctx.attr.python2_repo
+ fail("python3_repo has to be specified.")
repository_ctx.file("defs.bzl", executable = False, content = """
# Generated by rules_nixpkgs/toolchains/python/python.bzl
@@ -66,7 +60,6 @@ _nixpkgs_python_toolchain = repository_rule(
# Using attr.string instead of attr.label, so that the repository rule
# does not explicitly depend on the nixpkgs_package instances. This is
# necessary, so that builds don't fail on platforms without nixpkgs.
- "python2_repo": attr.string(),
"python3_repo": attr.string(),
"exec_constraints": attr.string_list(),
"target_constraints": attr.string_list(),
@@ -117,8 +110,6 @@ runCommand "bazel-nixpkgs-python-toolchain"
def nixpkgs_python_configure(
name = "nixpkgs_python_toolchain",
- python2_attribute_path = None,
- python2_bin_path = "bin/python",
python3_attribute_path = "python3",
python3_bin_path = "bin/python",
repository = None,
@@ -142,8 +133,6 @@ def nixpkgs_python_configure(
Args:
name: The name-prefix for the created external repositories.
- python2_attribute_path: The nixpkgs attribute path for python2.
- python2_bin_path: The path to the interpreter within the package.
python3_attribute_path: The nixpkgs attribute path for python3.
python3_bin_path: The path to the interpreter within the package.
repository: See [`nixpkgs_package`](#nixpkgs_package-repository).
@@ -155,10 +144,9 @@ def nixpkgs_python_configure(
exec_constraints: Constraints for the execution platform.
target_constraints: Constraints for the target platform.
"""
- python2_specified = python2_attribute_path and python2_bin_path
python3_specified = python3_attribute_path and python3_bin_path
- if not python2_specified and not python3_specified:
- fail("At least one of python2 or python3 has to be specified.")
+ if not python3_specified:
+ fail("python3 has to be specified.")
kwargs = dict(
repository = repository,
repositories = repositories,
@@ -167,18 +155,6 @@ def nixpkgs_python_configure(
fail_not_supported = fail_not_supported,
quiet = quiet,
)
- python2_repo = None
- if python2_attribute_path:
- python2_repo = "@%s_python2//" % name
- nixpkgs_package(
- name = name + "_python2",
- nix_file_content = _python_nix_file_content(
- attribute_path = python2_attribute_path,
- bin_path = python2_bin_path,
- version = "PY2",
- ),
- **kwargs
- )
python3_repo = None
if python3_attribute_path:
python3_repo = "@%s_python3//" % name
@@ -193,7 +169,6 @@ def nixpkgs_python_configure(
)
_nixpkgs_python_toolchain(
name = name,
- python2_repo = python2_repo,
python3_repo = python3_repo,
exec_constraints = exec_constraints,
target_constraints = target_constraints,