Skip to content

Commit

Permalink
Refactoring use souschef (#273)
Browse files Browse the repository at this point in the history
* add souschef to grayskull and small improvements

* add python 3.10 to the supported python version

* Refactoring to improve modularity

 - Remove inheritance
 - Using conda-souschef to deal with recipe/yaml

* update licence

* drop support for python 3.6 and add tests for python 3.10
  • Loading branch information
marcelotrevisani authored Jan 15, 2022
1 parent 9616ddc commit 04d046a
Show file tree
Hide file tree
Showing 35 changed files with 1,815 additions and 2,430 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
py_ver: ["3.7", "3.8", "3.9"]
py_ver: ["3.8", "3.9", "3.10"]
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.py_ver }}
Expand Down
13 changes: 6 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
repos:
- repo: https://github.com/psf/black
rev: 19.10b0
rev: 21.12b0
hooks:
- id: black
args: [--safe, --quiet]
- repo: https://github.com/asottile/blacken-docs
rev: v1.7.0
rev: v1.12.0
hooks:
- id: blacken-docs
additional_dependencies: [black==19.10b0]
additional_dependencies: [black==21.12b0]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
rev: v4.1.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -28,12 +28,12 @@ repos:
- id: debug-statements
language_version: python3
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.2.2
rev: v5.10.1
hooks:
- id: isort
exclude: tests/data
- repo: https://gitlab.com/pycqa/flake8
rev: 3.8.3
rev: 3.9.2
hooks:
- id: flake8
exclude: tests/data
Expand All @@ -42,4 +42,3 @@ repos:
- flake8-typing-imports==1.9.0
- flake8-builtins==1.5.3
- flake8-bugbear==20.1.4
- flake8-isort==3.0.1
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2020 Marcelo Duarte Trevisani
Copyright 2022` Marcelo Duarte Trevisani

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
9 changes: 6 additions & 3 deletions environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,24 @@ channels:
- conda-forge
- defaults
dependencies:
- python >=3.8
- pytest
- pytest-cov
- pytest-xdist
- pytest-forked
- requests
- ruamel.yaml>=0.16.10
- ruamel.yaml >=0.16.10
- ruamel.yaml.jinja2
- stdlib-list
- pip
- setuptools>=30.3.0
- rapidfuzz>=0.7.6,<0.13.0
- setuptools >=30.3.0
- rapidfuzz >=1.9.1
- progressbar2>=3.53.0
- colorama
- mock
- pytest-console-scripts
- numpy
- compilers
- fortran-compiler
- conda-souschef >=2.1.0
- setuptools-scm
31 changes: 22 additions & 9 deletions grayskull/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
from grayskull.cli import CLIConfig
from grayskull.cli.parser import parse_pkg_name_version
from grayskull.cli.stdout import print_msg
from grayskull.utils import origin_is_github
from grayskull.config import Configuration
from grayskull.utils import generate_recipe, origin_is_github

init(autoreset=True)
logging.basicConfig(format="%(levelname)s:%(message)s")
Expand Down Expand Up @@ -118,24 +119,36 @@ def main(args=None):
f"#### Initializing recipe for "
f"{Fore.BLUE}{pkg_name}{pypi_label} {Fore.GREEN}####\n"
)
pkg_name, pkg_version = parse_pkg_name_version(pkg_name)
try:
recipe = GrayskullFactory.create_recipe(
"pypi",
pkg_name,
pkg_version,
download=args.download,
is_strict_cf=args.is_strict_conda_forge,
recipe, config = create_python_recipe(
pkg_name, args.is_strict_conda_forge, args.download
)
except requests.exceptions.HTTPError as err:
print_msg(f"{Fore.RED}Package seems to be missing.\nException: {err}\n\n")
continue
recipe.generate_recipe(args.output, maintainers=args.maintainers)

if "extra" in recipe:
recipe["extra"]["recipe-maintainers"] = args.maintainers
else:
recipe.add_section({"extra": {"recipe-maintainers": args.maintainers}})

generate_recipe(recipe, config, args.output)
print_msg(
f"\n{Fore.GREEN}#### Recipe generated on "
f"{os.path.realpath(args.output)} for {pkg_name} ####\n"
)


def create_python_recipe(pkg_name, is_strict_conda_forge=True, download=False):
pkg_origin, pkg_name, pkg_version = parse_pkg_name_version(pkg_name)
config = Configuration(
name=pkg_name,
version=pkg_version,
is_strict_cf=is_strict_conda_forge,
download=download,
)
return GrayskullFactory.create_recipe("pypi", config, pkg_name), config


if __name__ == "__main__":
main(sys.argv[1:])
253 changes: 0 additions & 253 deletions grayskull/base/base_recipe.py

This file was deleted.

Loading

0 comments on commit 04d046a

Please sign in to comment.