Skip to content

Commit

Permalink
Add copytree_compat method (#15906)
Browse files Browse the repository at this point in the history
* add compat function

* test py3.12 on unit and integration

* add test

* pull image
  • Loading branch information
czoido authored Mar 20, 2024
1 parent 906146f commit f416a7e
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
4 changes: 4 additions & 0 deletions .ci/jenkins/testsv2.jenkins
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ String getTempFolder(String nodeName) {
List<Map> getConfigurations(String moduleName, String branchName, String jobName) {
// TODO: handle revision cases
def configs = []
if (moduleName=="conans/test/unittests" || moduleName=="conans/test/integration") {
configs.add([node: "Linux", pyvers: ["PY312"]])
}
if (branchName =~ /(^PR-.*)/) {
configs.add([node: "Linux", pyvers: ["PY36"]])
configs.add([node: "Windows", pyvers: ["PY36"]])
Expand Down Expand Up @@ -89,6 +92,7 @@ private Closure runTests(String nodeName, String pythonVersion, String module) {
if (nodeName=="Linux") {
try {
def dockerImage = getDockerImage(module)
docker.image(dockerImage).pull()
docker.image(dockerImage).inside("--entrypoint=") {

// we only test scons in Linux
Expand Down
2 changes: 1 addition & 1 deletion conans/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
REVISIONS = "revisions" # Only when enabled in config, not by default look at server_launcher.py
OAUTH_TOKEN = "oauth_token"

__version__ = '2.2.0'
__version__ = '2.2.1'
5 changes: 2 additions & 3 deletions conans/client/rest_client_local_recipe_index.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import sys
import textwrap
from distutils.dir_util import copy_tree
from fnmatch import fnmatch
from io import StringIO

Expand All @@ -14,7 +13,7 @@
from conans.errors import ConanException, PackageNotFoundException, RecipeNotFoundException
from conans.model.conf import ConfDefinition
from conans.model.recipe_ref import RecipeReference
from conans.util.files import load, save, rmdir
from conans.util.files import load, save, rmdir, copytree_compat


def add_local_recipes_index_remote(conan_api, remote):
Expand Down Expand Up @@ -160,7 +159,7 @@ def _export_recipe(self, ref):
def _copy_files(source_folder, dest_folder):
if not os.path.exists(source_folder):
return {}
copy_tree(source_folder, dest_folder)
copytree_compat(source_folder, dest_folder)
ret = {}
for root, _, _files in os.walk(dest_folder):
for _f in _files:
Expand Down
20 changes: 20 additions & 0 deletions conans/test/unittests/util/files/test_copy_compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import pytest

from conans.util.files import copytree_compat


@pytest.fixture
def source_dest_folders(tmp_path):
source_folder = tmp_path / "source"
dest_folder = tmp_path / "dest"
source_folder.mkdir()
dest_folder.mkdir()
test_file = source_folder / "test_file.txt"
test_file.write_text("Test content")
return source_folder, dest_folder


def test_copytree_compat(source_dest_folders):
source_folder, dest_folder = source_dest_folders
copytree_compat(str(source_folder), str(dest_folder))
assert (dest_folder / "test_file.txt").exists()
10 changes: 10 additions & 0 deletions conans/util/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import platform
import shutil
import stat
import sys
import tarfile
import time

Expand Down Expand Up @@ -373,3 +374,12 @@ def human_size(size_bytes):
formatted_size = str(round(num, ndigits=the_precision))

return "%s%s" % (formatted_size, the_suffix)


# FIXME: completely remove disutils once we don't support <3.8 any more
def copytree_compat(source_folder, dest_folder):
if sys.version_info >= (3, 8):
shutil.copytree(source_folder, dest_folder, dirs_exist_ok=True)
else:
from distutils.dir_util import copy_tree
copy_tree(source_folder, dest_folder)

0 comments on commit f416a7e

Please sign in to comment.