Skip to content
Open
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
12 changes: 5 additions & 7 deletions nexus/docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ to development or (currently) if any scripts/"binaries" are needed. Administrati
Note that while many supercomputer systems have an outdated system Python, a recent Python version is usually provided via a
loadable module: check the local documentation or discuss with your system administrators to find the simplest installation route.

.. important::
Currently, Nexus installed via ``pip`` or ``uv`` does not include any scripts (``qmca``, ``nxs-test``, etc.) which are readily available in QMCPACK installations.
Users may install them by following the manual installation method described in :ref:`manual_install`.

.. contents::

Installation using ``pip``
Expand Down Expand Up @@ -54,8 +50,11 @@ To subsequently use the environment:
cd $HOME/somewhere # Wherever you created the environment
source nexusenv/bin/activate

Note that any versions of Nexus found via the ``PYTHONPATH`` environment variable will take precedence over a ``pip`` installed
version.
Note that any versions of Nexus found via the ``PYTHONPATH`` environment variable will take precedence over a ``pip`` installed version.

.. important::
If you install Nexus into a virtual environment, the Nexus executables (e.g. ``qmca``, ``nxs-sim``, etc.) will only be accessible if you have activated that virtual environment.


System-wide installation (not recommended in general)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -114,7 +113,6 @@ minimum set of dependencies. You can also install the full set of optional depen

uv pip install "nexus[full]@git+https://github.com/QMCPACK/qmcpack.git@main#subdirectory=nexus"


Note that when using ``uv`` as a package manager, your Python scripts can optionally use a modified `shebang
<https://en.wikipedia.org/wiki/Shebang_(Unix)>`__ that tells it to use ``uv`` to run it. For example

Expand Down
Empty file added nexus/nexus/bin/__init__.py
Empty file.
4 changes: 2 additions & 2 deletions nexus/bin/eshdf → nexus/nexus/bin/eshdf
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ def find_nexus_modules():
import sys
# Prepend the assumed path of a folder containing the closely coupled nexus module to module search path
# It points to the top Nexus directory not necessarily the top QMCPACK directory.
nexus_lib = os.path.realpath(os.path.join(__file__,'..','..'))
nexus_lib = os.path.realpath(os.path.join(__file__,'..','..','..'))

# "import nexus" will succeed if nexus directory exists without __init__.py in it.
# Explicitly check the existence of nexus/__init__.py at the closely coupled location
nexus_init = os.path.join(nexus_lib,'nexus','__init__.py')
nexus_init = os.path.join(nexus_lib,'nexus/__init__.py')
if not os.path.exists(nexus_init):
print('\nExpected file '+nexus_init+' does not exist!'
'\nBroken Nexus installation! Please follow Nexus manual regarding installation.\n')
Expand Down
4 changes: 2 additions & 2 deletions nexus/bin/nxs-redo → nexus/nexus/bin/nxs-redo
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ def find_nexus_modules():
import sys
# Prepend the assumed path of a folder containing the closely coupled nexus module to module search path
# It points to the top Nexus directory not necessarily the top QMCPACK directory.
nexus_lib = os.path.realpath(os.path.join(__file__,'..','..'))
nexus_lib = os.path.realpath(os.path.join(__file__,'..','..','..'))

# "import nexus" will succeed if nexus directory exists without __init__.py in it.
# Explicitly check the existence of nexus/__init__.py at the closely coupled location
nexus_init = os.path.join(nexus_lib,'nexus','__init__.py')
nexus_init = os.path.join(nexus_lib,'nexus/__init__.py')
if not os.path.exists(nexus_init):
print('\nExpected file '+nexus_init+' does not exist!'
'\nBroken Nexus installation! Please follow Nexus manual regarding installation.\n')
Expand Down
4 changes: 2 additions & 2 deletions nexus/bin/nxs-sim → nexus/nexus/bin/nxs-sim
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ def find_nexus_modules():
import sys
# Prepend the assumed path of a folder containing the closely coupled nexus module to module search path
# It points to the top Nexus directory not necessarily the top QMCPACK directory.
nexus_lib = os.path.realpath(os.path.join(__file__,'..','..'))
nexus_lib = os.path.realpath(os.path.join(__file__,'..','..','..'))

# "import nexus" will succeed if nexus directory exists without __init__.py in it.
# Explicitly check the existence of nexus/__init__.py at the closely coupled location
nexus_init = os.path.join(nexus_lib,'nexus','__init__.py')
nexus_init = os.path.join(nexus_lib,'nexus/__init__.py')
if not os.path.exists(nexus_init):
print('\nExpected file '+nexus_init+' does not exist!'
'\nBroken Nexus installation! Please follow Nexus manual regarding installation.\n')
Expand Down
74 changes: 68 additions & 6 deletions nexus/bin/nxs-test → nexus/nexus/bin/nxs-test
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,75 @@ if host_dir is not None:
#end if

