fortdepend


Namefortdepend JSON
Version 2.3.2 PyPI version JSON
download
home_page
SummaryAutomatically generate Fortran dependencies
upload_time2023-07-05 09:39:16
maintainer
docs_urlNone
author
requires_python>=3.8
licenseMIT
keywords build dependencies fortran
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            fortdepend
==========

[![Build Status](https://travis-ci.org/ZedThree/fort_depend.py.svg?branch=master)](https://travis-ci.org/ZedThree/fort_depend.py)
[![codecov](https://codecov.io/gh/ZedThree/fort_depend.py/branch/master/graph/badge.svg)](https://codecov.io/gh/ZedThree/fort_depend.py)

A python script to automatically generate Fortran dependencies.

Given a set of files, `fortdepend` automatically constructs the
dependency graph for the programs and files and can write a dependency
file suitable for Makefiles. `fortdepend` now uses [`pcpp`][pcpp], a
preprocessor written in Python, so it can determine which modules will
actually be used when you compile.

You can even use `fortdepend` to draw the graph of the module
dependencies (requires [`graphviz`][graphviz])!

Complete documentation is available [on ReadTheDocs][docs].

Original script by D. Dickinson

Installation
============

You can install fortdepend with pip:

    pip3 install --user fortdepend

Limitations
===========

`fortdepend` requires Python 3.

`fortdepend` works by looking for matching pairs of `program
<name>/end program <name>` and `module <name>/end module <name>`, and
so will not work on Fortran 77-style files that just use `end` without
the appropriate label.

Usage
=====

Basic usage:
------------

    fortdepend -o Makefile.dep

This will look for all files ending in `.f90` or `.F90` in the current
directory and write the output to `Makefile.dep`. The output will
something like this:

    test :  \
            moduleA.o \
            moduleB.o \
            moduleC.o \
            moduleD.o \
            programTest.o

    moduleA.o :

    moduleB.o :  \
            moduleA.o

    moduleC.o :  \
            moduleA.o \
            moduleB.o

    moduleD.o :  \
            moduleC.o

You could then get a basic makefile working by putting the following
in `Makefile`:

    .f90.o:
        gfortran -c $<

    test:
        gfortran $^ -o $@

    include Makefile.dep

And `make test` will magically build everything in the correct order!

Move advanced use
-----------------

You can specify preprocessor macros with `-D` and search paths with `-I`:

    fortdepend -DMACRO=42 -Isome/include/dir -o Makefile.dep

will replace instances of `MACRO` with `42` according to the usual C99
preprocessor rules. This can be used to conditionally `use` some
modules or change which module is `use`d at compile time.

Full command line arguments:

    $ fortdepend --help
    usage: fortdepend [-h] [-f FILES [FILES ...]] [-D NAME[=DESCRIPTION]
                      [NAME[=DESCRIPTION] ...]] [-b BUILD] [-o OUTPUT] [-g] [-v]
                      [-w] [-c] [-e EXCLUDE_FILES [EXCLUDE_FILES ...]]
                      [-i IGNORE_MODULES [IGNORE_MODULES ...]]

    Generate Fortran dependencies

    optional arguments:
      -h, --help            show this help message and exit
      -f FILES [FILES ...], --files FILES [FILES ...]
                            Files to process
      -D NAME[=DESCRIPTION] [NAME[=DESCRIPTION] ...]
                            Preprocessor define statements
      -I dir                Add dir to the preprocessor search path
      -b BUILD, --build BUILD
                            Build Directory (prepended to all files in output)
      -o OUTPUT, --output OUTPUT
                            Output file
      -g, --graph           Make a graph of the project
      -v, --verbose         explain what is done
      -w, --overwrite       Overwrite output file without warning
      -c, --colour          Print in colour
      -e EXCLUDE_FILES [EXCLUDE_FILES ...], --exclude-files EXCLUDE_FILES [EXCLUDE_FILES ...]
                            Files to exclude
      -i IGNORE_MODULES [IGNORE_MODULES ...], --ignore-modules IGNORE_MODULES [IGNORE_MODULES ...]
                            Modules to ignore
      --skip-programs       Don't include programs in the output file
      -n, --no-preprocessor
                            Don't use the preprocessor

Here's a slightly more advanced example of how to use `fortdepend` in
your makefiles:

    # Script to generate the dependencies
    MAKEDEPEND=/path/to/fortdepend

    # $(DEP_FILE) is a .dep file generated by fortdepend
    DEP_FILE = my_project.dep

    # Source files to compile
    OBJECTS = mod_file1.f90 \
              mod_file2.f90

    # Make sure everything depends on the .dep file
    all: $(actual_executable) $(DEP_FILE)

    # Make dependencies
    .PHONY: depend
    depend: $(DEP_FILE)

    # The .dep file depends on the source files, so it automatically gets updated
    # when you change your source
    $(DEP_FILE): $(OBJECTS)
        @echo "Making dependencies!"
        cd $(SRCPATH) && $(MAKEDEPEND) -w -o /path/to/$(DEP_FILE) -f $(OBJECTS)

    include $(DEP_FILE)

This will automatically rebuild the dependency file if any of the
source files change. You might not like to do this if you have a lot
of files and need to preprocess them!

[pcpp]: https://github.com/ned14/pcpp
[graphviz]: https://github.com/xflr6/graphviz
[docs]: https://fortdepend.readthedocs.io/en/latest/

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "fortdepend",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "build,dependencies,fortran",
    "author": "",
    "author_email": "Peter Hill <peter.hill@york.ac.uk>",
    "download_url": "https://files.pythonhosted.org/packages/b6/56/a87a4418a0c298e1a200e650986ea9743974128cf1a66ce97a429226775e/fortdepend-2.3.2.tar.gz",
    "platform": null,
    "description": "fortdepend\n==========\n\n[![Build Status](https://travis-ci.org/ZedThree/fort_depend.py.svg?branch=master)](https://travis-ci.org/ZedThree/fort_depend.py)\n[![codecov](https://codecov.io/gh/ZedThree/fort_depend.py/branch/master/graph/badge.svg)](https://codecov.io/gh/ZedThree/fort_depend.py)\n\nA python script to automatically generate Fortran dependencies.\n\nGiven a set of files, `fortdepend` automatically constructs the\ndependency graph for the programs and files and can write a dependency\nfile suitable for Makefiles. `fortdepend` now uses [`pcpp`][pcpp], a\npreprocessor written in Python, so it can determine which modules will\nactually be used when you compile.\n\nYou can even use `fortdepend` to draw the graph of the module\ndependencies (requires [`graphviz`][graphviz])!\n\nComplete documentation is available [on ReadTheDocs][docs].\n\nOriginal script by D. Dickinson\n\nInstallation\n============\n\nYou can install fortdepend with pip:\n\n    pip3 install --user fortdepend\n\nLimitations\n===========\n\n`fortdepend` requires Python 3.\n\n`fortdepend` works by looking for matching pairs of `program\n<name>/end program <name>` and `module <name>/end module <name>`, and\nso will not work on Fortran 77-style files that just use `end` without\nthe appropriate label.\n\nUsage\n=====\n\nBasic usage:\n------------\n\n    fortdepend -o Makefile.dep\n\nThis will look for all files ending in `.f90` or `.F90` in the current\ndirectory and write the output to `Makefile.dep`. The output will\nsomething like this:\n\n    test :  \\\n            moduleA.o \\\n            moduleB.o \\\n            moduleC.o \\\n            moduleD.o \\\n            programTest.o\n\n    moduleA.o :\n\n    moduleB.o :  \\\n            moduleA.o\n\n    moduleC.o :  \\\n            moduleA.o \\\n            moduleB.o\n\n    moduleD.o :  \\\n            moduleC.o\n\nYou could then get a basic makefile working by putting the following\nin `Makefile`:\n\n    .f90.o:\n        gfortran -c $<\n\n    test:\n        gfortran $^ -o $@\n\n    include Makefile.dep\n\nAnd `make test` will magically build everything in the correct order!\n\nMove advanced use\n-----------------\n\nYou can specify preprocessor macros with `-D` and search paths with `-I`:\n\n    fortdepend -DMACRO=42 -Isome/include/dir -o Makefile.dep\n\nwill replace instances of `MACRO` with `42` according to the usual C99\npreprocessor rules. This can be used to conditionally `use` some\nmodules or change which module is `use`d at compile time.\n\nFull command line arguments:\n\n    $ fortdepend --help\n    usage: fortdepend [-h] [-f FILES [FILES ...]] [-D NAME[=DESCRIPTION]\n                      [NAME[=DESCRIPTION] ...]] [-b BUILD] [-o OUTPUT] [-g] [-v]\n                      [-w] [-c] [-e EXCLUDE_FILES [EXCLUDE_FILES ...]]\n                      [-i IGNORE_MODULES [IGNORE_MODULES ...]]\n\n    Generate Fortran dependencies\n\n    optional arguments:\n      -h, --help            show this help message and exit\n      -f FILES [FILES ...], --files FILES [FILES ...]\n                            Files to process\n      -D NAME[=DESCRIPTION] [NAME[=DESCRIPTION] ...]\n                            Preprocessor define statements\n      -I dir                Add dir to the preprocessor search path\n      -b BUILD, --build BUILD\n                            Build Directory (prepended to all files in output)\n      -o OUTPUT, --output OUTPUT\n                            Output file\n      -g, --graph           Make a graph of the project\n      -v, --verbose         explain what is done\n      -w, --overwrite       Overwrite output file without warning\n      -c, --colour          Print in colour\n      -e EXCLUDE_FILES [EXCLUDE_FILES ...], --exclude-files EXCLUDE_FILES [EXCLUDE_FILES ...]\n                            Files to exclude\n      -i IGNORE_MODULES [IGNORE_MODULES ...], --ignore-modules IGNORE_MODULES [IGNORE_MODULES ...]\n                            Modules to ignore\n      --skip-programs       Don't include programs in the output file\n      -n, --no-preprocessor\n                            Don't use the preprocessor\n\nHere's a slightly more advanced example of how to use `fortdepend` in\nyour makefiles:\n\n    # Script to generate the dependencies\n    MAKEDEPEND=/path/to/fortdepend\n\n    # $(DEP_FILE) is a .dep file generated by fortdepend\n    DEP_FILE = my_project.dep\n\n    # Source files to compile\n    OBJECTS = mod_file1.f90 \\\n              mod_file2.f90\n\n    # Make sure everything depends on the .dep file\n    all: $(actual_executable) $(DEP_FILE)\n\n    # Make dependencies\n    .PHONY: depend\n    depend: $(DEP_FILE)\n\n    # The .dep file depends on the source files, so it automatically gets updated\n    # when you change your source\n    $(DEP_FILE): $(OBJECTS)\n        @echo \"Making dependencies!\"\n        cd $(SRCPATH) && $(MAKEDEPEND) -w -o /path/to/$(DEP_FILE) -f $(OBJECTS)\n\n    include $(DEP_FILE)\n\nThis will automatically rebuild the dependency file if any of the\nsource files change. You might not like to do this if you have a lot\nof files and need to preprocess them!\n\n[pcpp]: https://github.com/ned14/pcpp\n[graphviz]: https://github.com/xflr6/graphviz\n[docs]: https://fortdepend.readthedocs.io/en/latest/\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Automatically generate Fortran dependencies",
    "version": "2.3.2",
    "project_urls": {
        "Source": "https://github.com/ZedThree/fort_depend.py",
        "Tracker": "https://github.com/ZedThree/fort_depend.py/issues"
    },
    "split_keywords": [
        "build",
        "dependencies",
        "fortran"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9d79bd987e02b66bf75bffe481e745d63538cd347cd876ef17120e257ae413e4",
                "md5": "4bd264585cc7de40aa9d5c712ccf5c21",
                "sha256": "43d77f22e3ab8096bb5c475cd1dbe8e72921521fa6b0565b9b04b7bf5d6a32be"
            },
            "downloads": -1,
            "filename": "fortdepend-2.3.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "4bd264585cc7de40aa9d5c712ccf5c21",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 12858,
            "upload_time": "2023-07-05T09:39:15",
            "upload_time_iso_8601": "2023-07-05T09:39:15.647929Z",
            "url": "https://files.pythonhosted.org/packages/9d/79/bd987e02b66bf75bffe481e745d63538cd347cd876ef17120e257ae413e4/fortdepend-2.3.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b656a87a4418a0c298e1a200e650986ea9743974128cf1a66ce97a429226775e",
                "md5": "d62adfbfc9fe78bec66b8d298fd1be35",
                "sha256": "dfd165659315c284ecff4669e8b84471c6a1580cf42f165bdb3b837ecd6e105c"
            },
            "downloads": -1,
            "filename": "fortdepend-2.3.2.tar.gz",
            "has_sig": false,
            "md5_digest": "d62adfbfc9fe78bec66b8d298fd1be35",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 24295,
            "upload_time": "2023-07-05T09:39:16",
            "upload_time_iso_8601": "2023-07-05T09:39:16.929819Z",
            "url": "https://files.pythonhosted.org/packages/b6/56/a87a4418a0c298e1a200e650986ea9743974128cf1a66ce97a429226775e/fortdepend-2.3.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-05 09:39:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ZedThree",
    "github_project": "fort_depend.py",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "fortdepend"
}
        
Elapsed time: 1.72124s