Skip to content
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
6 changes: 4 additions & 2 deletions .github/workflows/linux_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ jobs:
--with-bashcompletiondir=/usr/share/bash-completion/completions
--with-fishcompletiondir=/usr/share/fish/vendor_completions.d
--with-zshcompletiondir=/usr/share/zsh/site-functions
--with-pythondir=/usr/lib/python3.6/site-packages
steps:
- name: Install system packages
run: |
Expand All @@ -565,7 +566,7 @@ jobs:
# need git in PATH for actions/checkout to get git repo instead of github export
dnf install -y git
yum install -y epel-release
yum install -y tcsh zsh ksh tcl perl python36 gzip ruby cmake R-core make curl perl python3-sphinx git dejagnu man-db rpm-build bzip2 autoconf gcc tcl-devel emacs
yum install -y tcsh zsh ksh tcl perl python36 python36-devel gzip ruby cmake R-core make curl perl python3-sphinx git dejagnu man-db rpm-build bzip2 autoconf gcc tcl-devel emacs
yum install -y which xorg-x11-server-utils xorg-x11-server-Xvfb
yum install -y fish
- name: Fix git safe directory
Expand Down Expand Up @@ -615,14 +616,15 @@ jobs:
--with-bashcompletiondir=/usr/share/bash-completion/completions
--with-fishcompletiondir=/usr/share/fish/vendor_completions.d
--with-zshcompletiondir=/usr/share/zsh/site-functions
--with-pythondir=/usr/lib/python3.9/site-packages
steps:
- name: Install system packages
run: |
# need git in PATH for actions/checkout to get git repo instead of github export
dnf install -y git
dnf install -y dnf-plugins-core epel-release
dnf config-manager --set-enabled crb
dnf install -y tcsh zsh ksh fish tcl perl python3 gzip ruby cmake R-core make perl python3-sphinx git dejagnu man-db rpm-build bzip2 autoconf gcc tcl-devel procps-ng emacs
dnf install -y tcsh zsh ksh fish tcl perl python3 python3-devel gzip ruby cmake R-core make perl python3-sphinx git dejagnu man-db rpm-build bzip2 autoconf gcc tcl-devel procps-ng emacs
- name: Fix git safe directory
run: |
# avoid "detected dubious ownership in repository" error
Expand Down
1 change: 1 addition & 0 deletions .hunspell.en.dic
Original file line number Diff line number Diff line change
Expand Up @@ -1594,3 +1594,4 @@ fpelt
isdir
bizstyle
importlib
pythondir
29 changes: 24 additions & 5 deletions INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,9 @@ instance :instopt:`--disable-set-manpath<--enable-set-manpath>`):

.. instopt:: --enable-append-pythonpath

Append rather prepend init directory to the PYTHONPATH environment variable
when the :instopt:`--enable-set-pythonpath` option is enabled. (default=no)
Append rather prepend the ``env_modules`` Python module directory to the
PYTHONPATH environment variable when the :instopt:`--enable-set-pythonpath`
option is enabled. (default=no)

.. only:: html or latex

Expand Down Expand Up @@ -841,9 +842,9 @@ instance :instopt:`--disable-set-manpath<--enable-set-manpath>`):

.. instopt:: --enable-set-pythonpath

Prepend init directory defined by the :instopt:`--initdir` option to the
PYTHONPATH environment variable in the shell initialization scripts.
(default=yes)
Prepend directory where the ``env_modules`` Python module is installed (see
:instopt:`--with-pythondir` option) to the PYTHONPATH environment
variable in the shell initialization scripts. (default=yes)

.. only:: html or latex

Expand Down Expand Up @@ -1454,6 +1455,24 @@ instance :instopt:`--without-modulepath<--with-modulepath>`):

.. versionadded:: 4.5

.. instopt:: --with-pythondir=DIR

Installation directory of the ``env_modules`` Python module. When this
option is not set, :file:`env_modules.py` is installed in the initialization
script directory. Whatever the installation directory of this Python module,
the :file:`python.py` symbolic link created in the initialization script
directory points to its location. (default=)

If this option is set to the ``site-packages`` directory of the Python
installation available on the system, the ``env_modules`` module can be
imported without requiring the PYTHONPATH environment variable to be set.
In this case the :instopt:`--disable-set-pythonpath<--enable-set-pythonpath>`
option may be used.

