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

Use a lightweight core library #2212

Merged
merged 4 commits into from
Mar 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ So, in your `pyproject.toml` file, add this section if it does not already exist

```toml
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
requires = ["poetry-core>=1.0.0"]
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible to have core somehow namespaced under poetry so that we will instead have requires = ["poetry.core>=1.0.0"]? Using a dash in the package name can be quite confusing, for example, when do we use the dash and the underscore (in docs/pyproject.md, it requires poetry_core).

Copy link
Contributor

Choose a reason for hiding this comment

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

Both of these are equivalent to PyPI - so “_-” won't matter to PyPI. You can use poetry_core instead of poetry-core and they'll refer to the same thing in the dependency specification.

That's the interoperability standard (PEP 508/440) and I expect poetry follows it. :)

Copy link
Member

Choose a reason for hiding this comment

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

Ah okay, good to know, thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

I would have preferred to use a namespace package but, as far as I know, it's not possible since poetry is already its own package.

It would require to no longer have the poetry package but multiple packages (like poetry-core and poetry-cli) so I don't think it's worth it for now.

However, if someone tells me there is a way to do it without big changes I'd be happy to change it.

Copy link
Member Author

Choose a reason for hiding this comment

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

In the end, I managed to make the poetry namespace work, so poetry-core will provide the poetry.core package.

build-backend = "poetry.core.masonry.api"
```

And use a `tox.ini` configuration file similar to this:
Expand Down
16 changes: 11 additions & 5 deletions docs/docs/pyproject.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,22 @@ If you publish you package on PyPI, they will appear in the `Project Links` sect
[PEP-517](https://www.python.org/dev/peps/pep-0517/) introduces a standard way
to define alternative build systems to build a Python project.

Poetry is compliant with PEP-517 so if you use Poetry to manage your Python
project you should reference it in the `build-system` section of the `pyproject.toml`
file like so:
Poetry is compliant with PEP-517, by providing a lightweight core library,
so if you use Poetry to manage your Python project you should reference
it in the `build-system` section of the `pyproject.toml` file like so:

```toml
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"
requires = ["poetry_core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
```

!!!note

When using the `new` or `init` command this section will be automatically added.


!!!note

If your `pyproject.toml` file still references `poetry` directly as a build backend,
you should update it to reference `poetry_core` instead.
5 changes: 5 additions & 0 deletions get-poetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,13 @@ def expanduser(path):
import os

lib = os.path.normpath(os.path.join(os.path.realpath(__file__), "../..", "lib"))
vendors = os.path.join(lib, "poetry", "_vendor")
current_vendors = os.path.join(
vendors, "py{}".format(".".join(str(v) for v in sys.version_info[:2]))
)

sys.path.insert(0, lib)
sys.path.insert(0, current_vendors)

if __name__ == "__main__":
from poetry.console import main
Expand Down
Loading