Skip to content

Commit

Permalink
docs: how to configure projects to use dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
apoclyps committed Nov 16, 2023
1 parent 991a08e commit adc5545
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions docs/how_to_use_dependency.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Configuring a Project to Use Gemfury Package

## 1. Environment Variables

Add the required environment variables `GEMFURY_DOWNLOAD_TOKEN` and `GEMFURY_REPOSITORY_URL` to your project environment. This can be achieved by either setting them as environmental variables or by including them in a `.env` file. If you opt for the latter, ensure that the `.env` file is excluded from version control using a `.gitignore` file.

## 2. Configure Poetry for Gemfury

Use the following commands to configure Poetry to use Gemfury as a repository:

```bash
poetry config virtualenvs.create false && \
poetry config repositories.gemfury $GEMFURY_REPOSITORY_URL && \
poetry config http-basic.fury $GEMFURY_DOWNLOAD_TOKEN NOPASS
```

## 3. Additional Configuration for Docker

When building your Docker container, pass the build arguments for your Gemfury credentials:

```bash
docker build \
--build-arg GEMFURY_DOWNLOAD_TOKEN=$(GEMFURY_DOWNLOAD_TOKEN) \
--build-arg GEMFURY_DOWNLOAD_TOKEN=$(GEMFURY_REPOSITORY_URL) \
-t $(DOCKER_REPOTAG) .
```

Example Dockerfile:

```dockerfile
ENV POETRY_VERSION=1.6.1

ARG GEMFURY_DOWNLOAD_TOKEN

RUN pip3 install "poetry==$POETRY_VERSION" --no-cache-dir && \
poetry config virtualenvs.create false && \
poetry config repositories.gemfury $GEMFURY_REPOSITORY_URL && \
poetry config http-basic.fury $GEMFURY_DOWNLOAD_TOKEN NOPASS
```

## 4. Adding Dependency to pyproject.toml

Update your pyproject.toml to include Gemfury as a source:

```toml
[[tool.poetry.source]]
name = "fury"
url = "https://pypi.fury.io/apoclyps/"
priority = "primary"

[[tool.poetry.source]]
name = "PyPI"
priority = "primary"

[tool.poetry.dependencies]
python-package-publish = { version = "0.3.0", source = "fury" }
```

## 5. Importing Your Package

Now, you can import your package into your source code:

```python
from python_package_publish.utils import get_utc_now

now = get_utc_now()
```

By following these steps, you should have successfully configured your project to use the Gemfury package.

0 comments on commit adc5545

Please sign in to comment.