> ## Documentation Index
> Fetch the complete documentation index at: https://lib.hao.vc/llms.txt
> Use this file to discover all available pages before exploring further.

# Installation

> How to install haolib

export const Dialogue = ({dialogue}) => {
  if (!dialogue || !Array.isArray(dialogue) || dialogue.length === 0) {
    return null;
  }
  return <div style={{
    margin: '2rem 0'
  }}>
            {dialogue.map((message, index) => {
    const isWriter = message.role === 'writer' || message.role === 'assistant';
    const messageText = message.text || message.content || '';
    return <div key={index} style={{
      display: 'flex',
      justifyContent: isWriter ? 'flex-end' : 'flex-start',
      marginBottom: '2rem',
      padding: '1rem'
    }}>
                        <div style={{
      maxWidth: '75%',
      display: 'flex',
      flexDirection: isWriter ? 'row-reverse' : 'row',
      alignItems: 'flex-start',
      gap: '1rem'
    }}>
                            <div style={{
      width: '50px',
      height: '50px',
      borderRadius: '50%',
      background: isWriter ? 'linear-gradient(135deg, #00CC8B 0%, #07C983 100%)' : 'linear-gradient(135deg, #07C983 0%, #00CC8B 100%)',
      display: 'flex',
      alignItems: 'center',
      justifyContent: 'center',
      fontSize: '1.5rem',
      flexShrink: 0
    }}>
                                {isWriter ? '🐱' : '👤'}
                            </div>

                            <div style={{
      flex: 1
    }}>
                                <div style={{
      fontSize: '0.75rem',
      fontWeight: '600',
      textTransform: 'uppercase',
      letterSpacing: '1px',
      marginBottom: '0.5rem',
      color: isWriter ? '#00CC8B' : '#07C983',
      textAlign: isWriter ? 'right' : 'left'
    }}>
                                    {isWriter ? 'HAO' : 'You'}
                                </div>

                                <div style={{
      background: isWriter ? 'linear-gradient(135deg, rgba(0, 204, 139, 0.2) 0%, rgba(7, 201, 131, 0.1) 100%)' : 'linear-gradient(135deg, rgba(7, 201, 131, 0.2) 0%, rgba(0, 204, 139, 0.1) 100%)',
      backdropFilter: 'blur(10px)',
      borderRadius: isWriter ? '24px 8px 24px 24px' : '8px 24px 24px 24px',
      padding: '1.5rem',
      border: isWriter ? '2px solid rgba(0, 204, 139, 0.4)' : '2px solid rgba(7, 201, 131, 0.4)',
      boxShadow: isWriter ? '0 10px 30px rgba(0, 204, 139, 0.25)' : '0 10px 30px rgba(7, 201, 131, 0.25)',
      color: '#ffffff',
      fontSize: '1rem',
      lineHeight: '1.7'
    }}>
                                    {messageText}
                                </div>
                            </div>
                        </div>
                    </div>;
  })}
        </div>;
};

export const Exercises = ({exercises}) => <div>
        <h2>Exercises</h2>
        <AccordionGroup>
            {exercises.map(exercise => <Accordion title={exercise.question}>
                    <p>{exercise.answer}</p>
                </Accordion>)}
        </AccordionGroup>
    </div>;

## Using [uv](https://docs.astral.sh/uv/) (the only recommended way <Tooltip tip="'So far' because haolib is designed to ALWAYS BE SOTA!">so far</Tooltip>)

<Dialogue
  dialogue={
[
    {
        role: 'reader',
        content: 'First, why is it recommended to use uv?'
    },
    {
        role: 'writer',
        content: 'I know why! Because uv is probably the best Python package manager overall so far!'
    }
]
}
/>

HAO, you are absolutely right! uv is really a SOTA package manager for Python! We definitely need to use it!

<Dialogue
  dialogue={
[
    {
        role: 'reader',
        content: 'Still, what about other package managers?'
    },
    {
        role: 'writer',
        content: 'MEOW! Other package managers are not SOTA, uv is SOTA! I love SOTA!'
    }
]
}
/>