# save nexus directories
library_dir = parent_dir
test_dir = os.path.join(parent_dir,'nexus/tests')
reference_dir = os.path.join(parent_dir,'nexus/tests/reference')
library_dir = os.path.dirname(parent_dir)
test_dir = os.path.join(parent_dir,'tests')
reference_dir = os.path.join(parent_dir,'tests/reference')
example_dir = os.path.join(parent_dir,'examples')

# ensure that nxs-test executable is resident in a nexus directory tree
dirs_check = ['examples','bin','nexus','nexus/tests','nexus/tests/reference']
dirs_check = [
"tests/",
"bin/",
"basisset.py",
"bundle.py",
"debug.py",
"developer.py",
"execute.py",
"fileio.py",
"gamess_analyzer.py",
"gamess_input.py",
"gamess.py",
"gaussian_process.py",
"generic.py",
"grid_functions.py",
"hdfreader.py",
"__init__.py",
"machines.py",
"memory.py",
"nexus_base.py",
"nexus_version.py",
"numerics.py",
"observables.py",
"periodic_table.py",
"physical_system.py",
"project_manager.py",
"pseudopotential.py",
"pwscf_analyzer.py",
"pwscf_data_reader.py",
"pwscf_input.py",
"pwscf_postprocessors.py",
"pwscf.py",
"pyscf_analyzer.py",
"pyscf_input.py",
"pyscf_sim.py",
"qmcpack_analyzer_base.py",
"qmcpack_analyzer.py",
"qmcpack_converters.py",
"qmcpack_input.py",
"qmcpack_method_analyzers.py",
"qmcpack_property_analyzers.py",
"qmcpack.py",
"qmcpack_quantity_analyzers.py",
"qmcpack_result_analyzers.py",
"quantum_package_analyzer.py",
"quantum_package_input.py",
"quantum_package.py",
"rmg_analyzer.py",
"rmg_input.py",
"rmg.py",
"scripts.py",
"simulation.py",
"structure.py",
"template_simulation.py",
"testing.py",
"unit_converter.py",
"utilities.py",
"vasp_analyzer.py",
"vasp_input.py",
"vasp.py",
"versions.py",
"xmlreader.py",
]
for d in dirs_check:
pd = os.path.join(parent_dir,d)
if not os.path.exists(pd):
Expand Down Expand Up @@ -1788,7 +1850,7 @@ def user_examples(label):
# remove prexisting example files
nenter(tpath,relative=True)
# copy over nexus examples files just for this example
epath = os.path.join(example_dir,path)
epath = os.path.realpath(os.path.join(example_dir,path))
command = 'rsync -av {0}/* ./'.format(epath)
out,err,rc = execute(command)
if rc>0:
Expand Down Expand Up @@ -2223,7 +2285,7 @@ if __name__=='__main__':
testing_wrong_nexus_install = False
try:
import nexus
nexus_file = os.path.realpath(os.path.join(nexus.__file__,'../..'))
nexus_file = os.path.realpath(os.path.join(nexus.__file__,'../'))
test_file = os.path.realpath(os.path.join(__file__,'../..'))
testing_wrong_nexus_install = nexus_file!=test_file
except:
Expand Down
4 changes: 2 additions & 2 deletions nexus/bin/qdens → nexus/nexus/bin/qdens
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ def find_nexus_modules():
import sys
# Prepend the assumed path of a folder containing the closely coupled nexus module to module search path
# It points to the top Nexus directory not necessarily the top QMCPACK directory.
nexus_lib = os.path.realpath(os.path.join(__file__,'..','..'))
nexus_lib = os.path.realpath(os.path.join(__file__,'..','..','..'))

# "import nexus" will succeed if nexus directory exists without __init__.py in it.
# Explicitly check the existence of nexus/__init__.py at the closely coupled location
nexus_init = os.path.join(nexus_lib,'nexus','__init__.py')
nexus_init = os.path.join(nexus_lib,'nexus/__init__.py')
if not os.path.exists(nexus_init):
print('\nExpected file '+nexus_init+' does not exist!'
'\nBroken Nexus installation! Please follow Nexus manual regarding installation.\n')
Expand Down
5 changes: 2 additions & 3 deletions nexus/bin/qdens-radial → nexus/nexus/bin/qdens-radial
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ def find_nexus_modules():
import sys
# Prepend the assumed path of a folder containing the closely coupled nexus module to module search path
# It points to the top Nexus directory not necessarily the top QMCPACK directory.
nexus_lib = os.path.realpath(os.path.join(__file__,'..','..'))
nexus_lib = os.path.realpath(os.path.join(__file__,'..','..','..'))

