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

package: add class for pnpm #18

Merged
merged 5 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
31 changes: 6 additions & 25 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# This file is part of Invenio.
# Copyright (C) 2020 CERN.
# Copyright (C) 2025 KTH Royal Institute of Technology.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
Expand All @@ -14,28 +15,8 @@ on:
- v*

jobs:
Publish:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.7

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel babel

- name: Build package
run: |
python setup.py sdist bdist_wheel

- name: Publish on PyPI
uses: pypa/[email protected]
with:
user: __token__
password: ${{ secrets.pypi_token }}
build-n-publish:
uses: inveniosoftware/workflows/.github/workflows/pypi-publish.yml@master
secrets: inherit
with:
babel-compile-catalog: true
64 changes: 15 additions & 49 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
# Copyright (C) 2020 CERN.
# Copyright (C) 2020-2024 CERN.
# Copyright (C) 2020 Northwestern University.
# Copyright (C) 2022 Graz University of Technology.
# Copyright (C) 2023 Rambaud Pierrick.
#
Expand All @@ -12,59 +12,25 @@ name: CI

on:
push:
branches: master
branches:
- master
- "feature/*"
- "maint-**"
pull_request:
branches: master
branches:
- master
- "maint-**"
- "feature/**"
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '0 3 * * 6'
- cron: "0 3 * * 6"
workflow_dispatch:
inputs:
reason:
description: 'Reason'
description: "Reason"
required: false
default: 'Manual trigger'
default: "Manual trigger"

jobs:
Tests:
timeout-minutes: 20
strategy:
matrix:
os: [ubuntu-20.04]
python-version: [3.7, 3.8, 3.9]
requirements-level: [pypi]
include:
- os: windows-latest
python-version: 3.9
runs-on: ${{ matrix.os }}
env:
EXTRAS: tests
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Generate dependencies
run: |
pip install wheel requirements-builder
requirements-builder -e "$EXTRAS" --level=${{ matrix.requirements-level }} setup.py > .${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt

- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('.${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt') }}

- name: Install dependencies
run: |
pip install -r .${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt
pip install .[$EXTRAS]
pip freeze

- name: Run tests
run: |
./run-tests.sh
Python:
uses: inveniosoftware/workflows/.github/workflows/tests-python.yml@master
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changes
=======

Version 0.3.0 (released 2025-02-20)

- Add ``PNPMPackage``

Version 0.2.0 (released 2023-11-27)

- Added ``shell`` argument.
Expand Down
7 changes: 4 additions & 3 deletions pynpm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# This file is part of PyNPM
# Copyright (C) 2017 CERN.
# Copyright (C) 2025 Graz University of Technology.
#
# PyNPM is free software; you can redistribute it and/or modify
# it under the terms of the Revised BSD License; see LICENSE file for
Expand All @@ -11,8 +12,8 @@

from __future__ import absolute_import, print_function

from .package import NPMPackage, YarnPackage
from .package import NPMPackage, PNPMPackage, YarnPackage

__version__ = "0.2.0"
__version__ = "0.3.0"

__all__ = ("__version__", "NPMPackage", "YarnPackage")
__all__ = ("__version__", "NPMPackage", "PNPMPackage", "YarnPackage")
27 changes: 27 additions & 0 deletions pynpm/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# This file is part of PyNPM
# Copyright (C) 2017 CERN.
# Copyright (C) 2023 Rambaud Pierrick.
# Copyright (C) 2025 Graz University of Technology.
#
# PyNPM is free software; you can redistribute it and/or modify
# it under the terms of the Revised BSD License; see LICENSE file for
Expand Down Expand Up @@ -96,3 +97,29 @@ def __init__(self, filepath, yarn_bin="yarn", commands=None, shell=False):
super(YarnPackage, self).__init__(
filepath, npm_bin=yarn_bin, commands=commands or ["install"], shell=shell
)


class PNPMPackage(NPMPackage):
"""API to a PNPM ``package.json``."""

def __init__(self, filepath, npm_bin="pnpm", commands=None, shell=False):
"""Construct."""
super().__init__(
filepath=filepath, npm_bin=npm_bin, commands=commands, shell=shell
)

def _run_npm(self, command, *args, **kwargs):
"""Run a PNPM command.

By default the call is blocking until PNPM is finished and output
is directed to stdout. If ``wait=False`` is passed to the method,
you get a handle to the process (return value of ``subprocess.Popen``).

:param command: PNPM command to run.
:param args: List of arguments.
:param wait: Wait for PNPM command to finish.
"""
if command == "install":
args = ["--shamefully-hoist"]

return super()._run_npm(command, *args, **kwargs)
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ install_requires =

[options.extras_require]
tests =
pytest-black>=0.3.0,<0.3.10
pytest-black>=0.6.0
pytest-cache>=1.0
pytest-invenio>=1.4.0
sphinx>=4.5
Expand Down
Loading