Skip to content

Commit

Permalink
CI: Parse requirements to update spyder feedstock meta.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
dalthviz committed Nov 4, 2022
1 parent 3e39496 commit 0b586de
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion installers-conda/build_conda_pkgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
# Standard library imports
import os
import re
import sys
from argparse import ArgumentParser
from configparser import ConfigParser
from datetime import timedelta
Expand Down Expand Up @@ -61,6 +62,11 @@
RESOURCES = HERE / "resources"
EXTDEPS = HERE.parent / "external-deps"
SPECS = DIST / "specs.yaml"
REQUIREMENTS = HERE.parent / "requirements"
REQ_MAIN = REQUIREMENTS / 'main.yml'
REQ_WINDOWS = REQUIREMENTS / 'windows.yml'
REQ_MAC = REQUIREMENTS / 'macos.yml'
REQ_LINUX = REQUIREMENTS / 'linux.yml'

DIST.mkdir(exist_ok=True)

Expand All @@ -85,6 +91,7 @@ class BuildCondaPkg:
feedstock = None
shallow_ver = None

_yaml_yml = YAML()
_yaml = YAML(typ='jinja2')
_yaml.indent(mapping=2, sequence=4, offset=2)

Expand Down Expand Up @@ -156,7 +163,24 @@ def patch_meta(self):
self.yaml = self._yaml.load(text)

self.yaml['source'] = {'path': str(self.src_path)}


if self.name == 'spyder':
current_requirements = self._yaml_yml.load(
REQ_MAIN.read_text())['dependencies']
if os.name == 'nt':
win_requirements = self._yaml_yml.load(
REQ_WINDOWS.read_text())['dependencies']
current_requirements += win_requirements
elif sys.platform == 'darwin':
mac_requirements = self._yaml_yml.load(
REQ_MAC.read_text())['dependencies']
current_requirements += mac_requirements
else:
linux_requirements = self._yaml_yml.load(
REQ_LINUX.read_text())['dependencies']
current_requirements += linux_requirements
self.yaml['requirements']['run'] = current_requirements

self.yaml.pop('test', None)
if 'outputs' in self.yaml:
for out in self.yaml['outputs']:
Expand All @@ -166,6 +190,9 @@ def patch_meta(self):

self._yaml.dump_all([self.yaml], file)

self.logger.info("Patched 'meta.yaml'...")
self.logger.info(file.read_text())

self._patched_meta = True

def _patch_build(self):
Expand Down

0 comments on commit 0b586de

Please sign in to comment.