Skip to content

Commit

Permalink
refactor prefix/name parsing (#9)
Browse files Browse the repository at this point in the history
* refactor prefix and name parsing
to use current env if no option is explicitly set

* modify meta.yaml for local building/testing
  • Loading branch information
rvalieris authored Dec 5, 2019
1 parent 216d2b1 commit d7a98bd
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 26 deletions.
29 changes: 16 additions & 13 deletions conda-tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import conda.exports
import networkx

__version__ = '0.0.5'
__version__ = '0.1.0'

# The number of spaces
INIT_TABSIZE = 3
Expand Down Expand Up @@ -192,21 +192,24 @@ def main():

args = parser.parse_args()

if args.name is not None:
# Allow user to specify name, but check the environment for an
# existing CONDA_EXE command. This allows a different conda
# package to be installed (and imported above) but will
# resolve the name using their expected conda. (The imported
# conda here will find the environments, but might not name
# them as the user expects.)
# Allow user to specify name, but check the environment for an
# existing CONDA_EXE command. This allows a different conda
# package to be installed (and imported above) but will
# resolve the name using their expected conda. (The imported
# conda here will find the environments, but might not name
# them as the user expects.)
if args.prefix is None:
_conda = os.environ.get('CONDA_EXE', 'conda')
_info = json.loads(subprocess.check_output(
[_conda, 'info', '-e', '--json']))
args.prefix = conda.base.context.locate_prefix_by_name(
name=args.name, envs_dirs=_info['envs_dirs'])

if args.prefix is None:
args.prefix = sys.prefix
if args.name is None:
if _info['active_prefix'] is not None:
args.prefix = _info['active_prefix']
else:
args.prefix = _info['default_prefix']
else:
args.prefix = conda.base.context.locate_prefix_by_name(
name=args.name, envs_dirs=_info['envs_dirs'])

l = get_local_cache(args.prefix)
g = make_cache_graph(l)
Expand Down
30 changes: 18 additions & 12 deletions meta.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,41 @@
# this recipe is for local building
# see https://github.com/conda-forge/conda-tree-feedstock/blob/master/recipe/meta.yaml
# for the conda-forge recipe

package:
name: conda-tree
version: "0.0.5"
version: dev

source:
git_url: https://github.com/rvalieris/conda-tree.git
git_rev: v0.0.5
path: .

build:
number: 0
noarch: python
script:
- "{{ PYTHON }} -m pip install . --no-deps -vv"
entry_points:
- conda-tree = conda_tree:main

requirements:
host:
- python
- pip
- setuptools

run:
- python
- networkx
- conda

build:
number: 0
noarch: generic
script:
- "{{ PYTHON }} -m pip install . --no-deps -vv"
entry_points:
- conda-tree = conda_tree:main

test:
commands:
- conda-tree -h

about:
home: https://github.com/rvalieris/conda-tree
license: MIT
license_family: MIT
license_file: LICENSE
summary: 'conda dependency tree helper'
dev_url: https://github.com/rvalieris/conda-tree
doc_url: https://github.com/rvalieris/conda-tree
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
shutil.copyfile('conda-tree.py', 'conda_tree.py')

setup(name='conda-tree',
version='0.0.5',
version='0.1.0',
description='conda dependency tree helper',
author='Renan Valieris',
url='https://github.com/rvalieris/conda-tree',
Expand Down

0 comments on commit d7a98bd

Please sign in to comment.