# "import nexus" will succeed if nexus directory exists without __init__.py in it.
# Explicitly check the existence of nexus/__init__.py at the closely coupled location
nexus_init = os.path.join(nexus_lib,'nexus','__init__.py')
nexus_init = os.path.join(nexus_lib,'nexus/__init__.py')
if not os.path.exists(nexus_init):
print('\nExpected file '+nexus_init+' does not exist!'
'\nBroken Nexus installation! Please follow Nexus manual regarding installation.\n')
Expand Down Expand Up @@ -56,7 +56,6 @@ import nexus.memory as memory
from nexus.observables import ChargeDensity, vlog
from nexus.fileio import XsfFile


# External imports
try:
import numpy as np
Expand Down
4 changes: 2 additions & 2 deletions nexus/bin/qmc-fit → nexus/nexus/bin/qmc-fit
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ def find_nexus_modules():
import sys
# Prepend the assumed path of a folder containing the closely coupled nexus module to module search path
# It points to the top Nexus directory not necessarily the top QMCPACK directory.
nexus_lib = os.path.realpath(os.path.join(__file__,'..','..'))
nexus_lib = os.path.realpath(os.path.join(__file__,'..','..','..'))

# "import nexus" will succeed if nexus directory exists without __init__.py in it.
# Explicitly check the existence of nexus/__init__.py at the closely coupled location
nexus_init = os.path.join(nexus_lib,'nexus','__init__.py')
nexus_init = os.path.join(nexus_lib,'nexus/__init__.py')
if not os.path.exists(nexus_init):
print('\nExpected file '+nexus_init+' does not exist!'
'\nBroken Nexus installation! Please follow Nexus manual regarding installation.\n')
Expand Down
4 changes: 2 additions & 2 deletions nexus/bin/qmca → nexus/nexus/bin/qmca
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ def find_nexus_modules():
import sys
# Prepend the assumed path of a folder containing the closely coupled nexus module to module search path
# It points to the top Nexus directory not necessarily the top QMCPACK directory.
nexus_lib = os.path.realpath(os.path.join(__file__,'..','..'))
nexus_lib = os.path.realpath(os.path.join(__file__,'..','..','..'))

# "import nexus" will succeed if nexus directory exists without __init__.py in it.
# Explicitly check the existence of nexus/__init__.py at the closely coupled location
nexus_init = os.path.join(nexus_lib,'nexus','__init__.py')
nexus_init = os.path.join(nexus_lib,'nexus/__init__.py')
if not os.path.exists(nexus_init):
print('\nExpected file '+nexus_init+' does not exist!'
'\nBroken Nexus installation! Please follow Nexus manual regarding installation.\n')
Expand Down
44 changes: 44 additions & 0 deletions nexus/nexus/scripts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import subprocess
import sys
from os import PathLike
from pathlib import Path

bin_dir = Path(__file__).parent/"bin"

def run(script_name: PathLike):
script_path = bin_dir/script_name
result = subprocess.run([script_path] + sys.argv[1:])
sys.exit(result.returncode)
#end def run

def eshdf():
run("eshdf")
#end def eshdf

def nxs_redo():
run("nxs-redo")
#end def nxs_redo

def nxs_sim():
run("nxs-sim")
#end def nxs_sim

def nxs_test():
run("nxs-test")
#end def nxs_test

def qdens():
run("qdens")
#end def qdens

def qdens_radial():
run("qdens-radial")
#end def qdens_radial

def qmca():
run("qmca")
#end def qmca

def qmc_fit():
run("qmc-fit")
#end def qmc_fit
4 changes: 1 addition & 3 deletions nexus/nexus/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,16 +290,14 @@ def nexus_path(append=None,location=None):
assert(len(tokens)>=3)
assert(tokens[-1].startswith('testing.py'))
assert(tokens[-2]=='nexus')
assert(tokens[-3]=='nexus')

path = os.path.dirname(testing_path)
path = os.path.dirname(path)

assert(path.endswith('/nexus'))

if location is not None:
if location=='unit':
append = 'nexus/tests'
append = 'tests'
elif location=='bin':
append = 'bin'
else:
Expand Down
8 changes: 4 additions & 4 deletions nexus/nexus/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ include("${PROJECT_SOURCE_DIR}/CMake/python.cmake")
check_python_reqs(numpy "nexus base" ADD_TEST)

