Skip to content

Commit 6da9bf2

Browse files
authored
python: drop nis module also for < 3.13 (spack#47862)
the nis module was removed in python 3.13 we had it default to ~nis no package requires +nis required dependencies for +nis were missing so better to remove the nis module entirely.
1 parent b3ee954 commit 6da9bf2

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

var/spack/repos/builtin/packages/python/package.py

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from spack.util.prefix import Prefix
2323

2424

25-
def make_pyvenv_cfg(python_spec: "spack.spec.Spec", venv_prefix: str) -> str:
25+
def make_pyvenv_cfg(python_spec: Spec, venv_prefix: str) -> str:
2626
"""Make a pyvenv_cfg file for a given (real) python command and venv prefix."""
2727
python_cmd = python_spec.command.path
2828
lines = [
@@ -254,7 +254,6 @@ class Python(Package):
254254
variant("ssl", default=True, description="Build ssl module")
255255
variant("sqlite3", default=True, description="Build sqlite3 module")
256256
variant("dbm", default=True, description="Build dbm module")
257-
variant("nis", default=False, description="Build nis module")
258257
variant("zlib", default=True, description="Build zlib module")
259258
variant("bz2", default=True, description="Build bz2 module")
260259
variant("lzma", default=True, description="Build lzma module")
@@ -285,7 +284,6 @@ class Python(Package):
285284
# https://docs.python.org/3.10/whatsnew/3.10.html#build-changes
286285
depends_on("[email protected]:", when="@3.10:+sqlite3")
287286
depends_on("gdbm", when="+dbm") # alternatively ndbm or berkeley-db
288-
depends_on("libnsl", when="+nis")
289287
depends_on("zlib-api", when="+zlib")
290288
depends_on("bzip2", when="+bz2")
291289
depends_on("xz libs=shared", when="+lzma")
@@ -387,7 +385,6 @@ def determine_variants(cls, exes, version_str):
387385
"readline",
388386
"sqlite3",
389387
"dbm",
390-
"nis",
391388
"zlib",
392389
"bz2",
393390
"lzma",
@@ -448,6 +445,29 @@ def patch(self):
448445
r"^(.*)setup\.py(.*)((build)|(install))(.*)$", r"\1setup.py\2 --no-user-cfg \3\6"
449446
)
450447

448+
# disable building the nis module (there is no flag to disable it).
449+
if self.spec.satisfies("@3.8:3.10"):
450+
filter_file(
451+
"if MS_WINDOWS or CYGWIN or HOST_PLATFORM == 'qnx6':",
452+
"if True:",
453+
"setup.py",
454+
string=True,
455+
)
456+
elif self.spec.satisfies("@3.7"):
457+
filter_file(
458+
"if host_platform in {'win32', 'cygwin', 'qnx6'}:",
459+
"if True:",
460+
"setup.py",
461+
string=True,
462+
)
463+
elif self.spec.satisfies("@3.6"):
464+
filter_file(
465+
"if (host_platform not in ['cygwin', 'qnx6'] and",
466+
"if False and",
467+
"setup.py",
468+
string=True,
469+
)
470+
451471
def setup_build_environment(self, env):
452472
spec = self.spec
453473

@@ -658,6 +678,11 @@ def configure_args(self):
658678
]
659679
)
660680

681+
# Disable the nis module in the configure script for Python 3.11 and 3.12. It is deleted
682+
# in Python 3.13. See ``def patch`` for disabling the nis module in Python 3.10 and older.
683+
if spec.satisfies("@3.11:3.12"):
684+
config_args.append("py_cv_module_nis=n/a")
685+
661686
# https://docs.python.org/3.8/library/sqlite3.html#f1
662687
if spec.satisfies("+sqlite3 ^sqlite+dynamic_extensions"):
663688
config_args.append("--enable-loadable-sqlite-extensions")
@@ -787,10 +812,6 @@ def import_tests(self):
787812
if "+dbm" in spec:
788813
self.command("-c", "import dbm")
789814

790-
# Ensure that nis module works
791-
if "+nis" in spec:
792-
self.command("-c", "import nis")
793-
794815
# Ensure that zlib module works
795816
if "+zlib" in spec:
796817
self.command("-c", "import zlib")

0 commit comments

Comments
 (0)