Home Blog CV Projects Patterns Notes Book Colophon Search

Switching out Poetry for Pip

28 Sep, 2023

Assuming you've read Poetry Git Submodules and Plugins with Poetry.

There are two tricks to getting this working nicely:

I prefer this approach because pip and setuptools come with most distributions of Python 3.11 anyway, so there isn't any need to install anything else.

Here are the files in the serve repo:

serve - same as before

tests - same as before

.gitignore:

*.egg-info
__pycache__

README.md - empty, same as before

pyproject.toml:

[project]
name = "serve"
version = "0.1.0"

[project.entry-points."blog.serve_msg"]
serve_msg_plugin = "serve:serve_msg"

And here are the files in the blog git repo:

blog - same as before

tests - same as before

private-packages - created when you run git -c protocol.file.allow=always submodule add ../serve private-packages/serve to install from the local serve git repo

README.md:

# Instructions

Install:

```
python3 -m venv .venv && .venv/bin/pip install -e private-packages/* && .venv/bin/pip install .
```

Every time metadata is changed, or submodules are updated:

```
git -c protocol.file.allow=always submodule update --remote && .venv/bin/pip install -e private-packages/*
```

To run:

```sh
.venv/bin/python3 blog/__init__.py serve_msg_plugin
```
```
Hello from serve
```

.gitignore:

*.egg-info
.venv
__pycache__
build

pyproject.toml:

[project]
name = "blog"
version = "0.1.0"
dependencies = [
  'serve'
]

See Declaring Project Metadata for other metadata available.

A lot simpler overall I think.

You can specify dev dependencies like this:

[project.optional-dependencies]
dev = [
  'black==23.9.1',
  'uvicorn==0.23.2',
  'isort==5.12.0',
  'autoflake==2.2.1',
]

Then:

.venv/bin/pip install '.[dev]'

Comments

Be the first to comment.

Add Comment





Copyright James Gardner 1996-2020 All Rights Reserved. Admin.