Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Named Package Categories #5366

Merged
merged 49 commits into from
Oct 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
80c3404
Remove unused methods, rename method, and add method to get all packa…
matteius Sep 11, 2022
d6954f2
Begin refactor to resolve multiple package categories.
matteius Sep 11, 2022
23af465
refactor section naming to category.
matteius Sep 11, 2022
19dd5e9
Resolve mutiple categories.
matteius Sep 11, 2022
301aaba
Begin passing category into the resolver.
matteius Sep 11, 2022
b37dc90
Pass the new category arg into the resolver subprocess.
matteius Sep 11, 2022
6de818a
Extend category into the resolver and move dev argument from methods …
matteius Sep 11, 2022
ceabe5a
Resolve circular import
matteius Sep 11, 2022
9d24bf0
Resolve no attribute dev on Entry.
matteius Sep 11, 2022
467045f
Allow sections that are not already written to the lockfile.
matteius Sep 11, 2022
a651b7b
Allow category based install with sync.
matteius Sep 11, 2022
0d57450
Allow adding packages to Pipfile in other sections.
matteius Sep 11, 2022
83d0f10
Fix hash generatiton with named categories and convert more to plette…
matteius Sep 11, 2022
0c8d4c3
Fix the tests.
matteius Sep 11, 2022
24c51eb
Resolve environment variables expanding for the sources.
matteius Sep 11, 2022
dcfa8d2
Fix remaining test.
matteius Sep 11, 2022
1a8356a
Refactor and working ahead on categories.
matteius Sep 19, 2022
afb5ce7
Resolve merge conflicts with main.
matteius Sep 19, 2022
169eb17
Make keep-outdated work with multiple categories.
matteius Sep 19, 2022
c7d8379
Expand uninstall/clean to consider categories.
matteius Sep 19, 2022
bd0a209
Expand uninstall/clean to consider categories.
matteius Sep 19, 2022
7646513
Expand uninstall/clean to consider categories.
matteius Sep 19, 2022
49386f6
Fix logic for failing tests.
matteius Sep 19, 2022
88ff657
Fix do outdated for categories.
matteius Sep 19, 2022
8a4916e
Adjust test expctation.
matteius Sep 19, 2022
d5c63a0
Fix import of plette.
matteius Sep 19, 2022
ae5d5f1
Fix import of plette.
matteius Sep 19, 2022
91b5160
Fix import of plette.
matteius Sep 19, 2022
7754e66
Refactor requirementslib for categories and remove unused code.
matteius Sep 19, 2022
40900bc
Add install categories tests.
matteius Sep 19, 2022
48a1c76
Allow users to lock only specific categories.
matteius Sep 19, 2022
eb6054a
Add test for isolated package lock.
matteius Sep 19, 2022
bb006fe
Allow locking of individual package groups.
matteius Sep 19, 2022
c882a09
Fixes for uninstall to work with categories.
matteius Sep 20, 2022
7497f0c
resolve issues with uninstall.
matteius Sep 20, 2022
9e064bc
Fix issues from prior refactoring and specify --no-build-isolation by…
matteius Sep 20, 2022
8886cb5
Run pipenv lock.
matteius Sep 20, 2022
8cf819c
Fix bug where locking one category clears the other category locks.
matteius Sep 20, 2022
8735dc6
resolve testing issue from last commit.
matteius Sep 20, 2022
8e81dda
resolve merge conflict with main.
matteius Sep 22, 2022
b3381ce
Check point progress fixing tests in branch.
matteius Sep 22, 2022
f6775eb
Merge branch 'main' into named-categories
matteius Sep 26, 2022
eaed25d
Write the lockfile contents when default content is missing.
matteius Sep 26, 2022
35b996d
merge in main and resolve conflict.
matteius Oct 4, 2022
a5256d2
Remove debug print.
matteius Oct 4, 2022
11b96ed
Prefer click secho over echo + style.
matteius Oct 4, 2022
19b5301
Merge branch 'main' into named-categories
matteius Oct 6, 2022
81cde42
add documentation for named categories.
matteius Oct 8, 2022
4fa70db
Merge branch 'main' into named-categories
matteius Oct 8, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[dev-packages]
pipenv = {path = ".", editable = true, extras = ["tests", "dev"]}
sphinx = "==4.*"
Expand Down
34 changes: 20 additions & 14 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions docs/basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,32 @@ the current working directory when working on packages::
``Pipfile.lock`` if you leave the ``-e`` option out.


