Skip to content

Commit

Permalink
Initial implementation of TOML file
Browse files Browse the repository at this point in the history
  • Loading branch information
holm10 committed Mar 9, 2024
1 parent 67e9ef7 commit 9035244
Show file tree
Hide file tree
Showing 26 changed files with 191 additions and 106 deletions.
2 changes: 1 addition & 1 deletion Makefile.Forthon
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ all: mppl2f90 $(BUILDDIR)/compydep $(BUILDDIR)/grdpydep $(BUILDDIR)/flxpydep $(B
rm -f uedgeC.so

mppl2f90:
(export PYTHONPATH=.:./pyscripts; $(MYPYTHON) convertor)
(export PYTHONPATH=.:./buildscripts; $(MYPYTHON) convertor)

$(BUILDDIR)/compydep: com/blasext.F com/brent.F com/comutil.F com/misc.F com/mnbrak.F com/dsum.f com/dummy_py.f com/error.f com/getmsg.f com/ssum.f com/$(PETSC-COM) com/com.v
$(FORTHON) -a $(INSTALLARGS) -a $(FCOMP) $(DEBUG) --interfacefile com/com.v -f com/blasext.F com com/brent.F com/comutil.F com/misc.F com/mnbrak.F com/dsum.f com/dummy_py.f com/error.f com/getmsg.f com/ssum.f $(PETSC-COM)
Expand Down
File renamed without changes.
File renamed without changes.
75 changes: 75 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
[build-system]
requires = ["setuptools >= 61.0", "forthon", "numpy"]
build-backend = "setuptools.build_meta:__legacy__"

[project]
#dynamic = ["version"]
version = "8.1.0-beta.0"
name = "uedge"
dependencies = [
"forthon",
"numpy",
]
requires-python = ">= 3.5" # TODO: verify
authors = [
{name = "Tom Rognlien"}
]
maintainers = [
{name = "Bill Meyer", email = "[email protected]"},
{name = "Andreas Holm", email = "[email protected]"}
]
description = "2D Fluid simulation of plasma and neutrals in magnetic fusion devices"
readme = "README.md"
keywords = [
"plasma",
"fusion",
"tokamak",
"edge-plasma",
"scrape-off layer",
"multi-fluid"
]
classifiers = [
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)",
"Operating System :: Unix",
"Operating System :: MacOS :: MacOS X",
"Programming Language :: Fortran",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Topic :: Scientific/Engineering :: Physics",
]

[project.urls]
Homepage = "https://github.com/LLNL/UEDGE/"
#Documentation = "https://readthedocs.org"
Repository = "https://github.com/LLNL/UEDGE.git"
Issues = "https://github.com/LLNL/UEDGE/issues"
#Changelog = "https://github.com/me/spam/blob/master/CHANGELOG.md"




[project.optional-dependencies]
ueplot = [
"matplotlib",
"scipy",
"scikit-image"
]

# TODO: rewrite scripts to be importable
#[project.scripts]
#spam-cli = "spam:main_cli"

#[tool.setuptools]
#script-files = [
# "pyscripts/pdb2hdf5",
# "pyscripts/bas2py",
# "pyscripts/hdf52pdb"
#]
#packages = ["uedge"]
#package-dir = {"" = "pyscripts"}



#[tool.setuptools.dynamic]
#version = {attr = "uedge.__version__"}
175 changes: 86 additions & 89 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,21 @@
from Forthon.compilers import FCompiler
import getopt
import logging
from subprocess import call
import numpy
from setuptools import Extension, setup, Distribution
from setuptools.command.build import build
from setuptools.command.develop import develop
from setuptools.command.egg_info import egg_info
os.environ['PATH'] += os.pathsep + site.USER_BASE + '/bin'

version='8.1.0-beta.0'

try:
os.environ['PATH'] += os.pathsep + site.USER_BASE + '/bin'
import setuptools
import distutils
from distutils.core import setup
from distutils.core import Extension
from distutils.dist import Distribution
from distutils.command.build import build
from distutils.command.install import install
from subprocess import call
import numpy
except:
raise SystemExit("Distutils problem")

optlist, args = getopt.getopt(sys.argv[1:], 'gt:F:', ['parallel', 'petsc', 'omp'])

optlist, args = getopt.getopt(sys.argv[1:], 'gt:F:', ['parallel', 'omp'])
machine = sys.platform
debug = 0
fcomp = None
parallel = 0
petsc = 0
#petsc = 0

