Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
MilanSkocic committed Aug 29, 2023
2 parents ace34dd + 587020a commit 6c6773d
Show file tree
Hide file tree
Showing 56 changed files with 689 additions and 437 deletions.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,10 @@ dist/

*generator*

pywrapper/pycodata/*.h
pywrapper/pycodata/*.h
pywrapper/pycodata/*.a
pywrapper/pycodata/*.dll
pywrapper/pycodata/*.dll.a
pywrapper/pycodata/*.so
pywrapper/pycodata/*.dylib
pywrapper/pycodata/*.pyd
17 changes: 6 additions & 11 deletions INSTALL.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
A Makefile is provided which uses `fpm <https://fpm.fortran-lang.org/en/index.html>`_ for building the library
with additional options:
A Makefile is provided, which uses `fpm <https://fpm.fortran-lang.org/en/index.html>`_, for building the library.

* compile the source generator and generate the sources
* copy needed sources into the python wrapper folder
* build a shared library
* install the C headers
* uninstall the library and headers
On windows, `msys2 <https://www.msys2.org>`_ needs to be installed.

On windows, `msys2 <https://www.msys2.org>`_ needs to be installed and use
the mingw64 or mingw32 terminals.
On Darwin, the `gcc <https://formulae.brew.sh/formula/gcc>`_ toolchain needs to be installed.

Build: the configuration file will set all the environmental variables necessary for the compilation

Expand All @@ -35,8 +29,9 @@ Uninstall
make uninstall
If a shared is needed:
If building the python wrapper is needed:

.. code-block:: bash
make shared
cd pywrapper
python setup.py bdist_wheel
31 changes: 19 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,39 @@ else
install_dir=$(DEFAULT_INSTALL_DIR)
endif

.PHONY: all clean install uninstall
.PHONY: all clean install uninstall copy_h copy_a shared_linux shared_windows shared_darwin

all: $(LIBNAME)

$(LIBNAME): build
cp $(shell find ./build -type f -name lib$(LIBNAME).a) $(BUILD_DIR)
cp $(BUILD_DIR)/lib$(LIBNAME).a $(PYW_MOD_DIR)/
cp $(INCLUDE_DIR)/$(LIBNAME).h $(PYW_MOD_DIR)/
$(LIBNAME): build copy_h copy_a shared copy_shared

build: clean
$(MAKE) -C ./srcgen
fpm build
fpm build --profile=release

shared: shared_$(PLATFORM)

shared_linux: $(LIBNAME)
shared_linux:
gfortran -shared -o $(BUILD_DIR)/lib$(LIBNAME).so -Wl,--whole-archive $(BUILD_DIR)/lib$(LIBNAME).a -Wl,--no-whole-archive

shared_darwin: $(LIBNAME)
gfortran -dynamiclib -install_name lib$(LIBNAME) -static-libgfortran -static-libquadmath -static-libgcc -o $(BUILD_DIR)/lib$(LIBNAME).dylib -Wl,-all_load $(BUILD_DIR)/lib$(LIBNAME).a -Wl,-noall_load
shared_darwin:
gfortran -dynamiclib -install_name @rpath/lib$(LIBNAME).dylib -static-libgfortran -static-libquadmath -static-libgcc -o $(BUILD_DIR)/lib$(LIBNAME).dylib -Wl,-all_load $(BUILD_DIR)/lib$(LIBNAME).a -Wl,-noall_load

shared_windows: $(LIBNAME)
shared_windows:
gfortran -shared -static -o $(BUILD_DIR)/lib$(LIBNAME).dll -Wl,--out-implib=$(BUILD_DIR)/lib$(LIBNAME).dll.a,--export-all-symbols,--enable-auto-import,--whole-archive $(BUILD_DIR)/lib$(LIBNAME).a -Wl,--no-whole-archive

copy_a:
cp $(shell find ./build -type f -name lib$(LIBNAME).a) $(BUILD_DIR)

copy_h:
cp $(INCLUDE_DIR)/$(LIBNAME)*.h $(PYW_MOD_DIR)/

copy_shared: copy_a
cp -f $(BUILD_DIR)/lib$(LIBNAME).so $(PYW_MOD_DIR) | true
cp -f $(BUILD_DIR)/lib$(LIBNAME).dylib $(PYW_MOD_DIR) | true
cp -f $(BUILD_DIR)/lib$(LIBNAME).dll $(PYW_MOD_DIR) | true
cp -f $(BUILD_DIR)/lib$(LIBNAME).dll.a $(PYW_MOD_DIR) | true

clean:
$(MAKE) -C ./srcgen clean
fpm clean --all

install:
Expand Down
3 changes: 2 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Description

.. readme_inclusion_start
`codata` provides the lastest codata constants (2018).
`codata` is a Fortran library providing the lastest codata constants (2018).
It also provides a API for the C language.
The raw codata are taken from http://physics.nist.gov/constants.

.. readme_inclusion_end
Expand Down
21 changes: 4 additions & 17 deletions configuration
Original file line number Diff line number Diff line change
@@ -1,39 +1,26 @@
LIBNAME="codata"

# Default flags
fcommon="-std=f2008 -pedantic -Wall -Wextra -fmax-errors=1 -fcheck=array-temps -fbacktrace -fcoarray=single"
ccommon="-std=c11 -pedantic -Wall -Wextra"
fpic="-fPIC"
opt="-O3"
static="-static"
osx_ld_flags="-static-libgfortran -static-libquadmath -static-libgcc"

# environment variables
PYW_DIR="./pywrapper"
BUILD_DIR="./build"
INCLUDE_DIR="./include"
PYW_MOD_DIR="$PYW_DIR/py$LIBNAME"
FPM_FFLAGS=""
FPM_LDFLAGS=""
FPM_CFLAGS=""
FPM_FFLAGS="-std=f2008 -pedantic -Wall -Wextra"
FPM_CFLAGS="-std=c11 -pedantic -Wall -Wextra"
FPM_LDFLAGS="-static"
DEFAULT_INSTALL_DIR="$HOME/.local"
PLATFORM="linux"

if [[ "$OSTYPE" == "msys" ]]; then
opt="-O0"
DEFAULT_INSTALL_DIR="${APPDATA//\\//}/local"
PLATFORM="windows"
fi

if [[ "$OSTYPE" == "darwin"* ]];then
static=""
FPM_LDFLAGS=$osx_ld_flags
FPM_LDFLAGS="-static-libgfortran -static-libquadmath -static-libgcc"
PLATFORM="darwin"
fi

FPM_FFLAGS="$fcommon $fpic $opt $static"
FPM_CFLAGS="$ccommon $fpic $opt $static"

export FPM_FFLAGS
export FPM_CFLAGS
export FPM_LDFLAGS
Expand Down
2 changes: 1 addition & 1 deletion docs/_sources/getting_started/codata.rst.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
codata
==============

.. image:: ../../../../media/logo-codata.png
.. image:: ../media/logo-codata.png
:width: 200
:align: center

Expand Down
7 changes: 4 additions & 3 deletions docs/_sources/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ Welcome to codata documentation!
api/index.rst


.. only:: html

Indices and tables
==================
Search
==================

* :ref:`search`
* :ref:`search`
25 changes: 25 additions & 0 deletions docs/_sources/releases/0.8.1-notes.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Codata 0.8.1 Release Note
============================

Summary
---------------

* Use shared library in python wrapper.
* Minor fixes in documentation.

Download
---------------

`Codata Releases <https://github.com/MilanSkocic/codata/releases>`_

`PYPI <https://pypi.org/project/pycodata>`_


Contributors
---------------
Milan Skocic

Commits
---------

**Full Changelog**: https://github.com/MilanSkocic/codata/compare/0.8.0...0.8.1
1 change: 1 addition & 0 deletions docs/_sources/releases/index.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Release Notes
.. toctree::
:maxdepth: 1

0.8.1-notes.rst
0.8.0-notes.rst
0.7.1-notes.rst
0.7.0-notes.rst
Expand Down
22 changes: 22 additions & 0 deletions docs/_static/basic.css
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ a.headerlink {
visibility: hidden;
}

a:visited {
color: #551A8B;
}

h1:hover > a.headerlink,
h2:hover > a.headerlink,
h3:hover > a.headerlink,
Expand Down Expand Up @@ -670,6 +674,16 @@ dd {
margin-left: 30px;
}

.sig dd {
margin-top: 0px;
margin-bottom: 0px;
}

.sig dl {
margin-top: 0px;
margin-bottom: 0px;
}

dl > dd:last-child,
dl > dd:last-child > :last-child {
margin-bottom: 0;
Expand Down Expand Up @@ -738,6 +752,14 @@ abbr, acronym {
cursor: help;
}

.translated {
background-color: rgba(207, 255, 207, 0.2)
}

.untranslated {
background-color: rgba(255, 207, 207, 0.2)
}

/* -- code displays --------------------------------------------------------- */

