Skip to content

Commit

Permalink
Update for newer manifest entries
Browse files Browse the repository at this point in the history
  • Loading branch information
awvwgk committed Sep 7, 2022
1 parent 3b0a239 commit 32b2d04
Show file tree
Hide file tree
Showing 5 changed files with 239 additions and 28 deletions.
5 changes: 5 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: devel
channels:
- conda-forge
dependencies:
- pydantic
10 changes: 7 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,23 @@ classifiers =
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10

[options]
package_dir =
=src
packages = find:
install_requires =
pydantic
tests_require =
pytest
pytest-cov
tomli
python_requires = >=3.6

[options.packages.find]
where = src

[coverage:run]
omit =
*/test_*.py

[aliases]
test=pytest
61 changes: 36 additions & 25 deletions pyfpm/model.py → src/pyfpm/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
Definition of the manifest format as used by the Fortran package manager (fpm).
"""

from typing import Dict, List, Optional, Union
from __future__ import annotations

from typing import Any
from pydantic import BaseModel, Field


Expand All @@ -41,14 +43,20 @@ class Build(BaseModel):
auto_examples: bool = Field(True, alias="auto-examples")
"""Automatic discovery of examples"""

link: Union[str, List[str]] = []
link: str | list[str] = []
"""Libraries to link against"""

external_modules: Union[str, List[str]] = Field([], alias="external-modules")
external_modules: str | list[str] = Field([], alias="external-modules")
"""Modules used from non-fpm packages"""


class Dependency(BaseModel):
"""
.. Dependency
A dependency on another fpm project.
"""

...


Expand Down Expand Up @@ -103,13 +111,13 @@ class GitDependencyRev(GitDependency):
"""Commit hash"""


DependencyUnion = Union[
LocalDependency,
GitDependencyTag,
GitDependencyBranch,
GitDependencyRev,
GitDependency,
]
DependencyUnion = (
LocalDependency
| GitDependencyTag
| GitDependencyBranch
| GitDependencyRev
| GitDependency
)


class Library(BaseModel):
Expand All @@ -122,7 +130,7 @@ class Library(BaseModel):
source_dir: str = Field("src", alias="source-dir")
"""Source path prefix"""

include_dir: Union[str, List[str]] = Field("include", alias="include-dir")
include_dir: str | list[str] = Field("include", alias="include-dir")
"""Include path prefix"""


Expand All @@ -142,10 +150,10 @@ class Executable(BaseModel):
main: str = "main.f90"
"""Name of the source file declaring the main program"""

link: Union[str, List[str]] = []
link: str | list[str] = []
"""Libraries to link against"""

dependencies: Dict[str, DependencyUnion] = {}
dependencies: dict[str, DependencyUnion] = {}
"""Dependency meta data for this executable"""


Expand Down Expand Up @@ -196,25 +204,25 @@ class Manifest(BaseModel):
version: str = "0"
"""Project version"""

license: Optional[str]
license: str | None
"""Project license information"""

maintainer: Union[str, List[str]] = []
maintainer: str | list[str] = []
"""Maintainer of the project"""

author: Union[str, List[str]] = []
author: str | list[str] = []
"""Author of the project"""

copyright: Optional[str]
copyright: str | None
"""Copyright of the project"""

description: Optional[str]
description: str | None
"""Description of the project"""

categories: List[str] = []
categories: str | list[str] = []
"""Categories associated with the project"""

keywords: List[str] = []
keywords: list[str] = []
"""Keywords describing the project"""

build = Build()
Expand All @@ -226,17 +234,20 @@ class Manifest(BaseModel):
library = Library()
"""Library meta data"""

executable: List[Executable] = []
executable: list[Executable] = []
"""Executable meta data"""

example: List[Example] = []
example: list[Example] = []
"""Example meta data"""

test: List[Test] = []
test: list[Test] = []
"""Test meta data"""

dependencies: Dict[str, DependencyUnion] = {}
dependencies: dict[str, DependencyUnion] = {}
"""Dependency meta data"""

dev_dependencies: Dict[str, DependencyUnion] = Field({}, alias="dev-dependencies")
dev_dependencies: dict[str, DependencyUnion] = Field({}, alias="dev-dependencies")
"""Development dependency meta data"""

extra: dict[str, Any] = {}
"""Additional free data field"""
155 changes: 155 additions & 0 deletions tests/fpm-projects.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
2021-08-17 14:50:46 -0300 https://github.com/14NGiestas/fregex
2021-04-26 10:14:55 -0300 https://github.com/14NGiestas/mfi
2021-04-23 13:46:56 -0300 https://github.com/14NGiestas/shunting-yard-fortran
2021-08-14 22:48:41 +1000 https://github.com/AshyIsMe/flox
2021-08-30 19:10:15 +1000 https://github.com/AshyIsMe/fortran-playground
2020-10-14 09:57:44 +0100 https://github.com/LKedward/fhash
2021-04-22 15:49:34 +0100 https://github.com/LKedward/netcdf-interfaces
2020-12-17 14:37:15 +0000 https://github.com/LKedward/stdlib-fpm
2021-03-19 09:23:26 +0100 https://github.com/Lima-Lima/fsqlite
2020-07-10 23:19:24 +0200 https://github.com/SHTOOLS/SHTOOLS
2021-06-05 01:08:25 +0800 https://github.com/St-Maxwell/Hf_Timer
2021-03-26 21:37:23 +0800 https://github.com/St-Maxwell/QCkits
2021-02-22 13:50:02 +0200 https://github.com/allixender/rhpix_fortran_test
2021-01-16 23:17:46 +0200 https://github.com/art-rasa/fnote
2021-01-03 00:43:38 +0200 https://github.com/art-rasa/math
2021-01-03 19:15:10 +0200 https://github.com/art-rasa/rational_number
2021-07-02 07:19:53 +0200 https://github.com/awvwgk/blas-interface
2020-12-14 14:20:15 +0100 https://github.com/awvwgk/check-version
2021-07-05 23:00:17 +0200 https://github.com/awvwgk/cuckoohash
2020-11-14 16:02:36 +0100 https://github.com/awvwgk/simple-dftd3
2021-02-05 21:44:43 +0100 https://github.com/awvwgk/stdlib_string
2021-04-11 00:21:22 +0200 https://github.com/awvwgk/tblite
2021-04-10 21:13:27 +0200 https://github.com/awvwgk/test-internal-io
2021-07-04 22:09:09 +0200 https://github.com/awvwgk/waterhash
2021-04-02 02:02:28 -0300 https://github.com/certik/minpack
2020-06-17 21:20:01 +0900 https://github.com/cure-honey/uzura1_fpm
2021-02-24 20:31:24 +0100 https://github.com/dftd4/dftd4
2021-06-30 17:26:41 +0930 https://github.com/exepulveda/gslib2.0
2021-07-16 10:58:13 +0800 https://github.com/fortran-fans/fftpack4.0-public-domain
2021-07-16 10:53:33 +0800 https://github.com/fortran-fans/fftpack5.1-GPL
2021-07-16 10:44:14 +0800 https://github.com/fortran-fans/fftpack5.1-NACR
2021-05-11 22:33:05 +0800 https://github.com/fortran-fans/forlab
2021-06-18 10:25:28 +0800 https://github.com/fortran-fans/fortsa
2020-12-23 08:35:45 -0500 https://github.com/fortran-gaming/blocktran
2021-07-14 22:20:05 -0400 https://github.com/fortran-gaming/mastermind
2021-07-27 20:35:47 +0800 https://github.com/fortran-lang/fftpack
2021-02-25 20:11:06 -0800 https://github.com/fortran-lang/fortran-forum-article-template
2021-03-31 16:13:58 +0200 https://github.com/fortran-lang/fpm
2021-03-14 23:26:18 +0100 https://github.com/fortran-lang/test-drive
2020-08-02 14:57:21 -0400 https://github.com/geospace-code/h5fortran
2020-12-23 08:37:26 -0500 https://github.com/geospace-code/maptran3d
2020-11-09 20:31:17 +0100 https://github.com/grimme-lab/gcp
2020-10-04 15:17:15 +0200 https://github.com/grimme-lab/mctc-lib
2020-11-10 11:11:41 +0100 https://github.com/grimme-lab/mstore
2021-02-20 01:42:13 +0100 https://github.com/grimme-lab/multicharge
2021-08-11 12:56:24 +0200 https://github.com/grimme-lab/nlopt-f
2021-05-18 08:14:05 +0200 https://github.com/grimme-lab/numsa
2020-10-07 13:44:38 +0200 https://github.com/grimme-lab/rmsd-tool
2021-06-23 03:18:17 -0800 https://github.com/han190/PE-Fortran
2020-12-20 19:28:41 +0100 https://github.com/interkosmos/fortran-curl
2021-02-19 14:00:37 +0100 https://github.com/interkosmos/fortran-sdl2
2021-07-22 23:30:22 +0200 https://github.com/interkosmos/fortran-sqlite3
2021-07-20 14:50:01 +0200 https://github.com/interkosmos/fortran-unix
2021-02-19 01:54:58 +0100 https://github.com/ivan-pi/LINPACK
2021-02-18 16:11:52 +0100 https://github.com/ivan-pi/SMMP
2020-12-22 18:43:04 +0100 https://github.com/ivan-pi/fortran-flann
2021-08-10 17:26:35 +0200 https://github.com/ivan-pi/stiff3
2021-02-17 19:31:11 +0100 https://github.com/ivan-pi/y12m
2021-09-10 08:21:01 -0500 https://github.com/jacobwilliams/NumDiff
2021-08-29 12:19:19 -0500 https://github.com/jacobwilliams/PCHIP
2021-08-26 14:22:56 -0500 https://github.com/jacobwilliams/bspline-fortran
2021-03-20 12:51:11 -0500 https://github.com/jacobwilliams/finterp
2021-07-15 10:43:51 +0800 https://github.com/jacobwilliams/fortran-csv-module
2021-05-31 15:36:14 -0500 https://github.com/jacobwilliams/json-fortran
2021-08-29 19:31:36 -0500 https://github.com/jacobwilliams/pikaia
2021-09-09 22:53:45 -0500 https://github.com/jacobwilliams/pyplot-fortran
2021-08-30 08:26:43 -0500 https://github.com/jacobwilliams/roots-fortran
2021-06-03 23:28:10 +0100 https://github.com/jacobwilliams/slsqp
2021-07-06 09:31:01 +0200 https://github.com/jbdv-no/to_f90
2021-05-31 13:49:15 +0800 https://github.com/jinleiphys/fortran-article
2021-06-07 19:45:17 -0700 https://github.com/jphaupt/cuda_eg
2021-05-07 15:59:19 +0800 https://github.com/keurfonluu/FFTPack
2020-12-15 14:23:38 +0000 https://github.com/kookma/ogpf
2021-06-04 20:33:18 +0200 https://github.com/marvinfriede/hartree-fock
2020-10-31 21:32:19 -0400 https://github.com/milancurcic/fortran202x_split
2021-06-15 10:42:17 -0400 https://github.com/modern-fortran/neural-fortran
2021-08-22 09:19:02 -0700 https://github.com/nedlrichards/fpm_test
2021-08-29 19:21:58 -0500 https://github.com/princemahajan/FLINT
2021-05-21 14:47:17 -0400 https://github.com/renatomatz/cafut
2021-05-26 21:50:35 -0400 https://github.com/renatomatz/otf
2021-02-11 20:24:00 -0800 https://github.com/sourceryinstitute/FEATS
2021-08-21 12:09:14 -0700 https://github.com/sourceryinstitute/assert
2021-05-14 13:45:05 -0700 https://github.com/sourceryinstitute/miniFAVOR
2020-11-27 15:21:43 -0800 https://github.com/sourceryinstitute/sourcery
2020-08-28 10:18:26 +0200 https://github.com/toml-f/toml-f
2020-07-07 22:52:54 -0400 https://github.com/urbanjost/M_CLI
2020-08-03 01:52:12 -0400 https://github.com/urbanjost/M_CLI2
2021-04-16 17:48:39 -0400 https://github.com/urbanjost/M_LA
2021-04-03 19:47:15 -0400 https://github.com/urbanjost/M_OS
2021-03-28 18:22:26 -0400 https://github.com/urbanjost/M_args
2021-07-24 14:35:42 -0400 https://github.com/urbanjost/M_attr
2021-08-15 18:18:40 -0400 https://github.com/urbanjost/M_blas
2021-06-25 23:40:53 -0400 https://github.com/urbanjost/M_calcomp
2020-07-07 10:10:49 -0400 https://github.com/urbanjost/M_calculator
2020-07-07 23:38:36 -0400 https://github.com/urbanjost/M_color
2020-07-18 14:56:02 -0400 https://github.com/urbanjost/M_draw
2020-09-12 18:09:48 -0400 https://github.com/urbanjost/M_escape
2021-03-28 22:07:23 -0400 https://github.com/urbanjost/M_factor
2020-07-07 21:39:10 -0400 https://github.com/urbanjost/M_history
2020-10-03 23:55:08 -0400 https://github.com/urbanjost/M_intrinsics
2020-07-07 22:42:54 -0400 https://github.com/urbanjost/M_io
2021-03-28 21:19:24 -0400 https://github.com/urbanjost/M_kracken
2020-07-15 00:00:24 -0400 https://github.com/urbanjost/M_kracken95
2021-01-12 22:05:08 -0500 https://github.com/urbanjost/M_list
2020-07-07 23:46:07 -0400 https://github.com/urbanjost/M_match
2021-04-16 17:48:39 -0400 https://github.com/urbanjost/M_matrix
2020-07-05 23:58:21 -0400 https://github.com/urbanjost/M_msg
2021-03-18 23:11:28 -0400 https://github.com/urbanjost/M_ncurses
2020-11-07 20:47:50 -0500 https://github.com/urbanjost/M_path
2020-08-22 17:17:43 -0400 https://github.com/urbanjost/M_pixel
2020-07-07 02:22:50 -0400 https://github.com/urbanjost/M_process
2021-01-15 23:20:25 -0500 https://github.com/urbanjost/M_readline
2021-03-12 20:37:48 -0500 https://github.com/urbanjost/M_slices
2021-01-06 21:16:11 -0500 https://github.com/urbanjost/M_sort
2020-07-12 02:57:44 -0400 https://github.com/urbanjost/M_strings
2020-07-16 18:23:49 -0400 https://github.com/urbanjost/M_system
2020-07-07 21:34:28 -0400 https://github.com/urbanjost/M_time
2021-02-10 07:23:50 -0500 https://github.com/urbanjost/M_uuid
2021-09-12 17:57:49 -0400 https://github.com/urbanjost/easy
2021-03-18 18:57:22 -0400 https://github.com/urbanjost/fpm-man
2021-03-16 19:13:26 -0400 https://github.com/urbanjost/general-purpose-fortran
2021-06-08 23:16:48 -0400 https://github.com/urbanjost/prep
2021-09-15 00:09:54 -0400 https://github.com/urbanjost/testit
2021-03-02 21:03:30 +0100 https://github.com/vmagnin/formidi
2021-02-19 22:10:40 +0100 https://github.com/vmagnin/forsynth
2021-03-13 18:05:10 +0100 https://github.com/vmagnin/fundamental_constants
2021-06-03 15:27:19 +0200 https://github.com/vmagnin/gtkzero_fpm
2020-04-26 14:57:00 -0400 https://github.com/wavebitscientific/datetime-fortran
2020-10-05 15:05:30 +0200 https://github.com/wavebitscientific/functional-fortran
2021-03-19 11:41:31 -0700 https://github.com/willdickson/fqs-aero
2021-03-22 16:58:27 -0700 https://github.com/willdickson/h5fortran-wbd-experimental
2021-09-11 12:00:56 +0800 https://github.com/zoziha/SPH
2021-05-25 13:23:34 +0800 https://github.com/zoziha/fftpack-4
2021-05-07 15:59:19 +0800 https://github.com/zoziha/fftpack-5
2021-06-18 10:25:28 +0800 https://github.com/zoziha/fortsa
2021-09-08 15:56:21 +0800 https://github.com/zoziha/mini-test
2021-02-08 13:30:43 -0600 https://gitlab.com/everythingfunctional/binary_tree
2020-07-30 17:55:52 -0700 https://gitlab.com/everythingfunctional/cmdff
2020-06-04 11:26:05 -0700 https://gitlab.com/everythingfunctional/erloff
2020-05-23 10:27:30 -0700 https://gitlab.com/everythingfunctional/hello_fpm
2020-05-23 09:57:49 -0700 https://gitlab.com/everythingfunctional/helloff
2021-02-02 12:27:19 -0600 https://gitlab.com/everythingfunctional/heterogeneous_list
2020-05-30 13:25:17 -0700 https://gitlab.com/everythingfunctional/iso_varying_string
2020-06-04 14:28:19 -0700 https://gitlab.com/everythingfunctional/jsonff
2021-01-13 14:38:20 -0600 https://gitlab.com/everythingfunctional/make_vegetable_driver
2020-06-05 08:38:31 -0700 https://gitlab.com/everythingfunctional/matterff
2020-06-04 12:15:59 -0700 https://gitlab.com/everythingfunctional/parff
2020-06-04 19:26:12 -0700 https://gitlab.com/everythingfunctional/quaff
2020-06-10 19:54:15 -0700 https://gitlab.com/everythingfunctional/quaff_gnuplot_units
2020-06-10 15:30:48 -0700 https://gitlab.com/everythingfunctional/quaff_latex_units
2021-07-12 14:30:27 -0500 https://gitlab.com/everythingfunctional/recursive_data_structure_example
2020-06-14 18:51:50 -0700 https://gitlab.com/everythingfunctional/sqliteff
2021-02-09 12:50:11 -0600 https://gitlab.com/everythingfunctional/stack_example
2020-05-30 13:43:54 -0700 https://gitlab.com/everythingfunctional/strff
2020-05-30 15:33:55 -0700 https://gitlab.com/everythingfunctional/vegetables
36 changes: 36 additions & 0 deletions tests/test_model.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import pytest
import requests
import tomli as toml
from pathlib import Path

from pyfpm.model import Manifest


root = Path(__file__).parent
with open(root / "fpm-projects.txt") as fd:
data = fd.read()

repos = [
line.strip().split()[-1]
for line in data.splitlines()
if "https://github.com/" in line
]


@pytest.mark.parametrize("repo", repos)
def test_github(repo):
repo = repo.replace("https://github.com/", "")
response = requests.get(f"https://raw.githubusercontent.com/{repo}/HEAD/fpm.toml")
if response.status_code == 200:
try:
manifest = Manifest(**toml.loads(response.text))
except Exception as e:
print(response.text)
print(e)
assert False


if __name__ == "__main__":

for repo in repos:
test_github(repo)

0 comments on commit 32b2d04

Please sign in to comment.