.. only:: html or latex

.. versionadded:: 5.7

.. instopt:: --with-quarantine-vars=<VARNAME[=VALUE] ...>

Environment variables to put in quarantine when running the module command to
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ ifeq ($(appendpythonpath),y)
else
setappendpythonpath := prepend
endif
# env_modules python module is installed in initdir if no specific location
ifeq ($(pythondir),)
pythondir := $(initdir)
endif
ifeq ($(setmanpath),y)
setsetmanpath :=
else
Expand Down Expand Up @@ -519,6 +523,7 @@ sed -e 's|@prefix@|$(prefix)|g' \
-e 's|@usemanpath@|$(setusemanpath)|g' \
-e 's|@setpythonpath@|$(setsetpythonpath)|g' \
-e 's|@appendpythonpath@|$(setappendpythonpath)|g' \
-e 's|@pythondir@|$(pythondir)|g' \
-e 's|@notusemanpath@|$(setnotusemanpath)|g' \
-e 's|@shellcompsource@|$(shellcompsource)|g' \
-e 's|@tcllintercmd@|$(tcllintercmd)|g' \
Expand Down
3 changes: 3 additions & 0 deletions Makefile.inc.in
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ bashcompletiondir := @bashcompletiondir@
fishcompletiondir := @fishcompletiondir@
zshcompletiondir := @zshcompletiondir@

# python module location
pythondir := @pythondir@

