Skip to content

plugin: don't try to copy file onto itself #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hydrargyrum
Copy link

If the command generates the artifact in the right place, there's no need to copy it to out directory

Closes #8

Issues

#8

Summary

If the command generates the artifact in the right place, there's no need to copy it to out directory

If the command generates the artifact in the right place, there's no
need to copy it to out directory

Closes rmorshea#8
@hydrargyrum
Copy link
Author

doesn't seem to be the right fix

@hydrargyrum
Copy link
Author

i tried to test it like this:

diff --git tests/test_plugin.py tests/test_plugin.py
index deafd9d..0f3066e 100644
--- tests/test_plugin.py
+++ tests/test_plugin.py
@@ -1,9 +1,12 @@
+import pytest
+
 from hatch_build_scripts.plugin import OneScriptConfig
 
 from .utils import create_project
 
 
-def test_plugin(tmpdir):
[email protected]("out_dir", ["fake", "."])
+def test_plugin(tmpdir, out_dir):
     tmp_lib_dir = tmpdir / "lib"
     tmp_lib_dir.mkdir()
 
@@ -26,7 +29,7 @@ def test_plugin(tmpdir):
         tmp_lib_dir,
         [
             OneScriptConfig(
-                out_dir="fake",
+                out_dir=out_dir,
                 commands=["echo 'hello world' > fake.txt"],
                 artifacts=["fake.txt"],
             ),
@@ -61,7 +64,8 @@ def test_plugin(tmpdir):
     with proj.dist() as dist:
         dist.extractall(extract_dir)
 
-        assert (extract_dir / "fake" / "fake.txt").exists()
+        assert (extract_dir / out_dir / "fake.txt").exists()
         assert (extract_dir / "some-dir-out" / "module.py").exists()
 
         assert not (extract_dir / "some-dir-out" / "f3.txt").exists()

but the test fails as the fake.txt is not copied into extract_dir. But this is not caused by the change i made in plugin.py, this is because out_dir is . and plugin.py does

build_data["artifacts"].append(str(out_dir.relative_to(self.root)))

which only marks directories in build_data["artifacts"]. Don't know for sure but it seems wrong:

  • why not just using the artifacts list from pyproject.toml?
  • if using . as out_dir is not a good idea, why is it the default value?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

option not to copy files
1 participant