Skip to content

Commit

Permalink
Merge #31
Browse files Browse the repository at this point in the history
31: Add 'bork run' command. r=duckinator a=duckinator

Closes #30.

Co-authored-by: Ellen Marie Dash <me@duckie.co>
  • Loading branch information
bors[bot] and duckinator committed Sep 25, 2019
2 parents 937a777 + a04f6fe commit e0691d2
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 25 deletions.
4 changes: 2 additions & 2 deletions .cirrus.yml
Expand Up @@ -6,12 +6,12 @@ Lint_task:
container:
image: python:3.7-slim
install_script:
- pip install .
- pip install .[linting]
script:
- flake8 --version
- flake8
- pylint --version
- pylint bork
- bork run lint

# Linux_task:
# allow_failures: $CIRRUS_TASK_NAME =~ '.*-rc-.*'
Expand Down
31 changes: 20 additions & 11 deletions bork/__init__.py
@@ -1,9 +1,12 @@
import os
from pathlib import Path
import sys
import toml

from . import builder
from . import github
from . import pypi
from .filesystem import load_setup_cfg, try_delete
from .filesystem import try_delete


DOWNLOAD_SOURCES = {
Expand All @@ -15,16 +18,10 @@


def build():
config = load_setup_cfg()
if 'bork' in config:
config = config['bork']

if 'zipapp' in config:
want_zipapp = config['zipapp'].lower() == 'true'
else:
want_zipapp = 'zipapp_main' in config
else:
want_zipapp = False
pyproject = toml.load('pyproject.toml')
config = pyproject.get('tool', {}).get('bork', {})
zipapp = config.get('zipapp', {})
want_zipapp = zipapp.get('enabled', False)

builder.dist()

Expand Down Expand Up @@ -68,3 +65,15 @@ def release(test_pypi, dry_run):

# if 'github' in args:
# github.upload('./dist/*.pyz', dry_run=dry_run)


def run(alias):
pyproject = toml.load('pyproject.toml')
config = pyproject.get('tool', {}).get('bork', {})
aliases = config.get('aliases', {})

if alias not in aliases.keys():
sys.exit('bork: no such alias: {}'.format(alias))

command = aliases[alias]
os.system(command)
7 changes: 7 additions & 0 deletions bork/cli.py
Expand Up @@ -6,6 +6,7 @@
from . import clean as _clean
from . import download as _download
from . import release as _release
from . import run as _run
from . import DOWNLOAD_SOURCES


Expand Down Expand Up @@ -57,6 +58,12 @@ def release(test_pypi, dry_run):
_release(test_pypi, dry_run)


@cli.command()
@click.argument('alias', nargs=1)
def run(alias):
_run(alias)


def main():
verbose = '--verbose' in sys.argv
if verbose:
Expand Down
11 changes: 11 additions & 0 deletions pyproject.toml
Expand Up @@ -2,3 +2,14 @@
# Specify the required build system.
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"

[tool.bork.zipapp]
# bork can not build a functional zipapp of itself yet.
enabled = false
main = "bork.cli:main"

[tool.bork.aliases]
# Runs *only* pylint and flake8. (Not the actual tests.)
lint = "pytest -k 'flake8 or pylint' --pylint --flake8 --verbose"
# Runs tests, pylint, and flake8.
test = "pytest --pylint --flake8 --verbose"
17 changes: 5 additions & 12 deletions setup.cfg
@@ -1,7 +1,3 @@
[aliases]
# test = pytest + pylint + flake8.
test = pytest --addopts '--pylint --flake8 --verbose'

[metadata]
name = bork
version = 0.1.0
Expand All @@ -26,14 +22,13 @@ packages = find:
python_requires = >=3.5

install_requires =
toml~=0.10.0
pep517==0.5.0
twine==2.0.0
click~=7.0

tests_require =
bork[linting,testing]
pytest-flake8
pytest-pylint==2.4.1
bork[linting,testing]

[options.extras_require]
linting =
Expand All @@ -46,7 +41,9 @@ linting =
pylint==2.4.1

testing =
pytest==5.1.3
pytest~=5.1.0
pytest-flake8
pytest-pylint~=0.14.0

[options.entry_points]
console_scripts =
Expand All @@ -63,7 +60,3 @@ exclude =
build,
dist,
venv

#[bork]
#zipapp = True
#zipapp_main = bork.cli:main

0 comments on commit e0691d2

Please sign in to comment.