Skip to content

Commit

Permalink
Fix installation of Python components (dftbplus#1267)
Browse files Browse the repository at this point in the history
  • Loading branch information
vanderhe authored Dec 1, 2023
1 parent ed63385 commit c6e576c
Show file tree
Hide file tree
Showing 23 changed files with 123 additions and 253 deletions.
3 changes: 2 additions & 1 deletion tools/dptools/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
set(prefix ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_PREFIX})
set(cmake-command "
execute_process(
COMMAND ${PYTHON_INTERPRETER} setup.py install --prefix=$DESTDIR/${CMAKE_INSTALL_PREFIX}
COMMAND ${PYTHON_INTERPRETER} -m pip install --no-deps --prefix ${prefix} .
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
")

Expand Down
18 changes: 8 additions & 10 deletions tools/dptools/README → tools/dptools/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ gen2xyz
xyz2gen
Converts an xyz file to gen file.

straingen
straingen
Applies uniaxial, isotropic or shear strains to geometries,
with principle axes aligned with the cartesian directions.

repeatgen
repeatgen
Can be used to build supercell structures for phonon bandstructures

Each script can be invoked with the option ``-h`` to obtain a short
Expand All @@ -40,9 +40,9 @@ summary about its usage and possible options.
Testing dp_tools
================

In the top directory of DFTB+, running
In the top directory of DFTB+, running::

make test_dptools
make test_dptools

will validate the source of dp_tools for your python interpreter and
environment.
Expand All @@ -51,10 +51,10 @@ For developers
--------------

To perform pylint static checking, in the top DFTB+ directory the
individual scripts can be tested, for example by
individual scripts can be tested, for example by ::

env PYTHONPATH=$PWD/tools/dptools/src pylint3 --rcfile \
utils/srccheck/pylint/pylintrc-3.ini tools/dptools/bin/*
env PYTHONPATH=$PWD/tools/dptools/src pylint3 --rcfile \
utils/srccheck/pylint/pylintrc-3.ini tools/dptools/src/dptools/*


Installation
Expand All @@ -64,8 +64,6 @@ Please note, that the package needs at least **Python 2.6** or later,
with Python 3.X preferred. It additionally needs Numerical Python (the
numpy module).

You can install the script package via the standard 'python setup'
mechanism::
You can install the script package via the standard 'pip' mechanism::

pip install .

20 changes: 0 additions & 20 deletions tools/dptools/bin/dp_bands

This file was deleted.

20 changes: 0 additions & 20 deletions tools/dptools/bin/dp_dos

This file was deleted.

20 changes: 0 additions & 20 deletions tools/dptools/bin/gen2cif

This file was deleted.

20 changes: 0 additions & 20 deletions tools/dptools/bin/gen2xyz

This file was deleted.

20 changes: 0 additions & 20 deletions tools/dptools/bin/repeatgen

This file was deleted.

20 changes: 0 additions & 20 deletions tools/dptools/bin/straingen

This file was deleted.

20 changes: 0 additions & 20 deletions tools/dptools/bin/xyz2gen

This file was deleted.

3 changes: 3 additions & 0 deletions tools/dptools/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ['setuptools', 'wheel']
build-backend = 'setuptools.build_meta'
37 changes: 37 additions & 0 deletions tools/dptools/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
[metadata]
name = dptools
version = 23.1
author = DFTB+ developers
url = http://www.dftbplus.org
description = Tools to process DFTB+ related data
long_description = file: README.rst
long_description_content_type = text/x-rst
license = LGPL License
platform = platform independent
classifiers =
Intended Audience :: Science/Research
License :: OSI Approved :: LGPL License
Programming Language :: Python
Environment :: Console
Operating System :: OS Independent
Topic :: Scientific/Engineering

[options]
include_package_data = True
packages = find:
install_requires =
numpy

[options.entry_points]
console_scripts =
dp_bands = dptools.scripts.dp_bands:main
dp_dos = dptools.scripts.dp_dos:main
gen2cif = dptools.scripts.gen2cif:main
gen2xyz = dptools.scripts.gen2xyz:main
makecube = dptools.scripts.makecube:main
repeatgen = dptools.scripts.repeatgen:main
straingen = dptools.scripts.straingen:main
xyz2gen = dptools.scripts.xyz2gen:main

[options.packages.find]
where = src
38 changes: 0 additions & 38 deletions tools/dptools/setup.py

This file was deleted.

Empty file modified tools/dptools/src/dptools/scripts/dp_bands.py
100755 → 100644
Empty file.
Empty file modified tools/dptools/src/dptools/scripts/dp_dos.py
100755 → 100644
Empty file.
Empty file modified tools/dptools/src/dptools/scripts/gen2cif.py
100755 → 100644
Empty file.
Empty file modified tools/dptools/src/dptools/scripts/gen2xyz.py
100755 → 100644
Empty file.
32 changes: 29 additions & 3 deletions tools/dptools/bin/makecube → ...s/dptools/src/dptools/scripts/makecube.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,24 @@
"""


def main():
'''Main driver routine for makecube.'''
def main(cmdlineargs=None):
'''Main driver for makecube.
Args:
cmdlineargs: List of command line arguments. When None, arguments in
sys.argv are parsed (Default: None).
'''
args = parse_arguments(cmdlineargs)
makecube(args)


def parse_arguments(cmdlineargs=None):
'''Parses command line arguments.
Args:
cmdlineargs: List of command line arguments. When None, arguments in
sys.argv are parsed (Default: None).
'''
parser = argparse.ArgumentParser(description=USAGE)

helpstring = 'file containing X vector coordinates (default Xvector.dat)'
Expand All @@ -45,8 +60,18 @@ def main():
helpstring = 'output cube/vtk file name'
parser.add_argument('dest', help=helpstring)

args = parser.parse_args()
args = parser.parse_args(cmdlineargs)

return args


def makecube(args):
'''Converts the potential or charge data file from DFTB+ transport
calculations to a Gaussian Cube format.
Args:
args: Containing the obtained parsed arguments.
'''
# Build the grid
with open(args.xvec, 'r') as xvecfile:
xvec = np.array(xvecfile.read().split(), dtype=float)
Expand Down Expand Up @@ -90,5 +115,6 @@ def main():
raise ValueError('Cannot determine output format in '
'makecube:unknown file extension')


if __name__ == "__main__":
main()
Empty file modified tools/dptools/src/dptools/scripts/xyz2gen.py
100755 → 100644
Empty file.
3 changes: 2 additions & 1 deletion tools/pythonapi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
set(prefix ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_PREFIX})
set(cmake-command "
execute_process(
COMMAND ${PYTHON_INTERPRETER} setup.py install --prefix=$DESTDIR/${CMAKE_INSTALL_PREFIX}
COMMAND ${PYTHON_INTERPRETER} -m pip install --no-deps --prefix ${prefix} .
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
")

Expand Down
Loading

0 comments on commit c6e576c

Please sign in to comment.