☤ Specifying Package Categories
-------------------------------

Originally pipenv supported only two package groups: ``packages`` and ``dev-packages`` in the ``Pipfile`` which mapped to ``default`` and ``develop`` in the ``Pipfile.lock``. Support for additional named categories has been added such that arbitrary named groups can utilized across the available pipenv commands.

.. note:: The name will be the same between ``Pipfile`` and lock file, however to support the legacy naming convention it is not possible to have an additional group named ``default`` or ``develop`` in the ``Pipfile``.

By default ``pipenv lock`` will lock all known package categorises; to specify locking only specific groups use the ``--categories`` argument.
The command should process the package groups in the order specified.

Example usages::

# single category
pipenv install six --catetgories prereq

# multiple categories
pipenv sync --categories="prereq packages"

# lock and uninstall examples
pipenv lock --categories="prereq dev-packages"
pipenv uninstall six --categories prereq



.. note:: The ``packages``/``default`` specifiers are used to constrain all other categories just as they have done for ``dev-packages``/``develop`` category. However this is the only way constraints are applied -- the presence of other named groups do not constraint each other, which means it is possible to define conflicting package versions across groups. This may be desired in some use cases where users only are installing groups specific to their system platform.

.. _environment_management:

☤ Environment Management with Pipenv
Expand Down
5 changes: 4 additions & 1 deletion pipenv/cli/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,6 @@ def install(state, **kwargs):
python=state.python,
pypi_mirror=state.pypi_mirror,
system=state.system,
lock=not state.installstate.skip_lock,
ignore_pipfile=state.installstate.ignore_pipfile,
skip_lock=state.installstate.skip_lock,
requirementstxt=state.installstate.requirementstxt,
Expand All @@ -253,6 +252,7 @@ def install(state, **kwargs):
editable_packages=state.installstate.editables,
site_packages=state.site_packages,
extra_pip_args=state.installstate.extra_pip_args,
categories=state.installstate.categories,
)


Expand Down Expand Up @@ -291,6 +291,7 @@ def uninstall(ctx, state, all_dev=False, all=False, **kwargs):
all=all,
keep_outdated=state.installstate.keep_outdated,
pypi_mirror=state.pypi_mirror,
categories=state.installstate.categories,
ctx=ctx,
)
if retcode:
Expand Down Expand Up @@ -341,6 +342,7 @@ def lock(ctx, state, **kwargs):
keep_outdated=state.installstate.keep_outdated,
pypi_mirror=state.pypi_mirror,
write=not state.quiet,
categories=state.installstate.categories,
)


Expand Down Expand Up @@ -654,6 +656,7 @@ def sync(ctx, state, bare=False, user=False, unused=False, **kwargs):
pypi_mirror=state.pypi_mirror,
system=state.system,
extra_pip_args=state.installstate.extra_pip_args,
categories=state.installstate.categories,
)
if retcode:
ctx.abort()
Expand Down
22 changes: 22 additions & 0 deletions pipenv/cli/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def __init__(self):
self.packages = []
self.editables = []
self.extra_pip_args = []
self.categories = []


class LockOptions:
Expand Down Expand Up @@ -223,6 +224,24 @@ def callback(ctx, param, value):
)(f)


def categories_option(f):
def callback(ctx, param, value):
state = ctx.ensure_object(State)
if value:
for opt in value.split(" "):
state.installstate.categories.append(opt)
return value

return option(
"--categories",
nargs=1,
required=False,
callback=callback,
expose_value=True,
type=click_types.STRING,
)(f)


def install_dev_option(f):
return _dev_option(f, "Install both develop and default packages")

Expand Down Expand Up @@ -547,6 +566,7 @@ def install_base_options(f):

def uninstall_options(f):
f = install_base_options(f)
f = categories_option(f)
f = uninstall_dev_option(f)
f = skip_lock_option(f)
f = editable_option(f)
Expand All @@ -558,12 +578,14 @@ def lock_options(f):
f = install_base_options(f)
f = lock_dev_option(f)
f = dev_only_flag(f)
f = categories_option(f)
return f


def sync_options(f):
f = install_base_options(f)
f = install_dev_option(f)
f = categories_option(f)
return f


Expand Down
Loading