pre {
Expand Down
5 changes: 2 additions & 3 deletions docs/_static/documentation_options.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var DOCUMENTATION_OPTIONS = {
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
VERSION: '0.8.0',
const DOCUMENTATION_OPTIONS = {
VERSION: '0.8.1',
LANGUAGE: 'en',
COLLAPSE_INDEX: false,
BUILDER: 'html',
Expand Down
26 changes: 17 additions & 9 deletions docs/_static/searchtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ const _removeChildren = (element) => {
const _escapeRegExp = (string) =>
string.replace(/[.*+\-?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string

const _displayItem = (item, searchTerms) => {
const _displayItem = (item, searchTerms, highlightTerms) => {
const docBuilder = DOCUMENTATION_OPTIONS.BUILDER;
const docUrlRoot = DOCUMENTATION_OPTIONS.URL_ROOT;
const docFileSuffix = DOCUMENTATION_OPTIONS.FILE_SUFFIX;
const docLinkSuffix = DOCUMENTATION_OPTIONS.LINK_SUFFIX;
const showSearchSummary = DOCUMENTATION_OPTIONS.SHOW_SEARCH_SUMMARY;
const contentRoot = document.documentElement.dataset.content_root;

const [docName, title, anchor, descr, score, _filename] = item;

Expand All @@ -75,20 +75,24 @@ const _displayItem = (item, searchTerms) => {
if (dirname.match(/\/index\/$/))
dirname = dirname.substring(0, dirname.length - 6);
else if (dirname === "index/") dirname = "";
requestUrl = docUrlRoot + dirname;
requestUrl = contentRoot + dirname;
linkUrl = requestUrl;
} else {
// normal html builders
requestUrl = docUrlRoot + docName + docFileSuffix;
requestUrl = contentRoot + docName + docFileSuffix;
linkUrl = docName + docLinkSuffix;
}
let linkEl = listItem.appendChild(document.createElement("a"));
linkEl.href = linkUrl + anchor;
linkEl.dataset.score = score;
linkEl.innerHTML = title;
if (descr)
if (descr) {
listItem.appendChild(document.createElement("span")).innerHTML =
" (" + descr + ")";
// highlight search terms in the description
if (SPHINX_HIGHLIGHT_ENABLED) // set in sphinx_highlight.js
highlightTerms.forEach((term) => _highlightText(listItem, term, "highlighted"));
}
else if (showSearchSummary)
fetch(requestUrl)
.then((responseData) => responseData.text())
Expand All @@ -97,6 +101,9 @@ const _displayItem = (item, searchTerms) => {
listItem.appendChild(
Search.makeSearchSummary(data, searchTerms)
);
// highlight search terms in the summary
if (SPHINX_HIGHLIGHT_ENABLED) // set in sphinx_highlight.js
highlightTerms.forEach((term) => _highlightText(listItem, term, "highlighted"));
});
Search.output.appendChild(listItem);
};
Expand All @@ -115,14 +122,15 @@ const _finishSearch = (resultCount) => {
const _displayNextItem = (
results,
resultCount,
searchTerms
searchTerms,
highlightTerms,
) => {
// results left, load the summary and display it
// this is intended to be dynamic (don't sub resultsCount)
if (results.length) {
_displayItem(results.pop(), searchTerms);
_displayItem(results.pop(), searchTerms, highlightTerms);
setTimeout(
() => _displayNextItem(results, resultCount, searchTerms),
() => _displayNextItem(results, resultCount, searchTerms, highlightTerms),
5
);
}
Expand Down Expand Up @@ -360,7 +368,7 @@ const Search = {
// console.info("search results:", Search.lastresults);

// print the results
_displayNextItem(results, results.length, searchTerms);
_displayNextItem(results, results.length, searchTerms, highlightTerms);
},

/**
Expand Down
16 changes: 13 additions & 3 deletions docs/_static/sphinx_highlight.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,19 @@ const _highlight = (node, addItems, text, className) => {
}

span.appendChild(document.createTextNode(val.substr(pos, text.length)));
const rest = document.createTextNode(val.substr(pos + text.length));
parent.insertBefore(
span,
parent.insertBefore(
document.createTextNode(val.substr(pos + text.length)),
rest,
node.nextSibling
)
);
node.nodeValue = val.substr(0, pos);
/* There may be more occurrences of search term in this node. So call this
* function recursively on the remaining fragment.
*/
_highlight(rest, addItems, text, className);

if (isInSVG) {
const rect = document.createElementNS(
Expand Down Expand Up @@ -140,5 +145,10 @@ const SphinxHighlight = {
},
};

_ready(SphinxHighlight.highlightSearchWords);
_ready(SphinxHighlight.initEscapeListener);
_ready(() => {
/* Do not call highlightSearchWords() when we are on the search page.
* It will highlight words from the *previous* search query.
*/
if (typeof Search === "undefined") SphinxHighlight.highlightSearchWords();
SphinxHighlight.initEscapeListener();
});
Loading

0 comments on commit 6c6773d

Please sign in to comment.