diff --git a/src/ape/managers/project.py b/src/ape/managers/project.py index e4ea3b0b85..a437743970 100644 --- a/src/ape/managers/project.py +++ b/src/ape/managers/project.py @@ -774,12 +774,19 @@ def _unpack(self, path: Path, tracked: set[str]) -> Iterator["Dependency"]: if not folder.is_dir(): # Not yet unpacked. - contracts_folder_id = get_relative_path( - self.project.contracts_folder, self.project.path - ) - destination = folder / contracts_folder_id - destination.parent.mkdir(parents=True, exist_ok=True) - shutil.copytree(self.project.contracts_folder, destination) + if isinstance(self.project, LocalProject): + contracts_folder_id = get_relative_path( + self.project.contracts_folder, self.project.path + ) + destination = folder / contracts_folder_id + destination.parent.mkdir(parents=True, exist_ok=True) + if self.project.contracts_folder.is_dir(): + shutil.copytree(self.project.contracts_folder, destination) + + else: + # Will create contracts folder from source IDs. + folder.parent.mkdir(parents=True, exist_ok=True) + self.project.manifest.unpack_sources(folder) # self is done! yield self diff --git a/src/ape_pm/projects.py b/src/ape_pm/projects.py index 3159235c37..9c6dd652e8 100644 --- a/src/ape_pm/projects.py +++ b/src/ape_pm/projects.py @@ -149,7 +149,7 @@ def extract_config(self, **overrides) -> "ApeConfig": # Handle root project configuration. # NOTE: The default contracts folder name is `src` in foundry # instead of `contracts`, hence the default. - ape_cfg["contracts_folder"] = root_data.get("src", "src") + ape_cfg["contracts_folder"] = root_data.get("src") # Used for seeing which remappings are comings from dependencies. lib_paths = root_data.get("libs", ("lib",)) @@ -173,6 +173,9 @@ def extract_config(self, **overrides) -> "ApeConfig": solidity_data["optimize"] = root_data["optimizer"] if runs := solidity_data.get("optimizer_runs"): solidity_data["optimization_runs"] = runs + if evm_version := root_data.get("evm_version"): + solidity_data["evm_version"] = evm_version + if soldata := solidity_data: ape_cfg["solidity"] = soldata diff --git a/tests/functional/test_dependencies.py b/tests/functional/test_dependencies.py index 036010b1ee..f9bcd1ed92 100644 --- a/tests/functional/test_dependencies.py +++ b/tests/functional/test_dependencies.py @@ -262,9 +262,17 @@ def test_unpack(project_with_downloaded_dependencies): def test_unpack_dependencies_of_dependencies(project, with_dependencies_project_path): dep = project.dependencies.install(local=with_dependencies_project_path, name="wdep") with create_tempdir() as tempdir: - dep.unpack(tempdir) + list(dep.unpack(tempdir)) + subdirs = [x.name for x in tempdir.iterdir() if x.is_dir()] + assert "sub-dependency" in subdirs - # TODO: Check for dependency of dependency! + +def test_unpack_no_contracts_folder(project, with_dependencies_project_path): + dep = project.dependencies.install(local=with_dependencies_project_path, name="wdep") + with create_tempdir() as tempdir: + list(dep.unpack(tempdir)) + subdirs = [x.name for x in tempdir.iterdir() if x.is_dir()] + assert "empty-dependency" in subdirs class TestPackagesCache: diff --git a/tests/functional/test_project.py b/tests/functional/test_project.py index a891d8eb5e..731163fbd8 100644 --- a/tests/functional/test_project.py +++ b/tests/functional/test_project.py @@ -582,6 +582,7 @@ def toml(self): out = 'out' libs = ['lib'] solc = "0.8.18" +evm_version = 'cancun' remappings = [ 'forge-std/=lib/forge-std/src/', @@ -630,6 +631,7 @@ def test_extract_config(self, toml, gitmodules, mock_github): "@openzeppelin/=openzeppelin-contracts/", ] assert actual_sol["version"] == "0.8.18" + assert actual_sol["evm_version"] == "cancun" # Ensure dependencies migrated from .gitmodules. assert "dependencies" in actual, "Dependencies failed to migrate" diff --git a/tests/integration/cli/projects/with-dependencies/ape-config.yaml b/tests/integration/cli/projects/with-dependencies/ape-config.yaml index 98aa93ea92..3e597fe8c4 100644 --- a/tests/integration/cli/projects/with-dependencies/ape-config.yaml +++ b/tests/integration/cli/projects/with-dependencies/ape-config.yaml @@ -20,3 +20,6 @@ dependencies: - name: manifest-dependency local: ./manifest_dependency.json + + - name: empty-dependency + local: ./empty_dependency diff --git a/tests/integration/cli/projects/with-dependencies/empty_dependency/README.md b/tests/integration/cli/projects/with-dependencies/empty_dependency/README.md new file mode 100644 index 0000000000..5df0bb166d --- /dev/null +++ b/tests/integration/cli/projects/with-dependencies/empty_dependency/README.md @@ -0,0 +1 @@ +# For testing anything with a dependency with no contracts.