Git Product home page Git Product logo

sandbox's Introduction

sandbox

This is just a Sandbox.

Virtual environment setup with Pyenv and Poetry

Requirements:

  • pyenv, for Python versions management
  • poetry, for packaging and dependency management
  1. Define the python version with pyenv, e.g.:
pyenv local 3.11

so that it also creates a .python-version file in the project root.

  1. Create an env variable from the file.
export POETRY_PYTHON_VERSION=$(cat .python-version)
  1. Set pyproject_template.toml to use python = "^${POETRY_PYTHON_VERSION".

  2. Fill the template with the chosen python versions using the following command,

sed "s/python = \"^\${POETRY_PYTHON_VERSION}\"/python = \"^$POETRY_PYTHON_VERSION\"/" pyproject_template.toml > pyproject.toml

note that it directs the output to create or overwrite the file pyproject.toml.

  1. Double check with pyenv versions that the correct version is active. Then force poetry to use this version:
poetry env use python

this already creates the poetry venv, but it doesn't install anything yet. You can debug with poetry debug info and sanity check that the System will show pyenv path and version as desired, and this should match the virtual environment. Poetry Python version does not need to match it.

$ poetry debug info

Poetry
Version: 1.7.1
Python:  3.12.0

Virtualenv
Python:         3.11.6
Implementation: CPython
Path:           ~/.cache/pypoetry/virtualenvs/sandbox-py3.11
Executable:     ~/.cache/pypoetry/virtualenvs/sandbox-py3.11/bin/python
Valid:          True

System
Platform:   linux
OS:         posix
Python:     3.11.6
Path:       ~/.pyenv/versions/3.11.6
Executable: ~/.pyenv/versions/3.11.6/bin/python3.11
  1. Finally, you should be able to run poetry install to install all dependencies and poetry shell to manually spawn your virtual environment.

sandbox's People

Contributors

fontanads avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.