Skip to content

feat: Support custom package root #226

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

chiora93
Copy link

@chiora93 chiora93 commented Aug 4, 2025

Allow tov-uv to recognize properly a custom package root if any, without enforcing to have pyproject.toml in the same directory of tox.ini

Address issue #220

Allow tov-uv to recognize properly a custom package root if any, without enforcing to have pyproject.toml in the same directory of tox.ini

Address issue tox-dev#220
@chiora93 chiora93 requested a review from gaborbernat as a code owner August 4, 2025 13:10
@@ -112,7 +113,14 @@ def _setup_env(self) -> None: # noqa: C901
cmd.extend(("-p", self.env_version_spec()))

show = self.options.verbosity > 2 # noqa: PLR2004
outcome = self.execute(cmd, stdin=StdinSource.OFF, run_id="uv-sync", show=show)
cwd = self.package_root()
Copy link
Member

Choose a reason for hiding this comment

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

Should be root instead of cwd.

@@ -310,6 +311,18 @@ def _py_info(self) -> PythonInfo: # pragma: win32 no cover
extra={},
)

def package_root(self) -> Path:
Copy link
Member

Choose a reason for hiding this comment

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

This should be a cached property.

try:
return self.core["package_root"]
except KeyError:
config = self.core["tox_root"] / "tox.ini"
Copy link
Member

Choose a reason for hiding this comment

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

This can be a lot more, than just ini, like toml and various other file sources we support.

@@ -168,6 +168,9 @@ overwritten by the VIRTUALENV_SYSTEM_SITE_PACKAGES environment variable. This fl
We use `uv pip` to install packages into the virtual environment. The behavior of this can be configured via the
following options:

tox-uv resolves your project location based on the `package_root` setting. If that option is not defined, it will fall
Copy link
Member

Choose a reason for hiding this comment

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

We don't really want to publicize setupdir, rather package_root is what we should only advertise.

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

Successfully merging this pull request may close these issues.

2 participants