Skip to content
Snippets Groups Projects
Commit 0fd2cdca authored by Nathan Hertz's avatar Nathan Hertz
Browse files

Added logging to setup_to_meta and build_pkgs.

parent 9951a251
No related branches found
No related tags found
No related merge requests found
import subprocess
import logging
logger = logging.getLogger("buildout/build_pkgs")
def get_dirs():
"""
Finds all subdirectories containing setup.py files.
:return: List of directories as strings.
"""
logger.debug("Getting list of directories containing setup.py files...")
find = subprocess.run([
'find', '.', '-name', 'setup.py', '-not', '-path', './build/recipes/*'
], stdout=subprocess.PIPE)
......@@ -14,6 +18,7 @@ def get_dirs():
for i, d in enumerate(dirs_cpy):
dirs[i] = d.replace('/setup.py', '')
logger.debug("Done getting directories.")
return dirs
def get_names(dirs):
......@@ -22,6 +27,7 @@ def get_names(dirs):
subproject directory will be the name of the subproject.
:return: List of names as strings.
"""
logger.debug("Generating list of subproject names...")
names = []
for d in dirs:
if d != '':
......@@ -32,6 +38,7 @@ def get_names(dirs):
name = "services"
names.append(name)
logger.debug("Done generating.")
return names
class Recipe:
......@@ -59,7 +66,7 @@ class Recipe:
for p in pkgs:
if p not in self.pkg_list or p == '':
print("Package {} not valid. Skipping.".format(p))
logger.error(f"Package {p} not valid. Skipping.")
continue
subprocess.run(["conda", "build", "build/metadata/{}".format(p), "--output-folder", "build/pkgs/"],
stdout=subprocess.PIPE)
......
import json
import setuptools, importlib, subprocess, os, re
import subprocess
import logging
import json
import os
PYTHON_VERSION = '3.8'
logger = logging.getLogger("buildout/setup_to_meta")
def write_metafile(metadata, filepath):
"""
Writes given metadata to file with given path.
"""
logger.debug(f"Writing meta.yaml file at {filepath}...")
try:
os.makedirs(filepath[:-10])
except FileExistsError:
......@@ -15,6 +19,7 @@ def write_metafile(metadata, filepath):
with open(filepath, 'w') as f:
f.write(metadata)
logger.debug("Done writing.")
class MetadataGenerator:
......@@ -89,6 +94,7 @@ class MetadataGenerator:
return test_string
def generate(self):
logger.debug(f"Generating meta.yaml file from {self.path}...")
# Filter numpy etc. out of the requirements
try:
self.setup['install_requires'] = [req for req in self.setup['install_requires'] if req != 'numpy']
......@@ -106,7 +112,8 @@ class MetadataGenerator:
with open('build/tools/metafile_template.txt', 'r') as f:
metadata = f.read()
logger.debug("Done generating.")
return metadata.format(
name = name,
version = version,
......@@ -126,12 +133,14 @@ def parse_setup(d):
:param d: Directory with a setup.py file.
:return: Data collected from parse_setup.py.
"""
logger.debug(f"Parsing setup.py at {d}...")
subprocess.run(['cp', 'build/tools/parse_setup.py', d])
os.chdir(d)
proc = subprocess.run(['python3', 'parse_setup.py'], stdout=subprocess.PIPE)
os.chdir(root)
subprocess.run(['rm', '{}/parse_setup.py'.format(d)])
logger.debug("Done parsing.")
return json.loads(proc.stdout)
def get_outputs(names):
......@@ -151,6 +160,7 @@ def get_dirs():
Finds all subdirectories containing setup.py files.
:return: List of directories as strings.
"""
logger.debug("Finding list of directories containing setup.py files...")
find = subprocess.run([
'find', '.', '-name', 'setup.py', '-not', '-path', './build/recipes/*'
], stdout=subprocess.PIPE)
......@@ -160,6 +170,7 @@ def get_dirs():
for i, d in enumerate(dirs_cpy):
dirs[i] = d.replace('/setup.py', '')
logger.debug("Done finding directories.")
return dirs
def get_names(dirs):
......@@ -168,6 +179,7 @@ def get_names(dirs):
subproject directory will be the name of the subproject.
:return: List of names as strings.
"""
logger.debug("Getting list of names...")
names = []
for d in dirs:
if d != '':
......@@ -178,6 +190,7 @@ def get_names(dirs):
name = "services"
names.append(name)
logger.debug("Done getting list of names.")
return names
def del_substrings(s, substrings):
......@@ -213,7 +226,6 @@ class Recipe:
self.outputs = get_outputs(self.names)
self.options = options
# TODO: Keep track of path in setup_dict
def install(self):
"""
Install method that runs when recipe has components it needs to install.
......
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