Skip to content
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

Clear the cache when switching to a different package manager #1673

Closed
edmorley opened this issue Oct 30, 2024 · 0 comments · Fixed by #1679
Closed

Clear the cache when switching to a different package manager #1673

edmorley opened this issue Oct 30, 2024 · 0 comments · Fixed by #1679
Assignees
Labels

Comments

@edmorley
Copy link
Member

Currently if a build is performed using one package manager (eg Pipenv), and then a subsequent build is performed using a different package manager (eg pip), the build cache is not cleared, resulting in leftover files and packages (such as the Pipenv installation still being present).

This can be seen in these recently added tests:

context 'when the package manager has changed from Pipenv to pip since the last build' do
let(:app) { Hatchet::Runner.new('spec/fixtures/pipenv_basic') }
# TODO: Fix this case so the cache is actually cleared.
it 'clears the cache before installing with pip' do
app.deploy do |app|
FileUtils.rm(['Pipfile', 'Pipfile.lock'])
FileUtils.cp(FIXTURE_DIR.join('requirements_basic/.python-version'), '.')
FileUtils.cp(FIXTURE_DIR.join('requirements_basic/requirements.txt'), '.')
app.commit!
app.push!
expect(clean_output(app.output)).to match(Regexp.new(<<~REGEX))
remote: -----> Python app detected
remote: -----> Using Python #{DEFAULT_PYTHON_MAJOR_VERSION} specified in .python-version
remote: -----> Using cached install of Python #{DEFAULT_PYTHON_FULL_VERSION}
remote: -----> Installing pip #{PIP_VERSION}, setuptools #{SETUPTOOLS_VERSION} and wheel #{WHEEL_VERSION}
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote: -----> Discovering process types
REGEX
end
end
end

context 'when the package manager has changed from pip to Pipenv since the last build' do
let(:app) { Hatchet::Runner.new('spec/fixtures/requirements_basic') }
# TODO: Fix this case so the cache is actually cleared.
it 'clears the cache before installing with Pipenv' do
app.deploy do |app|
FileUtils.rm('.python-version')
FileUtils.rm('requirements.txt')
FileUtils.cp(FIXTURE_DIR.join('pipenv_basic/Pipfile'), '.')
FileUtils.cp(FIXTURE_DIR.join('pipenv_basic/Pipfile.lock'), '.')
app.commit!
app.push!
expect(clean_output(app.output)).to match(Regexp.new(<<~REGEX))
remote: -----> Python app detected
remote: -----> Using Python #{DEFAULT_PYTHON_MAJOR_VERSION} specified in Pipfile.lock
remote: -----> Using cached install of Python #{DEFAULT_PYTHON_FULL_VERSION}
remote: -----> Installing pip #{PIP_VERSION}, setuptools #{SETUPTOOLS_VERSION} and wheel #{WHEEL_VERSION}
remote: -----> Installing Pipenv #{PIPENV_VERSION}
remote: -----> Installing SQLite3
remote: -----> Installing dependencies with Pipenv
remote: Installing dependencies from Pipfile.lock \\(.+\\)...
remote: -----> Discovering process types
REGEX
end
end
end

Fixing this blocks adding support for Poetry in #796, since there will be a number of apps that may switch package manager to try out Poetry.

@edmorley edmorley added the bug label Oct 30, 2024
@edmorley edmorley self-assigned this Oct 30, 2024
@edmorley edmorley changed the title The cache isn't cleared if a project switches to a different package manager (eg Pipenv to pip) The cache isn't cleared when switching to a different package manager (eg Pipenv to pip) Oct 30, 2024
@edmorley edmorley changed the title The cache isn't cleared when switching to a different package manager (eg Pipenv to pip) The cache isn't cleared when switching to a different package manager Oct 30, 2024
@edmorley edmorley changed the title The cache isn't cleared when switching to a different package manager Clear the cache when switching to a different package manager Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant