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

Support workspace only project #309

Closed
wants to merge 2 commits into from

Conversation

ischaojie
Copy link
Contributor

@ischaojie ischaojie commented Jun 11, 2023

[WIP] #236

For projects that do not need to be published as a package, add a "project-only" field for identification.

[tool.rye]
managed = true
project-only = true

Welcome everyone to express their own opinions.

.and_then(|x| x.get("rye"))
.and_then(|x| x.get("workspace-only"))
.and_then(|x| x.as_bool())
.unwrap_or(false)
Copy link
Contributor

Choose a reason for hiding this comment

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

would this config variable live better inside the existing group called tool.rye.workspace?

Copy link
Contributor

Choose a reason for hiding this comment

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

What about instead of adding a workspace only value we just expect members = [] where members is empty? So it's implied to be used as a workspace without members to install.

Copy link
Contributor

@bluss bluss Jun 12, 2023

Choose a reason for hiding this comment

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

I guess there are different ways to go but I was thinking that a workspace-only can be used both with members and without. And it would always be a workspace, hence the workspace key should be set anyway.

(Edit, I guess to clarify, in my model the "only" does not mean there are no members. It means the project is only a workspace and not a python package. And a workspace can always have members in it.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The tool.rye.workspace configuration is not normally needed for single project development. The workspace-only here might be more appropriately called no-package? or is-package = true ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Setting tool.rye.workspace makes sure that rye creates the virtualenv in that (the current) project's directory, which fits well with the "workspace-only" feature.

Do we need an additional orthogonal marker that's independent of workspace? Then you create more scenarios and additional complexity (package or "not package", workspace or not workspace is a 2x2 matrix). We can have three combinations, where a pyproject.toml becomes with rye, a:

  • python package
  • python package and a workspace
  • workspace (only)

Copy link
Contributor

Choose a reason for hiding this comment

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

To just keep the discussion diverse, I kinda think about this as everything is a workspace. Some workspaces you want to add packages/projects (members) to. Some of those projects/packages (members) are meant to be installed or their environments are managed via a workspace .venv.

So

  • python package

What keeps us from considering it as

  • python package and a workspace

and

  • workspace (only)

Is just a workspace with no added members.

Copy link
Contributor

@bluss bluss Jun 12, 2023

Choose a reason for hiding this comment

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

I appreciate that. A workspace is a ceiling, or the top level of a thing. Can't include workspaces in workspaces. Then it would seem anything that is "the top" is a workspace?

let applicable_extras =
format_project_extras(features_by_project.as_ref(), &pyproject)?;
writeln!(local_req_file, "-e {}{}", rel_url, applicable_extras)?;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this skips installing any workspace member, but it's only the root we want to skip installing (?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes indeed, further consideration is needed here.

Copy link
Contributor

@bluss bluss Jun 12, 2023

Choose a reason for hiding this comment

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

fwiw I think your PR did something useful when I tried it, I inserted the skip root (but keep other members) here and a name in the pyproject file, and then rye sync did what was expected I think - pulling in members and dev-dependencies. Since this is all close to the pip-tools backend (which might be replaced), I think it's tricky to know how to approach this change. (I mean: whatever we implement might need to be changed later?)

@ischaojie
Copy link
Contributor Author

ischaojie commented Jun 14, 2023

Using project-only instead of workspace-only might be a better expression. Suppose I have a workspace called o that contains projects o1 and o2, and the file structure looks like this:

/o
  /pyproject.toml
  /src/o
  /o1
    /pyproject.toml
    /src/o1
  /o2
    /pyproject.toml
    /src/o2

Each project can declare whether it is project-only or not (identify project-only=true in [tool.rye]). For example, I'm assuming that o1 is a package, o2 is just a normal project, and root o is also a package, so that when I sync or build, I generate -e file:. -e file:o1 and o-0.1.0-py3-none-any.whl o1-0.1.0-py3-none-any.whl.

@bluss
Copy link
Contributor

bluss commented Jun 14, 2023

@ischaojie it does seem to fit together well using project only. When you say for example o2 is a project only, what is that used for? Wondering about the usecase for having a leaf that's not a python lib.

@0xDing
Copy link

0xDing commented Jun 22, 2023

@ischaojie it does seem to fit together well using project only. When you say for example o2 is a project only, what is that used for? Wondering about the usecase for having a leaf that's not a python lib.

some team use monorepo

@T-256
Copy link
Contributor

T-256 commented Jul 16, 2023

Thanks to all of discussions, here is what's I take:

  1. Packages are buildable to be install on an environment.
  2. Environments include installed packages.
  3. Workspaces are managing packages (if available) and environments (if available).
  4. Projects are for creating different workspace kinds.

My expectation from Rye:

  • As Project Manager:
    1. Create a packable workspace.
    2. Create a non-packable workspace.
  • As Packable Workspace Manager:
    • build, install, publish, ... current and workspace members packages.
  • As Non-Packable Workspace Manager:
    • build, install, publish, ... only workspace members packages (if any available).

Currently rye init xyz will create Packable Workspace:

.
├── .git
├── .gitignore
├── .python-version
├── README.md
├── pyproject.toml
└── src
    └── xyz
        └── __init__.py
pyproject.toml
[project]
name = "xyz"
version = "0.1.0"
description = "Add a short description here"
authors = [
    { name = "Tester", email = "Tester@test.com" }
]
dependencies = []
readme = "README.md"
requires-python = ">= 3.7"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.rye]
managed = true

[tool.hatch.metadata]
allow-direct-references = true

This is a workspace that manages one package.

IIUC what's this PR tries to do is prevent create a workspace that limited to any packages.
rye init xyz --workspace-only:

.
├── .git
├── .gitignore
├── .python-version
├── README.md
├── pyproject.toml
pyproject.toml
[project]
name = "xyz"
version = "0.1.0"
description = "Add a short description here"
authors = [
    { name = "Tester", email = "Tester@test.com" }
]
dependencies = []
readme = "README.md"
requires-python = ">= 3.7"

[tool.rye]
managed = true

By this, no package created initially. (build-system is not in pyproject.toml)
You can still create sub projects here and add them to tool.rye.workspace.members.
IMO non-packable workspace should be default behavior and use packable workspace only when explicitly called (e.g. --private or --build-system xxxxx).

@mitsuhiko
Copy link
Collaborator

I think I will add a version of this. I do find the "project only" moniker confusing. Currently thinking of just calling it "virtual" and not be too descriptive about what this means.

@mitsuhiko
Copy link
Collaborator

Closing in favor of updated #551

@mitsuhiko mitsuhiko closed this Jan 21, 2024
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.

6 participants