setup-python icon indicating copy to clipboard operation
setup-python copied to clipboard

Cache doesn't work when the project is not in the root of the repository.

Open atayardimci opened this issue 3 years ago • 12 comments

Description: Add an input to the action (working-directory or project-directory) to specify the path to the project, where the pyproject.toml file is located. Use this directory to look for the pyproject.toml and cached deps.

Justification: Caching doesn't work for projects where the project is not in the root of the repository.

atayardimci avatar Aug 05 '22 17:08 atayardimci

Hi, @atayardimci 👋 Thank you for the feature request, we will take a look at it and get back to you with updates.

IvanZosimov avatar Aug 08 '22 08:08 IvanZosimov

I've been workarounding it as follows for now

-      - uses: actions/setup-python@v4
-        with:
-          python-version: 3.9
-          cache: poetry
-          cache-dependency-path: foo/poetry.lock
-      - run: poetry install

+      - uses: actions/cache@v3
+        with:
+          path: /home/runner/.cache/pypoetry/virtualenvs
+          key: hashFiles('foo/poetry.lock')

I hope this feature request be integrated into setup-python : )

dongho-jung avatar Aug 22 '22 03:08 dongho-jung

Hello @atayardimci. Sorry for the late response. Could you please try to specify cache-dependency-path with the path to pyproject.toml ?

dmitry-shibanov avatar Oct 03 '22 09:10 dmitry-shibanov

Hi @dmitry-shibanov. I had already tried that, but it didn't work as expected.

atayardimci avatar Oct 03 '22 13:10 atayardimci

Hello @atayardimci. Could you please provide a public repository to reproduce the issue ?

dmitry-shibanov avatar Oct 03 '22 20:10 dmitry-shibanov

@dmitry-shibanov you can find an example with a poetry.lock in https://github.com/mdn/yari/pull/7236

nschonni avatar Oct 03 '22 21:10 nschonni

I have a totally same issue because using monorepo. My root is not the root of the project.

stalkerg avatar Oct 24 '22 08:10 stalkerg

Same issue!

jbacon-cfs avatar Nov 29 '22 21:11 jbacon-cfs

Hello everyone! We've released v4.5.0 action version. Could you please try using it and check that everything is working as expected and the issue is fixed?

MaksimZhukov avatar Jan 12 '23 13:01 MaksimZhukov

I am closing the issue, since the new release should fix it. Please let us know if you are still facing this issue. Thanks!

MaksimZhukov avatar Feb 06 '23 13:02 MaksimZhukov

@MaksimZhukov seems like still not fixed because we can't specify working-directory or project-directory. If you have monorepo with 20 different projects, have no sense to run find by **/poetry.lock pattern. Basically, you are solving a different issue - you have one project but not at the root. This issue is about - in your root folder you have multiple projects and you should pick up one.

Base on this PR https://github.com/actions/setup-python/pull/447

stalkerg avatar Feb 07 '23 03:02 stalkerg

Any progress?

stalkerg avatar Mar 30 '23 01:03 stalkerg

Hello Everyone, We’ve raised PR #1128 to address the above request. Please validate it against the requirement that caching should work when the project is not located at the root of the repository, and confirm to proceed further. Feel free to reach out if you have any questions or need further clarification.

aparnajyothi-y avatar Jun 12 '25 05:06 aparnajyothi-y

Hello Everyone, Just a quick reminder — we’ve raised PR #1128 to address the above request. Please validate it against the requirement that caching should work when the project is not located at the root of the repository, and confirm if we can proceed further. Feel free to reach out if you have any questions or need additional clarification.

aparnajyothi-y avatar Jun 17 '25 05:06 aparnajyothi-y

Hello Everyone, The issue regarding cache not working when the project is not located at the root of the repository has been addressed and resolved through PR #1128, which has now been merged into main.

With this update, caching behavior should now work when the project is not in the root of the repository hence closing this issue. Please feel free reach us in case of any concerns / clarifications needed.

aparnajyothi-y avatar Jul 03 '25 07:07 aparnajyothi-y

Hi everyone, Following up on this discussion and the recent implementation in PR #1128:

After further review and discussion, we’ve decided to revert PR #1128. In that implementation, a file was copied from the composite action into the main workspace at a repository level. This was initially intended to support composite actions in setup-python and provided valuable insight into how such scenarios could be addressed.

Moving forward, we’ll be implementing this capability at the toolkit level, as tracked in actions/toolkit#1035 . This will allow us to provide consistent support for composite actions in a secure and scalable way, while also unblocking hashFiles path handling at its root.

aparnajyothi-y avatar Aug 22 '25 04:08 aparnajyothi-y