for o in optlist:
if o[0] == '-g':
Expand All @@ -43,19 +35,19 @@
fcomp = o[1]
elif o[0] == '--parallel':
parallel = 1
elif o[0] == '--petsc':
petsc = 1
# elif o[0] == '--petsc':
# petsc = 1
elif o[0] == '--omp':
os.putenv("OMP","1")



if petsc == 1 and os.getenv('PETSC_DIR') == None:
raise SystemExit("PETSc requested but PETSC_DIR not set")
if os.getenv('PETSC_DIR') != None:
petsc = 1
if petsc == 1 and os.getenv('PETSC_ARCH') == None:
raise SystemExit("PETSc requested but PETSC_ARCH not set")
#if petsc == 1 and os.getenv('PETSC_DIR') == None:
# raise SystemExit("PETSc requested but PETSC_DIR not set")
#if os.getenv('PETSC_DIR') != None:
# petsc = 1
#if petsc == 1 and os.getenv('PETSC_ARCH') == None:
# raise SystemExit("PETSc requested but PETSC_ARCH not set")


sys.argv = ['setup2.py']+args
Expand All @@ -64,36 +56,53 @@
fcompname=fcomp)


class uedgeInstall(build):
def run(self):
install.run(self)
logging.basicConfig(stream=sys.stderr,level=logging.INFO)
log = logging.getLogger()
log.info("test")
#class uedgeInstall(build):
# def run(self):
# install.run(self)
# logging.basicConfig(stream=sys.stderr,level=logging.INFO)
# log = logging.getLogger()
# log.info("test")

class uedgeBuild(build):
def run(self):
print("Building UEDGE...")
# with python2 everything is put into a single uedgeC.so file
if sys.hexversion < 0x03000000:
raise SystemExit("Python versions < 3 not supported")
else:
if petsc == 0:
status = call(['make', '-f','Makefile.Forthon'])
else:
status = call(['make', '-f', 'Makefile.PETSc'])
if status != 0: raise SystemExit("Build failure")
# if petsc == 0:
status = call(['make', '-f','Makefile.Forthon'])
# else:
# status = call(['make', '-f', 'Makefile.PETSc'])
if status != 0:
raise SystemExit("Build failure")
build.run(self)


class uedgeClean(build):
def run(self):
print("Cleaning UEDGE")
if sys.hexversion < 0x03000000:
raise SystemExit("Python versions < 3 not supported")
else:
if petsc == 0:
status = call(['make', '-f', 'Makefile.Forthon', 'clean'])
else:
status = call(['make', '-f', 'Makefile.PETSc', 'clean'])
if status != 0: raise SystemExit("Clean failure")
# if petsc == 0:
status = call(['make', '-f', 'Makefile.Forthon', 'clean'])
# else:
# status = call(['make', '-f', 'Makefile.PETSc', 'clean'])
if status != 0:
raise SystemExit("Clean failure")


class CustomDevelopCommand(develop):
def run(self):
print("Develop called")
develop.run(self)


class CustomEggInfoCommand(egg_info):
def run(self):
print("EggInfo called")
egg_info.run(self)

uedgepkgs = ['aph', 'api', 'bbb', 'com', 'flx', 'grd', 'svr', 'wdf', 'ncl']

Expand Down Expand Up @@ -126,27 +135,27 @@ def makeobjects(pkg):
library_dirs = fcompiler.libdirs
libraries = fcompiler.libs

if petsc:
#if petsc:
# PETSC_DIR = '/homes/mccomic/petsc-uedge'
# PETSC_ARCH = 'linux-uedge'
PETSC_DIR = os.getenv('PETSC_DIR')
PETSC_ARCH = os.getenv('PETSC_ARCH')
library_dirs = fcompiler.libdirs + \
[os.path.join(PETSC_DIR, PETSC_ARCH, 'lib')]
libraries = ['petscts', 'petscsnes', 'petscksp', 'petscdm', 'petscmat',
'petscvec', 'petsc', 'HYPRE', 'mpich', 'lapack', 'blas', 'X11',
'pthread', 'rt', 'stdc++', 'm'] + fcompiler.libs
libraries = ['petsc'] + fcompiler.libs
# PETSC_DIR = os.getenv('PETSC_DIR')
# PETSC_ARCH = os.getenv('PETSC_ARCH')
# library_dirs = fcompiler.libdirs + \
# [os.path.join(PETSC_DIR, PETSC_ARCH, 'lib')]
# libraries = ['petscts', 'petscsnes', 'petscksp', 'petscdm', 'petscmat',
# 'petscvec', 'petsc', 'HYPRE', 'mpich', 'lapack', 'blas', 'X11',
# 'pthread', 'rt', 'stdc++', 'm'] + fcompiler.libs
# libraries = ['petsc'] + fcompiler.libs