Well... Yes, HAO is mostly right, but you probably don't need to think that radical about the tools we consider SOTA. Again, we are human beings and... Oops! Well, not only human beings... Carbon-based lifeforms, so to say, and we are not perfect. So all our recommendations are based on our own experience of testing different tools and frameworks, so we selected those tools that we think are SOTA. If you think otherwise, you can always contribute to haolib and improve it the way you think real SOTA must be.

## The ways to install haolib:

First, you have to understand the concept of [optional dependencies](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#dependencies-optional-dependencies) in Python.

Since haolib is a monolith, it's might be not the best idea to install it with all the dependencies, including the ones useless for your project. So we have to use optional dependencies.

HAO, do you know what optional dependencies are?

<Dialogue
  dialogue={
[
    {
        role: 'writer',
        content: 'Optional dependencies are dependencies that are part of the project, but can be installed only if needed. For example, some libraries might utilize different message brokers like Kafka or RabbitMQ, but you most likely will not need them both in your project. So you can install only the one you need.'
    }
]
}
/>

Absolutely! Now let's see how we can install haolib using the optional dependencies feature.

```bash shell theme={null}
uv add git+https://github.com/hao-vc/haolib[fastapi,sqlalchemy,security]
```

In this example, we are installing haolib with the following dependencies:

* fastapi (the full FastAPI integration)
* sqlalchemy (the full SQLAlchemy integration)
* security (the security pack, including [JWT](https://en.wikipedia.org/wiki/JSON_Web_Token) (with [PyJWT](https://pyjwt.readthedocs.io/en/stable/)),
  password hashing (with [bcrypt](https://en.wikipedia.org/wiki/Bcrypt)), symmetric Fernet encryption (with [pyca/cryptography](https://cryptography.io/en/latest/)), and [more](/essentials/security))

## The full list of optional dependencies:

* `dishka` - [Dishka](https://dishka.readthedocs.io/en/stable/index.html) integration
* `fastapi` - [FastAPI](https://fastapi.tiangolo.com/) integration
* `faststream` - [FastStream](https://faststream.dev/) integration
* `fastmcp` - [FastMCP](https://fastmcp.readthedocs.io/en/stable/index.html) integration
* `sqlalchemy` - [SQLAlchemy](https://www.sqlalchemy.org/) integration
* `security` - the security pack, including [JWT](https://en.wikipedia.org/wiki/JSON_Web_Token) (with [PyJWT](https://pyjwt.readthedocs.io/en/stable/)),
  password hashing (with [bcrypt](https://en.wikipedia.org/wiki/Bcrypt)), symmetric Fernet encryption (with [pyca/cryptography](https://cryptography.io/en/latest/)), and [more](/essentials/security))
* `redis` - [Redis](https://redis.io/docs/latest/develop/clients/redis-py/) integration
* `taskiq` - [TaskIQ](https://taskiq-python.github.io/) integration
* `observability` - the observability pack, including [OpenTelemetry](https://opentelemetry.io/) for distributed tracing and monitoring

## How to understand that installation was successful?

Well, despite the fact that uv will show an error message if something goes wrong, the next lines should appear in your `pyproject.toml` file:

```toml title="pyproject.toml" theme={null}
[tool.uv.sources]
haolib = { git = "https://github.com/hao-vc/haolib" }

```

Now you can use haolib in your project.

<Exercises
  exercises={
[
    {
        question: 'Why is uv the only recommended way to install haolib?',
        answer: 'Because it is SOTA package manager for Python. And haolib is designed to be SOTA!'
    },
    {
        question: 'What is the difference between a "framework" and a "library"?',
        answer: 'The first one is more rigid and provides less freedom, but also less responsibility to the user.'
    },
    {
        question: 'What is "SOTA"?',
        answer: 'It stands for "State of the Art".'
    },
]}
/>
