GithubHelp home page GithubHelp logo

fortran-lang / fpm-haskell Goto Github PK

View Code? Open in Web Editor NEW
2.0 12.0 3.0 1.13 MB

The legacy Haskell implementation of fpm. No longer under active development.

License: MIT License

Haskell 93.68% Shell 0.79% Fortran 4.92% Makefile 0.61%

fpm-haskell's Introduction

This repository archives the legacy Haskell implementation of fpm and is not under active development.

See fortran-lang/fpm for the active fpm implementation

Fortran Package Manager - Haskell

Fortran Package Manager (fpm) is a package manager and build system for Fortran. Its key goal is to improve the user experience of Fortran programmers. It does so by making it easier to build your Fortran program or library, run the executables, tests, and examples, and distribute it as a dependency to other Fortran projects. Fpm's user interface is modeled after Rust's Cargo, so if you're familiar with that tool, you will feel at home with fpm. Fpm's long term vision is to nurture and grow the ecosystem of modern Fortran applications and libraries.

Building fpm-haskell

Install Haskell

To install Haskell Stack, follow these instructions, users without superuser (admin) permissions should follow the manual installation procedure.

Download this repository

git clone https://github.com/fortran-lang/fpm-haskell
cd fpm

Build and Test fpm

Build fpm using:

stack build

To test:

stack test

To install:

stack install

On Linux, the above command installs fpm to ${HOME}/.local/bin.

Usage

Creating a new project

Creating a new fpm project is as simple as running the command fpm new project_name. This will create a new folder in your current directory with the following contents and initialized as a git repository.

  • fpm.toml with your project's name and some default standard meta-data
  • README.md with your project's name
  • .gitgnore
  • src/project_name.f90 with a simple hello world subroutine
  • app/main.f90 (if --with-executable flag used) a program that calls the subroutine
  • test/main.f90 (if --with-test flag used) an empty test program

Building your Fortran project with fpm

fpm understands the basic commands:

  • fpm build - build your library, executables and tests
  • fpm run - run executables
  • fpm test- run tests

The command fpm run can optionally accept the name of the specific executable to run, as can fpm test; like fpm run specifc_executable. Command line arguments can also be passed to the executable(s) or test(s) with the option --args "some arguments".

See additional instructions in the Packaging guide.

fpm-haskell's People

Contributors

14ngiestas avatar aslozada avatar awvwgk avatar certik avatar chetankarwa avatar epagone avatar everythingfunctional avatar interkosmos avatar lkedward avatar miladsade96 avatar milancurcic avatar rouson avatar urbanjost avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fpm-haskell's Issues

Bootstrap version fails to read implicit dependencies table

This could be an upstream issue with https://github.com/kowainik/tomland, but I don't know enough Haskell to verify this.

Steps to reproduce:

  1. Install the bootstrap version of fpm (fcb7f67 used)
  2. Create new project and add any dependency without using an inline table
> fpm new example
> cd example
> echo "[dependencies.toml-f]\ngit = \"https://github.com/awvwgk/toml-f\"" >> fpm.toml
  1. Try to build the project with the dependency
> fpm build
# gfortran (for build/gfortran_debug/example/example.o build/gfortran_debug/example/example.mod)
# ar (for build/gfortran_debug/example/libexample.a)
ar: creating build/gfortran_debug/example/libexample.a
  1. Find the dependency not recognized
> tree build
build
└── gfortran_debug
    └── example
        ├── example.mod
        ├── example.o
        └── libexample.a

Presumed source of the error:

The following two TOML documents are equivalent, except

  1. uses an inline table for dependencies.toml-f
[dependencies]
toml-f = { git = "https://github.com/awvwgk/toml-f" }
  1. dependencies is implicitly created
[dependencies.toml-f]
git = "https://github.com/awvwgk/toml-f"

Apparently, implicit tables are handled differently by the tomland parser, but this implementation detail should not leak into fpm

Additional information:

Testing this with the Python toml module:

