Oleksandr Dashkov
Oleksandr Dashkov

Reputation: 2848

Custom section in pipfile

Is it possible to set up a custom section in the pipfile?

By default I see only [packages] and [dev-packages], but I have extra dependencies for some environment. So I want to install packages and for example [tests] but not [dev-packages].

E.G.:

pipenv install --tests
# or 
pipenv install --my-custom-section

Before that I used requirements.txt, requirements-dev.txt, requirements-integration.txt. Is there any good way to implement it with pipenv?

Upvotes: 6

Views: 1154

Answers (2)

Espoir Murhabazi
Espoir Murhabazi

Reputation: 6386

The Good News:

Just to give an update to someone else who comes here later. The feature to add categories to pip has been implemented to pipenv.

It was discussed in this issue and was implement in this pull request.

How it works?

If you want to install a package in a specific category in your pipfile, you can do the following:

pipenv install fastapi --categories api

This will add a new category called api in your Pipfie.

Later if you want to install the packages from your category only you can do:

pip install --categories=api

It also supports synchronization of categories and locks.

pipenv sync --categories="prereq packages"

For uninstallation:

 pipenv lock --categories="prereq dev-packages"
 pipenv uninstall six --categories prereq

Learn More:

Here ..

Upvotes: 1

Alex Yu
Alex Yu

Reputation: 3537

Let's look into documentation

If we look in Pipfile. The Concept:

Pipfile will be superior to requirements.txt file in a number of ways: ...

  • Existing requirements files tend to proliferate into multiple files - e.g. dev-requirements.txt, test-requirements.txt, etc. - but a Pipfile will allow seamlessly specifying groups of dependencies in one place. * This will be surfaced as only two built-in groups (default & development). (see note below)

Note

Custom groups may be added in the future. Remember, it is easier to add features in the future than it is to remove them. The Composer community has been successful with only default and development as group options for many years. This model is being followed.

Answer

It's not possible now although it was designed with idea of such possibility.

Maybe it will be possible in future.

Upvotes: 8

Related Questions