Skip to content

Commit cd2e095

Browse files
committed
Fix linking
Signed-off-by: Dan Ryan <dan@danryan.co>
1 parent 3b5796e commit cd2e095

2 files changed

Lines changed: 21 additions & 23 deletions

File tree

Pipfile.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/conftest.py

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ def setup_pythons(tmpdir):
192192
os.environ["PATH"] = env_path
193193
all_versions = {}
194194
vistir.path.set_write_bit(tmpdir.strpath)
195+
pyenv_python_dir = os.path.join(pyenv_dir, "versions")
196+
asdf_python_dir = os.path.join(asdf_dir, "installs", "python")
195197
for python in itertools.chain(
196198
STACKLESS,
197199
PYPY,
@@ -204,29 +206,24 @@ def setup_pythons(tmpdir):
204206
ACTIVEPYTHON,
205207
PYTHON,
206208
):
207-
pyenv_bin = os.path.join(pyenv_dir, "versions", python, "bin")
208-
asdf_bin = os.path.join(asdf_dir, "installs", "python", python, "bin")
209-
vistir.path.mkdir_p(pyenv_bin)
210-
vistir.path.mkdir_p(asdf_bin)
211-
python_version = random.choice(["python3.7m", "python3.6m", "python2.7"])
212-
all_versions[python] = os.path.join(pyenv_bin, python_version)
213-
for exe in ["python", python_version, python]:
214-
os.link(sys.executable, os.path.join(pyenv_bin, exe))
215-
os.link(sys.executable, os.path.join(asdf_bin, exe))
216-
if os.name == "nt":
217-
os.link(
218-
os.path.join(pyenv_bin, python), os.path.join(pyenv_shim_dir, python)
219-
)
220-
os.link(
221-
os.path.join(asdf_bin, python), os.path.join(asdf_shim_dir, python)
222-
)
223-
else:
224-
os.symlink(
225-
os.path.join(pyenv_bin, python), os.path.join(pyenv_shim_dir, python)
226-
)
227-
os.symlink(
228-
os.path.join(asdf_bin, python), os.path.join(asdf_shim_dir, python)
229-
)
209+
for base_plugin_dir, shim_dir in (
210+
(pyenv_python_dir, pyenv_shim_dir),
211+
(asdf_python_dir, asdf_shim_dir),
212+
):
213+
bin_dir = os.path.join(base_plugin_dir, python, "bin")
214+
vistir.path.mkdir_p(bin_dir)
215+
vistir.path.set_write_bit(bin_dir)
216+
vistir.path.set_write_bit(base_plugin_dir)
217+
python_version = random.choice(["python3.7m", "python3.6m", "python2.7"])
218+
all_versions[python] = os.path.join(bin_dir, python_version)
219+
for exe in ["python", python_version, python]:
220+
os.link(sys.executable, os.path.join(bin_dir, exe))
221+
if os.name == "nt":
222+
vistir.compat.Path(shim_dir).joinpath(python).touch()
223+
else:
224+
os.symlink(
225+
os.path.join(bin_dir, python), os.path.join(shim_dir, python)
226+
)
230227
os.environ["PYENV_ROOT"] = pyenv_dir
231228
os.environ["ASDF_DIR"] = asdf_dir
232229
os.environ["ASDF_DATA_DIR"] = asdf_dir

0 commit comments

Comments
 (0)