>>> import toml
>>> table = toml.loads("[dependencies.toml-f]\ngit = \"https://github.com/awvwgk/toml-f\"")
>>> print(table)
{'dependencies': {'toml-f': {'git': 'https://github.com/awvwgk/toml-f'}}}
>>> print(toml.dumps(table))
[dependencies.toml-f]
git = "https://github.com/awvwgk/toml-f"

Special characters in paths

I found this setting up challenging tests for fortran-lang/fpm#155, but it is also not working in bootstrap fpm as well.

Consider a project like this

.
├── app dir
│   └── main prog.f90
├── app"dir
│   └── main"prog.f90
├── app'dir
│   └── main'prog.f90
├── fpm.toml
└── source dir
    └── escape_m.f90

Of course, projects with such a structure are usually discouraged, but obviously not forbidden.

The fpm.toml for such a project would look like:

name = "escape chars"

[library]
source-dir = "source dir"

[[executable]]
name = "with spaces"
source-dir = "app dir"
main = "main prog.f90"

[[executable]]
name = "single'quotes"
source-dir = "app'dir"
main = "main'prog.f90"

[[executable]]
name = "double\"quotes"
source-dir = "app\"dir"
main = "main\"prog.f90"

And it is indeed a valid TOML document. But building with bootstrap fpm will fail due to spaces in the project name:

> fpm build
# ar (for build/gfortran_debug/escape chars/libescape chars.a)
ar: creating build/gfortran_debug/escape
ar: chars/libescape: No such file or directory
fpm: Error when running Shake build system:
  at want, called at src/Build.hs:205:11 in fpm-0.1.0.0-ExRRX9W2aflLvTBBChPpxh:Build
* Depends on: build/gfortran_debug/escape chars/libescape chars.a
  at cmd, called at src/Build.hs:204:13 in fpm-0.1.0.0-ExRRX9W2aflLvTBBChPpxh:Build
* Raised the exception:
Development.Shake.cmd, system command failed
Command line: ar rs build/gfortran_debug/escape chars/libescape chars.a 'build/gfortran_debug/escape chars/escape_m.o'
Exit code: 1
Stderr:
ar: creating build/gfortran_debug/escape
ar: chars/libescape: No such file or directory

Probably escape-chars is a better project name, but we still cannot run the executables:

fpm run with\ spaces
/bin/sh: /home/awvwgk/projects/src/github.com/fortran-package-manager/test/example_packages/escape-chars/build/gfortran_debug/app: No such file or directory

A complete version of this package is here: escape-chars.zip.

Pass arguments from command line

In this test, an only argument with blank spaces and a only line break is passed from command line.

Test with fpm run
test_with_fpm
test_with_fpm2

Test without fpm run
test_without_fpm

Source code:

program main
 
  character(len=:), allocatable :: buffer
  integer                       :: length
   
  call get_command_argument(1,length=length)
  allocate(character(len=length) :: buffer)
   
  call get_command_argument(1,buffer)
  
  write(*,'("The argument is: ",a)') buffer
end program main

Have I forgotten anything?


fpm commit: 8f27d57

Add --version info

I just installed fpm using the current master branch. It would be nice to be able to check the fpm version using something like fpm --version and/or fpm -v. Doing so with my just-installed copy gives

