Skip to content

Commit

Permalink
refactor signature of get_python_record
Browse files Browse the repository at this point in the history
  • Loading branch information
kalefranz committed Sep 3, 2018
1 parent 9a111fa commit 73a6f57
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 33 deletions.
2 changes: 1 addition & 1 deletion conda/core/prefix_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def _load_site_packages(self):

# Create prefix records for python packages not handled by conda
new_packages = {}
python_records = get_python_records(non_conda_anchor_files, self.prefix_path,
python_records = get_python_records(self.prefix_path, non_conda_anchor_files,
python_pkg_record.version)
for python_record in python_records:
self.__prefix_records[python_record.name] = python_record
Expand Down
6 changes: 3 additions & 3 deletions conda/core/python_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

# Main functions
# -----------------------------------------------------------------------------
def get_python_records(anchor_files, prefix_path, python_version):
def get_python_records(prefix_path, anchor_files, python_version):
"""
Process all anchor files and return a python record.
Expand All @@ -66,13 +66,13 @@ def get_python_records(anchor_files, prefix_path, python_version):
python_version = get_major_minor_version(python_version)
return tuple(
pyrec for pyrec in (
get_python_record(anchor_file, prefix_path, python_version)
get_python_record(prefix_path, anchor_file, python_version)
for anchor_file in sorted(anchor_files)
) if pyrec
)


def get_python_record(anchor_file, prefix_path, python_version):
def get_python_record(prefix_path, anchor_file, python_version):
"""
Convert a python package defined by an anchor file (Metadata information)
into a conda prefix record object.
Expand Down
20 changes: 10 additions & 10 deletions conda/core/python_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,16 @@ def evaluate(self, expr, context):
return result


def update_marker_context(python_version):
"""Update default marker context to include environment python version."""
updated_context = DEFAULT_MARKER_CONTEXT.copy()
context = {
'python_full_version': python_version,
'python_version': '.'.join(python_version.split('.')[:2]),
'extra': '',
}
updated_context.update(context)
return updated_context
# def update_marker_context(python_version):
# """Update default marker context to include environment python version."""
# updated_context = DEFAULT_MARKER_CONTEXT.copy()
# context = {
# 'python_full_version': python_version,
# 'python_version': '.'.join(python_version.split('.')[:2]),
# 'extra': '',
# }
# updated_context.update(context)
# return updated_context


def get_default_marker_context():
Expand Down
7 changes: 7 additions & 0 deletions conda/core/solve.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ def solve_for_diff(self, update_modifier=NULL, deps_modifier=NULL, prune=NULL,
unlink_precs, link_precs = diff_for_unlink_link_precs(
self.prefix, final_precs, self.specs_to_add, force_reinstall
)

# assert that all unlink_precs are manageable
unmanageable = groupby(lambda prec: prec.is_unmanageable, unlink_precs).get(True)
if unmanageable:
raise RuntimeError("Cannot unlink unmanageable packages:%s"
% dashlist(prec.record_id() for prec in unmanageable))

return unlink_precs, link_precs

def solve_final_state(self, update_modifier=NULL, deps_modifier=NULL, prune=NULL,
Expand Down
18 changes: 9 additions & 9 deletions tests/core/test_python_dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ def test_scrapy_py36_osx_whl():
prefix_path = join(ENV_METADATA_DIR, "py36-osx-whl")
if not isdir(prefix_path):
pytest.skip("test files not found: %s" % prefix_path)
prefix_recs = get_python_records(anchor_files, prefix_path, "3.6")
prefix_recs = get_python_records(prefix_path, anchor_files, "3.6")
assert len(prefix_recs) == 1
prefix_rec = prefix_recs[0]

Expand Down Expand Up @@ -879,7 +879,7 @@ def test_twilio_py36_osx_whl():
prefix_path = join(ENV_METADATA_DIR, "py36-osx-whl")
if not isdir(prefix_path):
pytest.skip("test files not found: %s" % prefix_path)
prefix_recs = get_python_records(anchor_files, prefix_path, "3.6")
prefix_recs = get_python_records(prefix_path, anchor_files, "3.6")
assert len(prefix_recs) == 1
prefix_rec = prefix_recs[0]
pprint(prefix_rec.depends)
Expand Down Expand Up @@ -935,7 +935,7 @@ def test_pyjwt_py36_osx_whl():
prefix_path = join(ENV_METADATA_DIR, "py36-osx-whl")
if not isdir(prefix_path):
pytest.skip("test files not found: %s" % prefix_path)
prefix_recs = get_python_records(anchor_files, prefix_path, "3.6")
prefix_recs = get_python_records(prefix_path, anchor_files, "3.6")
assert len(prefix_recs) == 1
prefix_rec = prefix_recs[0]

Expand Down Expand Up @@ -987,7 +987,7 @@ def test_cherrypy_py36_osx_whl():
prefix_path = join(ENV_METADATA_DIR, "py36-osx-whl")
if not isdir(prefix_path):
pytest.skip("test files not found: %s" % prefix_path)
prefix_recs = get_python_records(anchor_files, prefix_path, "3.6")
prefix_recs = get_python_records(prefix_path, anchor_files, "3.6")
assert len(prefix_recs) == 1
prefix_rec = prefix_recs[0]

Expand Down Expand Up @@ -1029,7 +1029,7 @@ def test_scrapy_py27_osx_no_binary():
prefix_path = join(ENV_METADATA_DIR, "py27-osx-no-binary")
if not isdir(prefix_path):
pytest.skip("test files not found: %s" % prefix_path)
prefix_recs = get_python_records(anchor_files, prefix_path, "2.7")
prefix_recs = get_python_records(prefix_path, anchor_files, "2.7")
assert len(prefix_recs) == 1
prefix_rec = prefix_recs[0]

Expand Down Expand Up @@ -1090,7 +1090,7 @@ def test_twilio_py27_osx_no_binary():
prefix_path = join(ENV_METADATA_DIR, "py27-osx-no-binary")
if not isdir(prefix_path):
pytest.skip("test files not found: %s" % prefix_path)
prefix_recs = get_python_records(anchor_files, prefix_path, "2.7")
prefix_recs = get_python_records(prefix_path, anchor_files, "2.7")
assert len(prefix_recs) == 1
prefix_rec = prefix_recs[0]
pprint(prefix_rec.depends)
Expand Down Expand Up @@ -1141,7 +1141,7 @@ def test_pyjwt_py27_osx_no_binary():
prefix_path = join(ENV_METADATA_DIR, "py27-osx-no-binary")
if not isdir(prefix_path):
pytest.skip("test files not found: %s" % prefix_path)
prefix_recs = get_python_records(anchor_files, prefix_path, "2.7")
prefix_recs = get_python_records(prefix_path, anchor_files, "2.7")
assert len(prefix_recs) == 1
prefix_rec = prefix_recs[0]

Expand Down Expand Up @@ -1189,7 +1189,7 @@ def test_cherrypy_py27_osx_no_binary():
prefix_path = join(ENV_METADATA_DIR, "py27-osx-no-binary")
if not isdir(prefix_path):
pytest.skip("test files not found: %s" % prefix_path)
prefix_recs = get_python_records(anchor_files, prefix_path, "2.7")
prefix_recs = get_python_records(prefix_path, anchor_files, "2.7")
assert len(prefix_recs) == 1
prefix_rec = prefix_recs[0]

Expand Down Expand Up @@ -1230,7 +1230,7 @@ def test_six_py27_osx_no_binary_unmanageable():
prefix_path = join(ENV_METADATA_DIR, "py27-osx-no-binary")
if not isdir(prefix_path):
pytest.skip("test files not found: %s" % prefix_path)
prefix_recs = get_python_records(anchor_files, prefix_path, "2.7")
prefix_recs = get_python_records(prefix_path, anchor_files, "2.7")
assert len(prefix_recs) == 1
prefix_rec = prefix_recs[0]

Expand Down
9 changes: 0 additions & 9 deletions tests/core/test_python_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,6 @@ def test_evaluate_marker():
output = pm.interpret(marker_expr, context)


def test_update_marker_context():
pyver = '2.8.1'
context = pd.update_marker_context(pyver)
_print_output(pyver, context)
assert context['extra'] == ''
assert context['python_version'] == '.'.join(pyver.split('.')[:2])
assert context['python_full_version'] == pyver


def test_get_default_marker_context():
context = pm.get_default_marker_context()
for key, val in context.items():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def test_get_reduced_index_unmanageable():
channels = r.channels
prefix_path = join(TEST_DATA_DIR, "env_metadata", "envpy27osx")
anchor_file = "lib/python2.7/site-packages/requests-2.19.1-py2.7.egg/EGG-INFO/PKG-INFO"
py_rec = get_python_record(anchor_file, prefix_path, "2.7")
py_rec = get_python_record(prefix_path, anchor_file, "2.7")
assert py_rec.package_type == PackageType.VIRTUAL_PYTHON_EGG_UNMANAGEABLE

index[py_rec] = py_rec
Expand Down

0 comments on commit 73a6f57

Please sign in to comment.