medic-lib 0.1.1
a python package
Requires Python: <4.0,>=3.12


# How to publish a open source python library on pypi


# 0. setup poetry

1. init project
```sh
poetry init
```

2. install deps

```sh
poetry add boto3
```
- add dev deps
```sh
poetry add --group dev pytest pytest-asyncio pytest-cov asgi-lifespan types-aiofiles mypy typer
```

3. create lock file

## poetry lock
- Update lock file with newly install dependancies
```sh
poetry lock
```


4. install pyproject.toml deps into venv
## poetry install
```sh
poetry install
```



# 1. Create pypi account

# 2. Set credentials

- https://python-poetry.org/docs/repositories/#configuring-credentials

```sh
export POETRY_PYPI_TOKEN_FOO=pypi-AgEIcHlwaS5vcmcCJDQyOGM4ZmUw
# or
poetry config pypi-token.pypi pypi-AgEIcHlwaS5vcmcCJDQyOGM4ZmUw
```

# 3. publish

```sh
poetry publish --build
```



---



# poetry

## poetry env list

```sh
poetry env list
poetry env list --full-path
```

## poetry add

__update package to latest version__

- Use @latest, you dont need to use the latest version number.
```sh
poetry add langchain@latest
```

## poetry add --group dev

__Add a package to the dev environment.__

- NOTE: The --dev option is deprecated, use the `--group dev` notation instead.
```sh
# examples
poetry add --group dev pytest pytest-asyncio pytest-cov asgi-lifespan types-aiofiles mypy typer
poetry add --group dev types-aiofiles

poetry add --group dev types-aiofiles
# moto for aws mocking in unit tests
poetry add --group dev 'moto[s3,sagemaker]'
# or
poetry add --group dev 'moto[s3]'
# or  
poetry add --group dev 'moto[all]'
poetry add --group dev 'typer==0.12.3'
```

## poetry remove

- Remove library from dev dependancies
```sh
poetry remove --group dev httpx
```

## poetry update
- updates poetry.lock with changes from `pyproject.toml`

## poetry shell
- activates virtual env associated with poetry

## poetry install
- __Installs poetry.lock into virtual env__
- Checks poetry.lock file for exact versions of all dependencies to install.
    - Install's those versions into the virtual environment that Poetry is managing for your project.

## poetry install dev
```sh
poetry install --with dev
```

## poetry install --all-extras --dry-run
- Install all dependencies.
- Install dev dependancies listed in pyproject.toml file. 

## poetry lock
- The message you're seeing suggests that there have been significant changes to your pyproject.toml file, which is the primary configuration file for Poetry that defines your project and its dependencies. 
- Since this file has changed, the poetry.lock file, which records the exact versions of dependencies that your project should use to ensure consistency across installations, is no longer in sync with pyproject.toml.
- The command `poetry lock --no-update` is used to regenerate the poetry.lock file. 
- Here's what happens depending on the option you choose:
  - `poetry lock` (without any flags): 
    - will regenerate the poetry.lock file and attempt to update the dependencies to their latest versions according to the version constraints specified in pyproject.toml. 
    - This is useful if you want to refresh your dependencies along with updating the lock file.

  - `poetry lock --no-update`: 
    - This command also regenerates the poetry.lock file, but it does not update the dependencies to their newer versions. 
    - Instead, it tries to maintain the versions of the dependencies that were previously locked (as much as possible) while ensuring that the lock file is consistent with the current pyproject.toml.
 
- This is useful when you want the dependencies to remain at their current versions but need the lock file to be updated to reflect changes in the configuration file or to resolve any discrepancies between the two files.
- Using either of these commands ensures that your project's dependency management remains consistent and reliable, adhering to the versions specified and avoiding potential conflicts or unexpected behavior due to version mismatches.

```sh
poetry lock
```

## poetry install
- __Installs poetry.lock into virtual env__
- Checks poetry.lock file for exact versions of all dependencies to install.
    - Install's those versions into the virtual environment that Poetry is managing for your project.

## poetry install --all-extras --dry-run
- Install all dependencies.
- Install dev dependancies listed in pyproject.toml file. 

## poetry install --no-build-isolation
- If you have all dependencies correctly installed, you can try installing the package with no build isolation, which sometimes resolves complex dependency issues

```sh
poetry install --no-build-isolation
```


## poetry update
- updates `poetry.lock` with changes from `pyproject.toml`

## poetry update self
`poetry self update` updates poetry being used in your viertual env
- can fix bugs when running `poetry update`