Skip to content

Commit

Permalink
[develop2] symlinks round trip (#13137)
Browse files Browse the repository at this point in the history
* [develop2] symlinks round trip

* fix tests
  • Loading branch information
memsharded authored Feb 16, 2023
1 parent 4b3cba7 commit 7133154
Show file tree
Hide file tree
Showing 10 changed files with 309 additions and 655 deletions.
4 changes: 2 additions & 2 deletions conan/internal/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def full_deploy(graph, output_folder):
folder_name = os.path.join(folder_name, arch)
new_folder = os.path.join(output_folder, folder_name)
rmdir(new_folder)
shutil.copytree(dep.package_folder, new_folder)
shutil.copytree(dep.package_folder, new_folder, symlinks=True)
dep.set_deploy_folder(new_folder)


Expand All @@ -88,5 +88,5 @@ def direct_deploy(graph, output_folder):
for dep in conanfile.dependencies.filter({"direct": True}).values():
new_folder = os.path.join(output_folder, dep.ref.name)
rmdir(new_folder)
shutil.copytree(dep.package_folder, new_folder)
shutil.copytree(dep.package_folder, new_folder, symlinks=True)
dep.set_deploy_folder(new_folder)
8 changes: 3 additions & 5 deletions conans/client/cmd/uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
EXPORT_TGZ_NAME, PACKAGE_TGZ_NAME, CONANINFO)
from conans.util.files import (clean_dirty, is_dirty, gather_files,
gzopen_without_timestamps, set_dirty_context_manager, mkdir)
from conans.util.tracer import log_recipe_upload, log_compressed_files, log_package_upload

UPLOAD_POLICY_FORCE = "force-upload"
UPLOAD_POLICY_SKIP = "skip-upload"
Expand Down Expand Up @@ -233,7 +232,7 @@ def upload_recipe(self, ref, bundle, remote):
self._app.remote_manager.upload_recipe(ref, cache_files, remote)

duration = time.time() - t1
log_recipe_upload(ref, duration, cache_files, remote.name)
self._output.debug(f"Upload {ref} in {duration} time")
return ref

def upload_package(self, pref, prev_bundle, remote):
Expand All @@ -245,7 +244,7 @@ def upload_package(self, pref, prev_bundle, remote):
t1 = time.time()
self._app.remote_manager.upload_package(pref, cache_files, remote)
duration = time.time() - t1
log_package_upload(pref, duration, cache_files, remote)
self._output.debug(f"Upload {pref} in {duration} time")


def compress_files(files, name, dest_dir, compresslevel=None, ref=None):
Expand All @@ -264,6 +263,5 @@ def compress_files(files, name, dest_dir, compresslevel=None, ref=None):
tgz.close()

duration = time.time() - t1
log_compressed_files(files, duration, tgz_path)

ConanOutput().debug(f"{name} compressed in {duration} time")
return tgz_path
Empty file.
49 changes: 0 additions & 49 deletions conans/test/functional/symlinks/symlink_package_test.py

This file was deleted.

121 changes: 0 additions & 121 deletions conans/test/integration/configuration/compressed_symlinks_test.py

This file was deleted.

82 changes: 0 additions & 82 deletions conans/test/integration/configuration/skip_broken_symlinks.py

This file was deleted.

51 changes: 1 addition & 50 deletions conans/test/integration/export_sources_test.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
import os
import platform
import textwrap

import pytest

from conans.model.recipe_ref import RecipeReference
from conans.test.assets.genconanfile import GenConanfile
from conans.test.utils.test_files import temp_folder
from conans.test.utils.tools import TestClient, TurboTestClient
from conans.util.files import load, rmdir
from conans.test.utils.tools import TestClient


def test_exports():
Expand Down Expand Up @@ -75,47 +70,3 @@ def test_test_package_copied():
"test_package/foo.txt": "bar"})
client.run("export . --name foo --version 1.0")
assert "Copied 1 '.txt' file" in client.out


@pytest.mark.skipif(platform.system() == "Windows", reason="Symlinks not in Windows")
def test_exports_does_not_follow_symlink():
def absolute_existing_folder():
tmp = temp_folder()
with open(os.path.join(tmp, "source.cpp"), "a") as _f:
_f.write("foo")
return tmp

linked_abs_folder = absolute_existing_folder()
client = TurboTestClient(default_server_user=True)
conanfile = GenConanfile()\
.with_package('copy(self, "*", self.source_folder, self.package_folder)')\
.with_exports_sources("*")\
.with_import("from conan.tools.files import copy")
client.save({"conanfile.py": conanfile, "foo.txt": "bar"})
os.symlink(linked_abs_folder, os.path.join(client.current_folder, "linked_folder"))
pref = client.create(RecipeReference.loads("lib/1.0"), conanfile=False)
exports_sources_folder = client.get_latest_ref_layout(pref.ref).export_sources()
assert os.path.islink(os.path.join(exports_sources_folder, "linked_folder"))
assert os.path.exists(os.path.join(exports_sources_folder, "linked_folder", "source.cpp"))

# Check files have been copied to the build
build_folder = client.get_latest_pkg_layout(pref).build()
assert os.path.islink(os.path.join(build_folder, "linked_folder"))
assert os.path.exists(os.path.join(build_folder, "linked_folder", "source.cpp"))

# Check package files are there
package_folder = client.get_latest_pkg_layout(pref).package()
assert os.path.islink(os.path.join(package_folder, "linked_folder"))
assert os.path.exists(os.path.join(package_folder, "linked_folder", "source.cpp"))

# Check that the manifest doesn't contain the symlink nor the source.cpp
contents = load(os.path.join(package_folder, "conanmanifest.txt"))
assert "foo.txt" in contents
assert "linked_folder" not in contents
assert "source.cpp" not in contents

# Now is a broken link, but the files are not in the cache, just a broken link
rmdir(linked_abs_folder)
assert not os.path.exists(os.path.join(exports_sources_folder, "linked_folder", "source.cpp"))
assert not os.path.exists(os.path.join(build_folder, "linked_folder", "source.cpp"))
assert not os.path.exists(os.path.join(package_folder, "linked_folder", "source.cpp"))
Loading

0 comments on commit 7133154

Please sign in to comment.