Skip to content

Commit

Permalink
black and isort
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusvniekerk committed Dec 19, 2019
1 parent 85594a0 commit 3c78088
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 43 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.cache/
.coverage
.idea/
.mypy_cache/
.vscode/
condax.egg-info/
build/
Expand Down
11 changes: 8 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
repos:
- repo: https://github.com/pre-commit/mirrors-isort
rev: master
rev: v4.3.21
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: stable
rev: 19.10b0
hooks:
- id: black
language_version: python3.6
language_version: python3.6

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.760
hooks:
- id: mypy
7 changes: 4 additions & 3 deletions condax/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
def cli():
pass


@cli.command()
@click.argument('package')
@click.argument("package")
def install(package):
core.install_package(package)


if __name__ == '__main__':
cli()
if __name__ == "__main__":
cli()
47 changes: 26 additions & 21 deletions condax/conda.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import glob
import json
import logging
import os
import platform
import shutil
import stat
import subprocess
import glob
import json

import requests

Expand Down Expand Up @@ -52,39 +52,44 @@ def ensure_dest_prefix():
def create_conda_environment(package):
conda_exe = ensure_conda()

subprocess.check_call([
conda_exe, 'create',
'--prefix', f'{CONDA_ENV_PREFIX_PATH}/{package}',
'--override-channels',
# TODO: allow configuring this
'--channel', 'conda-forge',
'--channel', 'defaults',
'--quiet',
package
])
subprocess.check_call(
[
conda_exe,
"create",
"--prefix",
f"{CONDA_ENV_PREFIX_PATH}/{package}",
"--override-channels",
# TODO: allow configuring this
"--channel",
"conda-forge",
"--channel",
"defaults",
"--quiet",
package,
]
)


def detemine_executables_from_env(package):
env_prefix = f"{CONDA_ENV_PREFIX_PATH}/{package}"

for file_name in glob.glob(f"{env_prefix}/conda-meta/{package}*.json"):
with open(file_name, 'r') as fo:
with open(file_name, "r") as fo:
package_info = json.load(fo)
if package_info["name"] == package:
potential_executables = [fn for fn in package_info["files"] if fn.startswith('bin/') or fn.startswith('sbin/')]
potential_executables = [
fn
for fn in package_info["files"]
if fn.startswith("bin/") or fn.startswith("sbin/")
]
break
else:
raise ValueError("Could not determine package files")

executables = []
for fn in potential_executables:
abs_executable_path = f'{env_prefix}/{fn}'
abs_executable_path = f"{env_prefix}/{fn}"
if os.access(abs_executable_path, os.X_OK):
executables.append(abs_executable_path)

return executables





return executables
2 changes: 1 addition & 1 deletion condax/config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import os

CONDA_ENV_PREFIX_PATH = os.path.expanduser("~/.condax")
CONDAX_LINK_DESTINATION = os.path.expanduser("~/.local/bin")
CONDAX_LINK_DESTINATION = os.path.expanduser("~/.local/bin")
8 changes: 1 addition & 7 deletions condax/core.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import os

from .conda import create_conda_environment, detemine_executables_from_env
from .config import CONDAX_LINK_DESTINATION
from .conda import (
create_conda_environment,
detemine_executables_from_env,
)


def install_package(package):
Expand All @@ -13,6 +10,3 @@ def install_package(package):
for exe in executables_to_link:
executable_name = os.path.basename(exe)
os.symlink(exe, f"{CONDAX_LINK_DESTINATION}/{executable_name}")



6 changes: 1 addition & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,5 @@
install_requires=REQUIRES,
tests_require=["coverage", "pytest"],
packages=find_packages(exclude=("tests", "tests.*")),
entry_points={
'console_scipts': [
'condax = condax.cli:cli'
]
},
entry_points={"console_scipts": ["condax = condax.cli:cli"]},
)
5 changes: 2 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[tox]
envlist =
py27,
py35,
py36,
pypy,
py37,
py38,
pypy3,

[testenv]
Expand Down

0 comments on commit 3c78088

Please sign in to comment.