# linter setup
nagelfaraddons := @nagelfaraddons@
tcllinter := @tcllinter@
Expand Down
7 changes: 7 additions & 0 deletions NEWS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,13 @@ Modules 5.7.0 (not yet released)
:mconfig:`modulepath_ignore` configuration option and
:option:`--no-modulepath-ignore` command line switch to control whether
pattern definitions are applied. (fix issue #562)
* Install: add the :instopt:`--with-pythondir` installation option to
define the directory where to install the ``env_modules`` Python module.
It enables for instance to install :file:`env_modules.py` with the other
Python modules available on the system. When this option is set,
:instopt:`--enable-set-pythonpath` adds this directory to
:envvar:`PYTHONPATH` instead of the Modules ``init`` directory. (fix issue
#643)


.. _5.6 release notes:
Expand Down
9 changes: 8 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ zshcompletiondir tcllinter tcllinteropts nagelfardatadir nagelfaraddons \
stickypurge uniquenameloaded abortonerror sourcecache logger loggeropts \
loggedevents conflictunload spideroutput spiderterseoutput spiderindepth \
emacsdatadir emacsaddons requirevia compressedchangelog paginate initenvvars \
setpythonpath appendpythonpath domainname domainnameopts"
setpythonpath appendpythonpath pythondir domainname domainnameopts"
libarglist=()

# flags to know if argument has been specified on command-line
Expand Down Expand Up @@ -156,6 +156,7 @@ variantshortcut=
bashcompletiondir=
fishcompletiondir=
zshcompletiondir=
pythondir=
tcllinter='nagelfar.tcl'
tcllinteropts=
nagelfaraddons=y
Expand Down Expand Up @@ -474,6 +475,9 @@ Optional Packages:
a quarantine variable instead of emptying it. []
--with-python=BIN name or full path of Python interpreter command to
use as shebang for helper scripts [$PYTHON]
--with-pythondir=DIR installation directory of \`env_modules' Python
module. \`env_modules.py' is installed in the
initialization script directory if not set []
--with-pager=BIN name or full path of default pager program to use to
paginate informational message output (can be super-
seeded at run-time by environment variable) [$pager]
Expand Down Expand Up @@ -986,6 +990,9 @@ for arg in "$@"; do
libarglist+=("$arg") ;;
--with-python=*|--without-python)
pythonbin=$(get_package_value "$arg") ;;
--with-pythondir=*|--without-pythondir)
# shellcheck disable=SC2034
pythondir=$(get_package_value "$arg" "") ;;
--with-module-path=*)
echo_warning "Option \`--with-module-path' ignored, use \`--modulepath' instead" ;;
-h|--help)
Expand Down
6 changes: 4 additions & 2 deletions doc/source/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1029,8 +1029,10 @@ The following module sub-commands appeared on Modules 5.
Starting Modules 5.5, definition of :command:`mogui` shell alias or function
is added on this sub-command.

Starting Modules 5.7, initialization directory is added to ``PYTHONPATH``
environment variable unless installation option
Starting Modules 5.7, directory where the ``env_modules`` Python module is
installed (initialization directory by default, which can be changed with
the :instopt:`--with-pythondir` installation option) is added to
``PYTHONPATH`` environment variable unless installation option
:instopt:`--disable-set-pythonpath<--enable-set-pythonpath>` is used.

:subcmd:`lint`
Expand Down
9 changes: 5 additions & 4 deletions doc/source/module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ time if :command:`mogui-cmd` command is found in :envvar:`PATH`.
changes performed in the GUI is applied onto the shell session that executed
:command:`mogui`.

The installation location of the ``env_modules`` Python module may also be
added to the :envvar:`PYTHONPATH` environment variable during initialization,
unless the :instopt:`--enable-append-pythonpath` installation option has been
disabled.
The installation location of the ``env_modules`` Python module (which is
defined with the :instopt:`--with-pythondir` installation option) may also
be added to the :envvar:`PYTHONPATH` environment variable during
initialization, unless the :instopt:`--enable-set-pythonpath` installation
option has been disabled.

.. only:: html or latex

Expand Down
24 changes: 22 additions & 2 deletions init/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ else
setzshfpathre := /@setzshfpath@/d
endif

# define python module location
ifeq ($(pythondir),)
pythondir := $(initdir)
makepythondir := n
else
makepythondir := y
endif

# comment entries if feature not enabled
ifeq ($(versioning),y)
versdir := $(baseprefix)/versions
Expand Down Expand Up @@ -265,11 +273,19 @@ ifeq ($(makebashcompdir),y)
endif
ifeq ($(makefishcompdir),y)
$(INSTALL_DIR) '$(DESTDIR)$(fishcompletiondir)'
endif
ifeq ($(makepythondir),y)
$(INSTALL_DIR) '$(DESTDIR)$(pythondir)'
endif
$(INSTALL_DIR) '$(DESTDIR)$(zshcompletiondir)'
$(INSTALL_DIR) '$(DESTDIR)$(modulefilesdir)'
$(INSTALL_DATA) $(ALL_SHELLS) '$(DESTDIR)$(initdir)/'
$(INSTALL_DATA) $(filter-out env_modules.py,$(ALL_SHELLS)) '$(DESTDIR)$(initdir)/'
$(INSTALL_DATA) env_modules.py '$(DESTDIR)$(pythondir)/'
ifeq ($(makepythondir),y)
ln -f -s '$(pythondir)/env_modules.py' '$(DESTDIR)$(initdir)/python.py'
else
ln -f -s env_modules.py '$(DESTDIR)$(initdir)/python.py'
endif
ifeq ($(windowssupport),y)
$(INSTALL_DATA) cmd.cmd '$(DESTDIR)$(initdir)/'
endif
Expand Down Expand Up @@ -300,7 +316,8 @@ ifeq ($(versioning),y)
endif

uninstall:
rm -f $(foreach initscript,$(ALL_SHELLS) python.py,'$(DESTDIR)$(initdir)/$(initscript)')
rm -f $(foreach initscript,$(filter-out env_modules.py,$(ALL_SHELLS)) python.py,'$(DESTDIR)$(initdir)/$(initscript)')
rm -f '$(DESTDIR)$(pythondir)/env_modules.py'
ifeq ($(windowssupport),y)
rm -f '$(DESTDIR)$(initdir)/cmd.cmd'
endif
Expand All @@ -327,6 +344,9 @@ ifeq ($(makebashcompdir),y)
endif
ifeq ($(makefishcompdir),y)
$(RMDIR_IGN_NON_EMPTY) '$(DESTDIR)$(fishcompletiondir)' || true
endif
ifeq ($(makepythondir),y)
$(RMDIR_IGN_NON_EMPTY) '$(DESTDIR)$(pythondir)' || true
endif
$(RMDIR_IGN_NON_EMPTY) '$(DESTDIR)$(zshcompletiondir)' || true
$(RMDIR_IGN_NON_EMPTY) '$(DESTDIR)$(initdir)' || true
Expand Down
13 changes: 13 additions & 0 deletions share/rpm/environment-modules.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ BuildRequires: dejagnu
BuildRequires: make
BuildRequires: sed
BuildRequires: less
# python3_sitelib macro and byte-compilation of env_modules.py installed
# in this directory
%if 0%{?fedora} >= 22 || 0%{?rhel} >= 8
BuildRequires: python3-devel
%endif
%if 0%{?rhel} && 0%{?rhel} <= 8
BuildRequires: util-linux
%else
Expand Down Expand Up @@ -120,6 +125,10 @@ have access to the module alias.
--disable-doc-install \
--enable-modulespath \
--with-python=%{pythonbin} \
%if 0%{?fedora} >= 22 || 0%{?rhel} >= 8
--with-pythondir=%{python3_sitelib} \
--disable-set-pythonpath \
%endif
--with-modulepath=%{_datadir}/Modules/modulefiles:%{_sysconfdir}/modulefiles:%{_datadir}/modulefiles \
--with-quarantine-vars='LD_LIBRARY_PATH LD_PRELOAD' \
--with-init-envvars='MANPATH='
Expand Down Expand Up @@ -237,6 +246,10 @@ fi
%{_datadir}/Modules/libexec/modulecmd.tcl
%dir %{_datadir}/Modules/init
%{_datadir}/Modules/init/*
%if 0%{?fedora} >= 22 || 0%{?rhel} >= 8
%{python3_sitelib}/env_modules.py
%{python3_sitelib}/__pycache__/env_modules.cpython-*.pyc
%endif
# do not need to require shell package as we "own" completion dir
%dir %{bash_completions_dir}
%{bash_completions_dir}/module
Expand Down
2 changes: 2 additions & 0 deletions site.exp.in
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ set install_bashcompletiondir "@bashcompletiondir@"
set install_fishcompletiondir "@fishcompletiondir@"
set install_zshcompletiondir "@zshcompletiondir@"

set install_pythondir "@pythondir@"

set install_tcllinter "@tcllinter@"
set install_tcllinteropts "@tcllinteropts@"
set install_tcllintercmd $install_tcllinter
Expand Down
6 changes: 3 additions & 3 deletions tcl/subcmd.tcl.in
Original file line number Diff line number Diff line change
Expand Up @@ -2171,9 +2171,9 @@ proc cmdModuleAutoinit {} {
@setmanpath@}
}

# add Modules init directory to PYTHONPATH if enabled
@setpythonpath@if {{@initdir@} ni [split [get-env PYTHONPATH] :]} {
@setpythonpath@ @appendpythonpath@-path PYTHONPATH {@initdir@}
# add env_modules python module directory to PYTHONPATH if enabled
@setpythonpath@if {{@pythondir@} ni [split [get-env PYTHONPATH] :]} {
@setpythonpath@ @appendpythonpath@-path PYTHONPATH {@pythondir@}
@setpythonpath@}

# source shell completion script if available, not installed in default
Expand Down
12 changes: 12 additions & 0 deletions testsuite/install.00-init/030-options.exp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,18 @@ if {[string length $nafelgar_script]} {
}


# test env_modules Python module installation location
if {$verbose} {
send_user "\tChecking env_modules Python module installation\n"
}
if {$install_pythondir ne {}} {
set pythondir $install_pythondir
} else {
set pythondir $install_initdir
}
testall_cmd_re "sh" "test -f '$pythondir/env_modules.py'" "" "" 0
testall_cmd_re "sh" "test -f '$install_initdir/python.py'" "" "" 0

# test Python module is found if PYTHONPATH is defined
if {$install_setpythonpath eq {y} && [info exists shell_path(python)]} {
# create a temporary script that checks import of module command
Expand Down
5 changes: 5 additions & 0 deletions testsuite/modules.00-init/005-init_ts.exp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ if {$install_setzshfpath eq {y}} {
set install_zshcompletiondir $install_initdir/zsh-functions
}

# env_modules python module is installed in initdir if no specific location
if {$install_pythondir eq {}} {
set install_pythondir $install_initdir
}

# locate siteconfig file
set siteconfig_file "$install_etcdir/siteconfig.tcl"
set siteconfig_filere [regsub -all "\(\[.+?\]\)" $siteconfig_file {\\\1}]
Expand Down
Loading
Loading