ยง2024-10-12
Poetry is a tool for dependency management and packaging in Python. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. Poetry offers a lockfile to ensure repeatable installs, and can build your project for distribution.
- install
$ source ~/PYTHON-3.13.0/bin/activate
(PYTHON-3.13.0) alexlai@hc4Bookworm:~/build/mongo$ which python3
/home/alexlai/PYTHON-3.13.0/bin/python3
(PYTHON-3.13.0) alexlai@hc4Bookworm:~/build/mongo$ cp ~/.bashrc ~/.bashrc.backup
(PYTHON-3.13.0) alexlai@hc4Bookworm:~/build/mongo$ curl -sSL https://install.python-poetry.org | python3 -
Retrieving Poetry metadata
# Welcome to Poetry!
This will download and install the latest version of Poetry,
a dependency and package manager for Python.
It will add the `poetry` command to Poetry's bin directory, located at:
/home/alexlai/.local/bin
You can uninstall at any time by executing this script with the --uninstall option,
and these changes will be reverted.
Installing Poetry (1.8.3): Done
Poetry (1.8.3) is installed now. Great!
To get started you need Poetry's bin directory (/home/alexlai/.local/bin) in your `PATH`
environment variable.
Add `export PATH="/home/alexlai/.local/bin:$PATH"` to your shell configuration file. <---
Alternatively, you can call Poetry explicitly with `/home/alexlai/.local/bin/poetry`.
You can test that everything is set up by executing:
`poetry --version`
(PYTHON-3.13.0) alexlai@hc4Bookworm:~/build/mongo$ ~/.local/bin/poetry --version
Poetry (version 1.8.3)
(PYTHON-3.13.0) alexlai@hc4Bookworm:~/build/mongo$ export PATH="/home/alexlai/.local/bin:$PATH"
(PYTHON-3.13.0) alexlai@hc4Bookworm:~/build/mongo$ poetry --version
Poetry (version 1.8.3)
- using poetry to install requirements
(PYTHON-3.13.0) alexlai@hc4Bookworm:~/build/mongo$ git branch
master
* r8.0.1
(PYTHON-3.13.0) alexlai@hc4Bookworm:~/build/mongo$ ls
bazel buildfarm CODEOWNERS copy.bara.sky CreativeCommons.txt distsrc etc jsconfig.json LICENSE-Community.txt OWNERS.yml pnpm-lock.yaml pyproject.toml README.third_party.md sbom.json site_scons WORKSPACE.bazel
BUILD.bazel buildscripts CONTRIBUTING.rst copybara.staging.sky debian docs evergreen jstests log package.json poetry.lock README.md rpm SConstruct src
(PYTHON-3.13.0) alexlai@hc4Bookworm:~/build/mongo$ poetry env use python3
Creating virtualenv mdb-python-deps-QXXwUIVB-py3.13 in /home/alexlai/.cache/pypoetry/virtualenvs
Using virtualenv: /home/alexlai/.cache/pypoetry/virtualenvs/mdb-python-deps-QXXwUIVB-py3.13
(PYTHON-3.13.0) alexlai@hc4Bookworm:~/build/mongo$ poetry install
Installing dependencies from lock file
Package operations: 171 installs, 0 updates, 0 removals
- Installing six (1.16.0)
- Installing jmespath (1.0.1)
- Installing python-dateutil (2.8.2)
- Installing urllib3 (1.26.18)
- Installing botocore (1.34.40)
- Installing pycparser (2.21)
- Installing s3transfer (0.10.0)
- Installing attrs (23.2.0)
- Installing boto3 (1.34.40)
- Installing cffi (1.16.0)
- Installing rpds-py (0.17.1): Failed
ChefBuildError
Backend subprocess exited when trying to invoke build_wheel
Running `maturin pep517 build-wheel -i /tmp/tmp0gt8ucmz/.venv/bin/python --compatibility off`
๐ฅ maturin failed
Caused by: Cargo metadata failed. Do you have cargo in your PATH?
Caused by: No such file or directory (os error 2)
Error: command ['maturin', 'pep517', 'build-wheel', '-i', '/tmp/tmp0gt8ucmz/.venv/bin/python', '--compatibility', 'off'] returned non-zero exit status 1
at ~/.local/share/pypoetry/venv/lib/python3.13/site-packages/poetry/installation/chef.py:164 in _prepare
160โ
161โ error = ChefBuildError("\n\n".join(message_parts))
162โ
163โ if error is not None:
โ 164โ raise error from None
165โ
166โ return path
167โ
168โ def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:
Note: This error originates from the build backend, and is likely not a problem with poetry but with rpds-py (0.17.1) not supporting PEP 517 builds. You can verify this by running 'pip wheel --no-cache-dir --use-pep517 "rpds-py (==0.17.1)"'.
- Installing smmap (5.0.1)
(PYTHON-3.13.0) alexlai@hc4Bookworm:~/build/mongo$ pip wheel --no-cache-dir --use-pep517 "rpds-py (==0.17.1)"
Collecting rpds-py==0.17.1
Downloading rpds_py-0.17.1.tar.gz (24 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
ร Preparing metadata (pyproject.toml) did not run successfully.
โ exit code: 1
โฐโ> [6 lines of output]
Cargo, the Rust package manager, is not installed or is not on PATH.
This package requires Rust and Cargo to compile extensions. Install it through
the system's package manager or via https://rustup.rs/
Checking for Rust toolchain....
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
ร Encountered error while generating package metadata.
โฐโ> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
(PYTHON-3.13.0) alexlai@hc4Bookworm:~/build/mongo$ git branch -D r8.0.1
Deleted branch r8.0.1 (was 2448d5d70cd).
(PYTHON-3.13.0) alexlai@hc4Bookworm:~/build/mongo$ git branch
* master
(PYTHON-3.13.0) alexlai@hc4Bookworm:~/build/mongo$ git checkout r8.0.0 -b r8.0.0
Updating files: 100% (13153/13153), done.
Switched to a new branch 'r8.0.0'
(PYTHON-3.13.0) alexlai@hc4Bookworm:~/build/mongo$ ls
bazel buildfarm CODEOWNERS copy.bara.sky CreativeCommons.txt distsrc etc jsconfig.json LICENSE-Community.txt OWNERS.yml pnpm-lock.yaml pyproject.toml README.third_party.md sbom.json site_scons WORKSPACE.bazel
BUILD.bazel buildscripts CONTRIBUTING.rst copybara.staging.sky debian docs evergreen jstests log package.json poetry.lock README.md rpm SConstruct src
(PYTHON-3.13.0) alexlai@hc4Bookworm:~/build/mongo$ poetry install
Installing dependencies from lock file
Package operations: 160 installs, 0 updates, 0 removals
- Installing rpds-py (0.17.1): Failed
ChefBuildError
Backend subprocess exited when trying to invoke build_wheel
Running `maturin pep517 build-wheel -i /tmp/tmpcni7q394/.venv/bin/python --compatibility off`
๐ฅ maturin failed
Caused by: Cargo metadata failed. Do you have cargo in your PATH?
Caused by: No such file or directory (os error 2)
Error: command ['maturin', 'pep517', 'build-wheel', '-i', '/tmp/tmpcni7q394/.venv/bin/python', '--compatibility', 'off'] returned non-zero exit status 1
at ~/.local/share/pypoetry/venv/lib/python3.13/site-packages/poetry/installation/chef.py:164 in _prepare
160โ
161โ error = ChefBuildError("\n\n".join(message_parts))
162โ
163โ if error is not None:
โ 164โ raise error from None
165โ
166โ return path
167โ
168โ def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:
Note: This error originates from the build backend, and is likely not a problem with poetry but with rpds-py (0.17.1) not supporting PEP 517 builds. You can verify this by running 'pip wheel --no-cache-dir --use-pep517 "rpds-py (==0.17.1)"'.
(PYTHON-3.13.0) alexlai@hc4Bookworm:~/build/mongo$ pip wheel --no-cache-dir --use-pep517 "rpds-py (==0.17.1)"
Collecting rpds-py==0.17.1
Downloading rpds_py-0.17.1.tar.gz (24 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
ร Preparing metadata (pyproject.toml) did not run successfully.
โ exit code: 1
โฐโ> [6 lines of output]
Cargo, the Rust package manager, is not installed or is not on PATH.
This package requires Rust and Cargo to compile extensions. Install it through
the system's package manager or via https://rustup.rs/
Checking for Rust toolchain....
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
ร Encountered error while generating package metadata.
โฐโ> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.