-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup Python package information and build setup for 3.12 (#1)
- Loading branch information
Showing
7,278 changed files
with
747 additions
and
183 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
name: Test Python package | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
pull_request: | ||
branches: [ main ] | ||
|
||
jobs: | ||
test: | ||
name: Testing | ||
runs-on: "ubuntu-latest" | ||
defaults: | ||
run: | ||
shell: bash -l {0} | ||
strategy: | ||
matrix: | ||
python-version: ['3.12'] | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: conda-incubator/setup-miniconda@v2 | ||
with: | ||
activate-environment: dev | ||
environment-file: ./environment_dev.yaml | ||
python-version: ${{ matrix.python-version }} | ||
- run: | | ||
ls | ||
pwd | ||
which python | ||
conda info | ||
- run: pip install . -v | ||
- run: make test python=python | ||
# - run: make format python=python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
# repo specific | ||
./env | ||
*.sqlite3 | ||
*.whl | ||
|
||
|
||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
python=./env/bin/python | ||
mamba=mamba | ||
pkg=qmllib | ||
pip=./env/bin/pip | ||
j=1 | ||
|
||
.PHONY: build | ||
|
||
all: env setup | ||
|
||
env: | ||
${mamba} env create -f ./environment_dev.yaml -p ./env --quiet | ||
${pip} install -e . | ||
|
||
setup: ./.git/hooks/pre-commit | ||
|
||
./.git/hooks/pre-commit: | ||
${python} -m pre_commit install | ||
|
||
format: | ||
${python} -m pre_commit run --all-files | ||
|
||
test: | ||
${python} -m pytest -rs \ | ||
./tests/test_kernels.py \ | ||
./tests/test_solvers.py \ | ||
./tests/test_distance.py \ | ||
./tests/test_slatm.py | ||
|
||
types: | ||
${python} -m monkeytype run $(which pytest) ./tests/ | ||
${python} -m monkeytype list-modules | grep ${pkg} | parallel -j${j} "${python} -m monkeytype apply {}" | ||
|
||
cov: | ||
${python} -m pytest -vrs --cov=${pkg} --cov-report html tests | ||
|
||
compile: | ||
${python} _compile.py | ||
|
||
build: | ||
@#${python} -m build . | ||
# ${python} -m pip wheel --no-deps -v . | ||
${python} -m pip wheel -v . | ||
ls *.whl | ||
|
||
clean: | ||
find ./src/ -type f \ | ||
-name "*.so" \ | ||
-name "*.pyc" \ | ||
-name ".pyo" \ | ||
-delete | ||
rm -rf *.whl | ||
rm -fr ./build/ ./__pycache__/ | ||
|
||
clean-env: | ||
rm -rf ./env/ | ||
rm ./.git/hooks/pre-commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
""" Compile script for Fortran """ | ||
|
||
import os | ||
import subprocess | ||
from pathlib import Path | ||
|
||
f90_modules = { | ||
"representations/frepresentations": ["frepresentations.f90"], | ||
"representations/facsf": ["facsf.f90"], | ||
"representations/fslatm": ["fslatm.f90"], | ||
"representations/fchl/ffchl_module": [ | ||
"ffchl_module.f90", | ||
"ffchl_scalar_kernels.f90", | ||
"ffchl_kernel_types.f90", | ||
"ffchl_kernels.f90", | ||
"ffchl_electric_field_kernels.f90", | ||
"ffchl_force_kernels.f90", | ||
], | ||
"solvers/fsolvers": ["fsolvers.f90"], | ||
"kernels/fdistance": ["fdistance.f90"], | ||
"kernels/fkernels": ["fkernels.f90", "fkpca.f90"], | ||
"kernels/fgradient_kernels": ["fgradient_kernels.f90"], | ||
} | ||
|
||
|
||
def find_mkl(): | ||
|
||
return | ||
|
||
|
||
def find_flags(fcc: str): | ||
"""Find compiler flags""" | ||
|
||
# TODO Find math lib | ||
# TODO Find os | ||
|
||
# -lgomp", "-lpthread", "-lm", "-ldl | ||
# ["-L${MKLROOT}/lib/intel64", "-lmkl_rt"] | ||
|
||
# COMPILER_FLAGS = ["-O3", "-fopenmp", "-m64", "-march=native", "-fPIC", | ||
# "-Wno-maybe-uninitialized", "-Wno-unused-function", "-Wno-cpp"] | ||
# LINKER_FLAGS = ["-lgomp"] | ||
|
||
flags = ["-L/usr/lib/", "-lblas", "-llapack"] | ||
|
||
return flags | ||
|
||
|
||
def find_fcc(): | ||
"""Find the fortran compiler. Either gnu or intel""" | ||
|
||
# fcc = "ifort" | ||
fcc = "gfortran" | ||
|
||
return fcc | ||
|
||
|
||
def main(): | ||
"""Compile f90 in src/qmllib""" | ||
|
||
fcc = find_fcc() | ||
flags = find_flags(fcc) | ||
|
||
os.environ["FCC"] = fcc | ||
|
||
for module_name, module_sources in f90_modules.items(): | ||
|
||
path = Path(module_name) | ||
|
||
parent = path.parent | ||
stem = path.stem | ||
cwd = Path("src/qmllib") / parent | ||
cmd = ["python", "-m", "numpy.f2py", "-c"] + flags + module_sources + ["-m", str(stem)] | ||
print(cwd, " ".join(cmd)) | ||
|
||
proc = subprocess.run(cmd, cwd=cwd, capture_output=True, text=True) | ||
stdout = proc.stdout | ||
stderr = proc.stderr | ||
exitcode = proc.returncode | ||
|
||
if exitcode > 0: | ||
print(stdout) | ||
print() | ||
print(stderr) | ||
exit(exitcode) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: qmllib_dev | ||
channels: | ||
- conda-forge | ||
- defaults | ||
dependencies: | ||
- python==3.12 | ||
- jupytext | ||
- monkeytype | ||
- numpy | ||
- pandas | ||
- pip | ||
- pre-commit | ||
- pytest | ||
- scikit-learn | ||
- scipy | ||
# build | ||
- meson | ||
- ninja |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[build-system] | ||
requires = ["setuptools", "numpy", "meson", "ninja"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "qmllib" | ||
dynamic = ["version"] | ||
authors = [] | ||
requires-python = ">=3.12" | ||
|
||
[options.packages.find] | ||
where="src" | ||
|
||
[tool.setuptools] | ||
include-package-data = true | ||
|
||
[tool.setuptools.dynamic] | ||
version = {attr = "qmllib.version.__version__"} | ||
|
||
[tool.setuptools.package-data] | ||
"*" = ['*.so'] | ||
|
||
|
||
# [tool.black] | ||
# line-length = 120 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"include": [ | ||
"src" | ||
], | ||
"exclude": [ | ||
"env" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[pytest] | ||
log_cli_level = DEBUG | ||
log_cli_format = %(asctime)s [%(levelname)8s] %(message)s (%(filename)s:%(lineno)s) | ||
log_cli_date_format=%Y-%m-%d %H:%M:%S |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import sys | ||
from pathlib import Path | ||
|
||
from setuptools import setup | ||
|
||
try: | ||
import _compile | ||
except ImportError: | ||
sys.path.append(str(Path(__file__).resolve().parent)) | ||
import _compile | ||
|
||
if __name__ == "__main__": | ||
_compile.main() | ||
setup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from qmllib.version import __version__ |
Empty file.
Oops, something went wrong.