if parallel:
library_dirs = fcompiler.libdirs + ['/usr/lpp/ppe.poe/lib']
libraries = fcompiler.libs + ['mpi']
# uedgeobjects = uedgeobjects + ['/usr/local/mpi/ifc_farg.o']

with open('pyscripts/__version__.py','w') as ff:
ff.write("__version__ = '%s'\n"%version)
with open('pyscripts/__src__.py','w') as ff:
ff.write("__src__ = '%s'\n"%os.getcwd())
#with open('pyscripts/__version__.py','w') as ff:
# ff.write("__version__ = '%s'\n"%version)
#with open('pyscripts/__src__.py','w') as ff:
# ff.write("__src__ = '%s'\n"%os.getcwd())

define_macros=[("WITH_NUMERIC", "0"),
("FORTHON_PKGNAME", '\"uedgeC\"'),
Expand All @@ -161,37 +170,25 @@ def makeobjects(pkg):
libraries = ['readline'] + libraries


setup(name="uedge",
version=version,
author='Tom Rognlien',
author_email="[email protected]",
maintainer='Bill Meyer',
maintainer_email='[email protected]',
description="2D Fluid simulation of plasma and neutrals in magnetic fusion devices",
platforms="Unix, Windows (cygwin), Mac OSX",
packages=['uedge'],
package_dir={'uedge': 'pyscripts'},
# include_package_data=True,
scripts=['pyscripts/pdb2hdf5', 'pyscripts/bas2py', 'pyscripts/hdf52pdb'],
ext_modules=[Extension('uedge.uedgeC',
['uedgeC_Forthon.c',
os.path.join(builddir, 'Forthon.c'),
'com/handlers.c', 'com/vector.c','bbb/exmain.c'],
include_dirs=[builddir, numpy.get_include()],
library_dirs=library_dirs,
libraries=libraries,
define_macros=define_macros,
extra_objects=uedgeobjects,
extra_link_args=['-g','-DFORTHON'] +
fcompiler.extra_link_args,
extra_compile_args=fcompiler.extra_compile_args
)],

cmdclass={'build': uedgeBuild, 'clean': uedgeClean},
test_suite="pytests",
install_requires=['forthon'],
# note that include_dirs may have to be expanded in the line above
classifiers=['Programming Language :: Python',
'Programming Language :: Python :: 3']

)
setup(
ext_modules=[Extension('uedge.uedgeC',
['uedgeC_Forthon.c',
os.path.join(builddir, 'Forthon.c'),
'com/handlers.c', 'com/vector.c','bbb/exmain.c'],
include_dirs=[builddir, numpy.get_include()],
library_dirs=library_dirs,
libraries=libraries,
define_macros=define_macros,
extra_objects=uedgeobjects,
extra_link_args=['-g','-DFORTHON'] +
fcompiler.extra_link_args,
extra_compile_args=fcompiler.extra_compile_args
)],
cmdclass={
'build': uedgeBuild,
'clean': uedgeClean,
'develop': CustomDevelopCommand,
'egg_info': CustomEggInfoCommand,
},
# test_suite="pytests",
)
File renamed without changes.
17 changes: 5 additions & 12 deletions pyscripts/__init__.py → src/uedge/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
from .uedge import *
from os import path
from pathlib import Path
try:
from uedge.__version__ import __version__
from uedge.__src__ import __src__
import uedge.checkver
except:
try:
from __version__ import __version__
from __src__ import __src__
import checkver
except:
__version__ = 'unknown'
__src__ = 'unknown'
import uedge.checkver
from uedge._version import version

__version__ = version()
with open('test.txt', 'w') as f:
f.write("kakka")
#
# Load the startup file .uedgerc.py from cwd or home.
#
Expand Down
1 change: 1 addition & 0 deletions src/uedge/__src__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__src__ = '/Users/holm10/Documents/fusion/uedge/src/master'
2 changes: 2 additions & 0 deletions src/uedge/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def version():
return "8.1.0-beta.0"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions src/uedge/filelists.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Methods to create a list of files in a directory, and a sub-list containing sspecified suffixes.

import os
import string
def filelist(path):
return os.listdir(path)

def filesublist(path,suffix):
sublist = []
biglist = filelist(path)
for filename in biglist:
filesplit = filename.split(".")
if filesplit[-1] == suffix:
sublist.append(filename)
return sublist


File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 9035244

Please sign in to comment.