± fpm --version
Invalid option `--version'

Usage: fpm COMMAND [--release] [--args ARGS]

fpm new description in project README

Hi,

The README.md file, in the master branch, describes that with the option new the files: fpm.toml, README.md, .gitignore, src/project_name.f90, app/main.f90 and test/main.f90 are built. However, in the pre-release v0.1.3 and the master branch, this option only generates the files: fpm.toml and README.md.

is the README.md file, in master branch, outdated?

Haskell fpm cannot build stdlib

Trying to use stdlib (https://github.com/LKedward/stdlib-fpm at commit eadc8ad5eaf182adee04f1bd31624ad19b9eaf2c) for fpm yields the following error in Haskell fpm:

fpm: Error when running Shake build system:
  at want, called at src/Build.hs:167:11 in fpm-0.1.0.0-5jx9ZzGZ9Bb3Rtenr4ru0y:Build
* Depends on: build/gfortran_30e5626f04e0df84_2a4c534d3ee9fc79/stdlib/libstdlib.a
  at undefined, called at src/BuildModel.hs:108:16 in fpm-0.1.0.0-5jx9ZzGZ9Bb3Rtenr4ru0y:BuildModel
  at error, called at libraries/base/GHC/Err.hs:78:14 in base:GHC.Err
* Raised the exception:
Prelude.undefined

This is a major blocker for using stdlib in Fortran fpm.

Parallel job control flag

I think it's great that fpm already supports parallel builds - there should be a command line flag, like -j, to control the maximum number of threads used.

This is important for two reasons:

  • you can't assume that the machine will not already be under load, particularly for multi-user environments;
  • memory limits - I have previously run out of memory on a work computer for a large parallel build

Error message on Cygwin - "pwd -W"

I have tried to build fpm on Windows/Cygwin and got an error message. The output to screen was:

$ stack build
Preparing to install GHC to an isolated location.
This will not interfere with any system-level installation.
Downloaded ghc-8.6.5.
Already downloaded.
Already downloaded.
Decompressing ghc-8.6.5.tar.xz...

7-Zip 9.20 Copyright (c) 1999-2010 Igor Pavlov 2010-11-18

Processing archive: C:\Users\markus\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5.tar.xz

Extracting ghc-8.6.5.tar

Everything is Ok

Size: 1773445120
Compressed: 280280296
Extracting ghc-8.6.5.tar...
Extracted total of 9780 files from ghc-8.6.5.tar
GHC installed to C:\Users\markus\AppData\Local\Programs\stack\x86_64-windows\ghc-8.6.5
Cloning 536a5e6ffb148d0dd4e4c4b120913a6744097676 from https://github.com/kowainik/tomland.git
Received ExitFailure 1 when running
Raw command: "C:\cygwin\bin\git.EXE" submodule update --init --recursive
Run from: C:\cygwin\tmp\with-repo1848\cloned
Standard error:

/usr/libexec/git-core/git-sh-setup: line 344: pwd: -W: invalid option
pwd: usage: pwd [-LP]
Unable to determine absolute path of git directory

Apparently, an option -W to the "pwd" command is being used that does not exist in the Cygwin version of "pwd".

How to proceed?

Multiple executables or tests in the same directory

Right now, program source files can not be placed in the same folder. The build system sees the other program source files and assumes they are modules. We should discuss whether this restriction should be clearly identified in the user documentation, or whether we want to try and support having multiple program sources in the same folder.

Add automatic program discovery in Haskell version

Once projects start to rely on the automatic program discovery of Fortran fpm the packages will not correctly build with Haskell version. For some of my projects I currently have to disable the automatic discovery and cannot add test because the Haskell and Fortran version behave differently when dealing with multiple programs in the same source directory.

Add pre-requisites to `stack build` in `README`

On my Ubuntu 20.04 machine, I have installed Haskell Stack unpacking the tarball and adding it to my PATH, as described in the README. After having cloned the fpm repository, stack build failed because I did not have the developers library of gmp (the package libgmp-dev, in my case). I have created PR fortran-lang/fpm#97 to add this information to the README (plus the fix to a trivial typo).

However, I believe that we should provide the user with info to cover far more cases (consider also that my test did not start from a "vanilla" Ubuntu 20.04 and it is likely that I had already some required packages installed without knowing it). Ideally, I think that the following should be covered in the README:

  • packages required for all the major GNU/Linux distributions
  • pre-requisites on Windows 8 and 10
  • pre-requisites on Apple OSs

Considering that I have no clue on how to action the above points, I wonder if the CI tools could help. (Disclaimer: I only vaguely know what CI is.)

PS: just for the records, I was temporary stopped also by the following error in my attempts to complete stack build

$ stack build
Linking /home/emanuele/.stack/setup-exe-cache/x86_64-linux-tinfo6/tmp-Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.5 ...
clock               > configure         
clock               > Configuring clock-0.8...
clock               > build             
colour              > configure         
clock               > Preprocessing library for clock-0.8..
clock               > Building library for clock-0.8..
clock               > [1 of 1] Compiling System.Clock
colour              > Configuring colour-2.3.5...
colour              > build             
file-embed          > configure         
colour              > Preprocessing library for colour-2.3.5..
colour              > Building library for colour-2.3.5..
colour              > [ 1 of 14] Compiling Data.Colour.CIE.Chromaticity
file-embed          > Configuring file-embed-0.0.11.1...
file-embed          > build             
file-embed          > Preprocessing library for file-embed-0.0.11.1..
file-embed          > Building library for file-embed-0.0.11.1..
colour              > [ 2 of 14] Compiling Data.Colour.CIE.Illuminant
file-embed          > [1 of 1] Compiling Data.FileEmbed
colour              > [ 3 of 14] Compiling Data.Colour.Chan
colour              > [ 4 of 14] Compiling Data.Colour.Internal
colour              > [ 5 of 14] Compiling Data.Colour.Matrix
colour              > [ 6 of 14] Compiling Data.Colour.RGB
clock               > copy/register     
clock               > Installing library in /home/emanuele/.stack/snapshots/x86_64-linux-tinfo6/49a576afeb5ab2de0c5f11799c421ee126e112c03a2f7d31c3261efc00737d53/8.6.5/lib/x86_64-linux-ghc-8.6.5/clock-0.8-H1S1zDefxirImaRbI6ITNv
clock               > Registering library for clock-0.8..
colour              > [ 7 of 14] Compiling Data.Colour.RGBSpace.HSL
file-embed          > copy/register
file-embed          > Installing library in /home/emanuele/.stack/snapshots/x86_64-linux-tinfo6/49a576afeb5ab2de0c5f11799c421ee126e112c03a2f7d31c3261efc00737d53/8.6.5/lib/x86_64-linux-ghc-8.6.5/file-embed-0.0.11.1-1DkjC7VmQhQFLvxtpUIE3o
colour              > [ 8 of 14] Compiling Data.Colour.RGBSpace.HSV
colour              > [ 9 of 14] Compiling Data.Colour.SRGB.Linear
file-embed          > Registering library for file-embed-0.0.11.1..
colour              > [10 of 14] Compiling Data.Colour.RGBSpace
colour              > [11 of 14] Compiling Data.Colour.SRGB
colour              > [12 of 14] Compiling Data.Colour
colour              > [13 of 14] Compiling Data.Colour.Names
colour              > [14 of 14] Compiling Data.Colour.CIE
colour              > copy/register
colour              > Installing library in /home/emanuele/.stack/snapshots/x86_64-linux-tinfo6/49a576afeb5ab2de0c5f11799c421ee126e112c03a2f7d31c3261efc00737d53/8.6.5/lib/x86_64-linux-ghc-8.6.5/colour-2.3.5-y0xjV3ONUd40VuBtReEvC
colour              > Registering library for colour-2.3.5..
HttpExceptionRequest Request {
  host                 = "casa.fpcomplete.com"
  port                 = 443
  secure               = True
  requestHeaders       = []
  path                 = "/v1/pull"
  queryString          = ""
  method               = "POST"
  proxy                = Nothing
  rawBody              = False
  redirectCount        = 10
  responseTimeout      = ResponseTimeoutDefault
  requestVersion       = HTTP/1.1
}
 (ConnectionFailure Network.Socket.getAddrInfo (called with preferred socket type/protocol: AddrInfo {addrFlags = [AI_ADDRCONFIG], addrFamily = AF_UNSPEC, addrSocketType = Stream, addrProtocol = 0, addrAddress = <assumed to be undefined>, addrCanonName = <assumed to be undefined>}, host name: Just "casa.fpcomplete.com", service name: Just "443"): does not exist (Try again))
Progress 4/30

but simply running stack build again solved magically the issue (I don't know what that is).

Add linking with native libraries to Haskell fpm

The link option is available in Fortran fpm and would be a valuable addition for Haskell version as well. Once the Fortran version depends on libraries like libgit2 or libcurl this would be a requirement in Haskell fpm to bootstrap the Fortran version.

This requires to introduce the build table and to propagate the link arguments correctly to the link line in the shake build system.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.