if(ADD_TEST)
file(TIMESTAMP ${qmcpack_SOURCE_DIR}/nexus/bin/nxs-test NEXUS_TESTLIST_TIMESTAMP)
file(TIMESTAMP ${qmcpack_SOURCE_DIR}/nexus/nexus/bin/nxs-test NEXUS_TESTLIST_TIMESTAMP)
if(NOT "${NEXUS_TESTLIST_TIMESTAMP}" STREQUAL "${CACHE_NEXUS_TESTLIST_TIMESTAMP}")
message("Generating Nexus test list for the first time or after a nxs-test time stamp change")
execute_process(COMMAND ${Python3_EXECUTABLE} ${qmcpack_SOURCE_DIR}/nexus/bin/nxs-test --ctestlist
execute_process(COMMAND ${Python3_EXECUTABLE} ${qmcpack_SOURCE_DIR}/nexus/nexus/bin/nxs-test --ctestlist
RESULT_VARIABLE NEXUS_TESTLIST_RESULT OUTPUT_VARIABLE NEXUS_TESTLIST)
if(NOT NEXUS_TESTLIST_RESULT EQUAL 0)
message(FATAL_ERROR "Command line '${Python3_EXECUTABLE} ${qmcpack_SOURCE_DIR}/nexus/bin/nxs-test --ctestlist' failed!")
message(FATAL_ERROR "Command line '${Python3_EXECUTABLE} ${qmcpack_SOURCE_DIR}/nexus/nexus/bin/nxs-test --ctestlist' failed!")
endif()

set(CACHE_NEXUS_TESTLIST
Expand All @@ -31,7 +31,7 @@ if(ADD_TEST)
endif()
foreach(TESTNAME ${NEXUS_TESTLIST})
#message("Adding test ntest_nexus_${TESTNAME}")
set(NTEST "${qmcpack_SOURCE_DIR}/nexus/bin/nxs-test")
set(NTEST "${qmcpack_SOURCE_DIR}/nexus/nexus/bin/nxs-test")
IF(ENABLE_PYCOV)
add_test(NAME ntest_nexus_${TESTNAME} COMMAND ${PYTHON_COVERAGE_EXECUTABLE} run -p ${NTEST} -R ${TESTNAME}\$ --ctest
--pythonpath=${PROJECT_SOURCE_DIR}/nexus:$ENV{PYTHONPATH})
Expand Down
2 changes: 1 addition & 1 deletion nexus/nexus/tests/test_pseudopotential.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def test_pseudopotential_classes():
f = open(files['C.BFD.xml'],'r')
pp_relpath = f.read().strip()
pp_path = os.path.split(files['C.BFD.xml'])[0]
filepath = os.path.join(pp_path,pp_relpath)
filepath = os.path.realpath(os.path.join(pp_path,pp_relpath))
f.close()

qpp = QmcpackPP(filepath)
Expand Down
2 changes: 1 addition & 1 deletion nexus/nexus/tests/test_pseudopotential_files/C.BFD.upf
Original file line number Diff line number Diff line change
@@ -1 +1 @@
../../../examples/qmcpack/pseudopotentials/C.BFD.upf
../../examples/qmcpack/pseudopotentials/C.BFD.upf
2 changes: 1 addition & 1 deletion nexus/nexus/tests/test_pseudopotential_files/C.BFD.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
../../../examples/qmcpack/pseudopotentials/C.BFD.xml
../../examples/qmcpack/pseudopotentials/C.BFD.xml
19 changes: 9 additions & 10 deletions nexus/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ dependencies = [
"numpy (>=2.3.0, !=2.4.0) ; python_version >= '3.14.0'", #
]

# TODO Restructure to support including the scripts with the package distribution
# [project.scripts]
# eshdf = "nexus.scripts:eshdf"
# nxs-redo = "nexus.scripts:nxs_redo"
# nxs-sim = "nexus.scripts:nxs_sim"
# nxs-test = "nexus.scripts:nxs_test"
# qdens = "nexus.scripts:qdens"
# qdens-radial = "nexus.scripts:qdens_radial"
# qmca = "nexus.scripts:qmca"
# qmc-fit = "nexus.scripts:qmc_fit"
[project.scripts]
eshdf = "nexus.scripts:eshdf"
nxs-redo = "nexus.scripts:nxs_redo"
nxs-sim = "nexus.scripts:nxs_sim"
nxs-test = "nexus.scripts:nxs_test"
qdens = "nexus.scripts:qdens"
qdens-radial = "nexus.scripts:qdens_radial"
qmca = "nexus.scripts:qmca"
qmc-fit = "nexus.scripts:qmc_fit"

[build-system]
requires = ["hatchling"]
Expand Down
Loading