wntrblm / nox

Flexible test automation for Python
https://nox.thea.codes
Apache License 2.0
1.3k stars 148 forks source link

Wrong starting directory when noxfile.py is a symlink #828

Open rsyring opened 3 months ago

rsyring commented 3 months ago

I have a project where I want the noxfille to be a symlink to a different shared file. When I do this, it throws off the paths b/c nox follows the symlink and starts in that directory instead of starting in the directory where the symlink is.

 ❯ ls -l noxfile.py 
lrwxrwxrwx 1 rsyring rsyring 21 May 15 23:09 noxfile.py -> ./template/noxfile.py

 ❯ nox -s cwd
nox > Running session cwd
nox > Creating virtual environment (uv) using python3 in .nox/cwd
cwd is: /home/rsyring/projects/copier-py-package/template

Was this an intentional design decision? If not, how about starting where the symlink is instead (i.e. don't follow it)?

Thanks for your work on this project and consideration.

cjolowicz commented 3 months ago

Thanks, PR welcome. Take a look in load_nox_module in tasks.py.

henryiii commented 3 months ago

That happens here: https://github.com/wntrblm/nox/blob/a6e1a4efaeea3d67dd2c47b80b9b8836a4aa579a/nox/tasks.py#L86

The one below is fine (takes the global path of the dir), maybe it should just use that and reassemble the name.

jamesharris-garmin commented 3 months ago

I actually use this behavior with the repo tool to symlink a nox-file into the root of of my repo client clone directory and expect that the sessions I reference occur in a sub directory. It probably isn't a huge deal if you modify this behavior (I can also make it symlink the folders/change the paths.) but I thought I should note that there is someone out here who uses this behavior.