Skip to content
Snippets Groups Projects
Commit 6955bccd authored by Robert K's avatar Robert K Committed by Andreas Dedner
Browse files

[feature][dunepackaging.py] Added option to write meta.yaml for conda

build.

remove debug output

typo

force use of portalocker

remove upgrade again from pip command

but --upgrade back in

remove wheel generation from make install - seems to fail with missing access to numpy wheel

use both DUNE_CMAKE_FLAGS and CMAKE_FLAGS in this order

[testing]

[testing]
parent beab4c65
No related branches found
No related tags found
No related merge requests found
......@@ -22,10 +22,10 @@ def main(argv):
repositories = ["gitlab", "testpypi", "pypi"]
def usage():
return 'usage: dunepackaging.py [--upload <'+"|".join(repositories)+'> | -c | --clean | --version <version> | --onlysdist]'
return 'usage: dunepackaging.py [--upload <'+"|".join(repositories)+'> | -c | --clean | --version <version> | --onlysdist | --bdist_conda]'
try:
opts, args = getopt.getopt(argv, "hc", ["upload=", "clean", "version=", "onlysdist"])
opts, args = getopt.getopt(argv, "hc", ["upload=", "clean", "version=", "onlysdist", "bdist_conda"])
except getopt.GetoptError:
print(usage())
sys.exit(2)
......@@ -35,6 +35,7 @@ def main(argv):
clean = False
version = None
onlysdist = False
bdistconda = False
for opt, arg in opts:
if opt == '-h':
print(usage())
......@@ -52,6 +53,9 @@ def main(argv):
version = arg
elif opt in ("--onlysdist"):
onlysdist = True
elif opt in ("--bdist_conda"):
onlysdist = True
bdistconda = True
# Remove generated files
def removeFiles():
......@@ -140,5 +144,66 @@ def main(argv):
removeFiles()
# create conda package meta.yaml (experimental)
if bdistconda:
import hashlib
remove = ['rm', '-rf', 'dist/'+data.name]
subprocess.call(remove)
mkdir = ['mkdir', 'dist/'+data.name ]
subprocess.call(mkdir)
print("Create bdist_conda (experimental)")
distfile = 'dist/'+data.name+'-'+version+'.tar.gz'
datahash = ''
with open(distfile, "rb") as include:
source = include.read()
datahash = hashlib.sha256( source ).hexdigest()
print("Generate ",'dist/'+data.name+'/meta.yaml')
f = open('dist/'+data.name+'/meta.yaml', "w")
f.write('{% set name = "' + data.name + '" %}\n')
f.write('{% set version = "' + version + '" %}\n')
f.write('{% set hash = "' + datahash + '" %}\n\n')
f.write('package:\n')
f.write(' name: "{{ name|lower }}"\n')
f.write(' version: "{{ version }}"\n\n')
f.write('source:\n')
f.write(' path: ../{{ name }}-{{ version }}/\n')
f.write(' sha256: {{ hash }}\n\n')
f.write('build:\n')
f.write(' number: 1\n')
if 'TMPDIR' in os.environ:
f.write(' script_env:\n')
f.write(' - TMPDIR=' + os.environ['TMPDIR'] +'\n')
f.write(' script: "{{ PYTHON }} -m pip install . --no-deps --ignore-installed -vv "\n\n')
f.write('requirements:\n')
requirements = ['pip', 'python', 'mkl', 'tbb', 'intel-openmp',
'libgcc-ng', 'libstdcxx-ng', 'gmp', 'scikit-build',
'mpi4py', 'matplotlib', 'numpy', 'scipy', 'ufl']
for dep in data.depends:
requirements += [dep[0]]
f.write(' host:\n')
for dep in requirements:
f.write(' - ' + dep + '\n')
f.write('\n')
f.write(' run:\n')
for dep in requirements:
f.write(' - ' + dep + '\n')
f.write('\n')
f.write('test:\n')
f.write(' imports:\n')
f.write(' - ' + data.name.replace('-','.') + '\n\n')
f.write('about:\n')
f.write(' home: '+data.url+'\n')
f.write(' license: GPLv2 with linking exception.\n')
f.write(' license_family: GPL\n')
f.write(' summary: '+data.description+'\n')
f.close()
if __name__ == "__main__":
main(sys.argv[1:])
......@@ -144,9 +144,9 @@ function(dune_python_install_package)
set(WHEEL_COMMAND ${Python3_EXECUTABLE} -m pip wheel -w ${DUNE_PYTHON_WHEELHOUSE} ${PYINST_FULLPATH} ${PYINST_ADDITIONAL_PIP_PARAMS} ${DUNE_PYTHON_ADDITIONAL_PIP_PARAMS})
# Add the installation rule
install(CODE "message(\"Installing wheel for python package at ${PYINST_FULLPATH}...\")
dune_execute_process(COMMAND ${WHEEL_COMMAND}
ERROR_MESSAGE \"Error installing wheel for python package at ${PYINST_FULLPATH}\"
)"
)
# install(CODE "message(\"Installing wheel for python package at ${PYINST_FULLPATH}...\")
# dune_execute_process(COMMAND ${WHEEL_COMMAND}
# ERROR_MESSAGE \"Error installing wheel for python package at ${PYINST_FULLPATH}\"
# )"
# )
endfunction()
......@@ -132,9 +132,6 @@ def pkg_config(pkg, var=None, paths=[]):
pkgconfig = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
pkgconfig.wait()
prefix = pkgconfig.stdout.read()
print(dict(os.environ))
print("err:", pkgconfig.stderr.read() )
print("out:", prefix )
if pkgconfig.returncode != 0:
raise KeyError('package ' + pkg + ' not found.')
return buffer_to_str(prefix).strip()
......@@ -164,9 +161,7 @@ def is_installed(dir, module=None):
prefix = get_prefix(module)
except KeyError:
return False
print("looking at", dir, "prefix=",prefix)
for l in ['lib','lib32','lib64']:
print("comparing with",os.path.realpath(os.path.join(prefix, l, 'dunecontrol', module)))
if os.path.realpath(dir) == os.path.realpath(os.path.join(prefix, l, 'dunecontrol', module)):
return True
return False
......
......@@ -265,11 +265,15 @@ def cmakeFlags():
]))
# test environment for additional flags
cmakeFlags = os.environ.get('DUNE_CMAKE_FLAGS')
if cmakeFlags is None:
cmakeFlags = os.environ.get('CMAKE_FLAGS')
print("@@@@@ cmakeFlags=",cmakeFlags,flush=True)
# split cmakeFlags and add them to flags
if cmakeFlags is not None:
flags += shlex.split(cmakeFlags)
cmakeFlags = os.environ.get('CMAKE_FLAGS')
print("@@@@@ cmakeFlags=",cmakeFlags,flush=True)
if cmakeFlags is not None:
flags += shlex.split(cmakeFlags)
print("@@@@@ flags=",flags,flush=True)
return flags
def inVEnv():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment