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

Add an option for PDM's scripts to set the current working directory #2620

Closed
madebylydia opened this issue Feb 6, 2024 · 3 comments · Fixed by #2694
Closed

Add an option for PDM's scripts to set the current working directory #2620

madebylydia opened this issue Feb 6, 2024 · 3 comments · Fixed by #2694
Assignees
Labels
⭐ enhancement Improvements for existing features

Comments

@madebylydia
Copy link

madebylydia commented Feb 6, 2024

Is your feature/enhancement proposal related to a problem? Please describe.

This issue suggest adding a new key for commands defined under tool.pdm.scripts, to set the current working directory before running the given action.

Consider the following project structure:

my_project/
├─ docs/
│  ├─ source/
│  ├─ Makefile
│  ├─ make.bat
├─ src/
│  ├─ my_package/
├─ pyproject.toml

This is a recurring structure given Sphinx's proposed setup.
There are commands that can only be ran in the docs/ directory, due to the nature of make that uses the Makefile available at the root of the current working directory.

Describe the solution you'd like

This key, which could be called cwd, or in_path, or any given suggestion, would provide an OS-agnostic way to set the current working directory.

When a command will be running, and this property is set with a relative path (In this example ./docs), PDM should come back to the root of the project (pdm info --where), so that moving in directories is seamless, and would not surprise us in case our current working directory was in src/my_package, for example.

Alternatively, this could be done by using operators like && in a shell script, but such operator (In my knowledge) could be different depending on the OS used.

Adding such key would, in my opinion, increase confidence when creating new scripts that require to move to specific directories.


I am willing to work on this issue and submit a PR.

@madebylydia madebylydia added the ⭐ enhancement Improvements for existing features label Feb 6, 2024
@frostming
Copy link
Collaborator

You can change the root of make command by -C <path> right?

@madebylydia
Copy link
Author

madebylydia commented Feb 7, 2024

This is only an example. There are other use cases that could require changing the current working directory.

Also, there's no make command on Windows, hence the existence of the .bat file.

@frostming
Copy link
Collaborator

This is only an example. There are other use cases that could require changing the current working directory.

I was not saying that is not necessary, just in case you would think it blocks your workflow.

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

Successfully merging a pull request may close this issue.

2 participants