Skip to content

cosalib/build: Use workdir tmp/ as tempdir #1097

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

Merged
merged 1 commit into from
Feb 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/cosalib/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,12 @@ def __init__(self, *args, **kwargs):

self._found_files = {}
self._workdir = kwargs.pop("workdir", os.getcwd())
self._tmpdir = tempfile.mkdtemp(prefix="build_tmpd")
tmpdir = os.path.join(self._workdir, "tmp")
os.environ['TMPDIR'] = tmpdir
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't new, but... rust-lang/rust#24741

AFAIK cosa isn't multi-threaded today, but it's just a time bomb to be mutating the environment. We can fix as a follow-up.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we should probably just set it in the entrypoint instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I think it's trickier than that since the entrypoint has no notion of workdir. So yeah, let's do that as a follow-up!


# we need to make sure we allocate in tmp/ so we're on the same
# filesystem as builds/ and we can just `rename()` it there
self._tmpdir = tempfile.mkdtemp(dir=tmpdir)
self._image_name = None

# Setup the instance properties.
Expand All @@ -108,7 +113,6 @@ def __init__(self, *args, **kwargs):
}

os.environ['workdir'] = self._workdir
os.environ['TMPDIR'] = os.path.join(self._workdir, "tmp")

# Setup what is required for this Class.
# require_cosa means that the COSA information is need
Expand Down