=======
PyNPM
=======
.. image:: https://github.com/inveniosoftware/pynpm/workflows/CI/badge.svg
:target: https://github.com/inveniosoftware/pynpm/actions?query=workflow%3ACI
.. image:: https://img.shields.io/coveralls/inveniosoftware/pynpm.svg
:target: https://coveralls.io/r/inveniosoftware/pynpm
.. image:: https://img.shields.io/github/tag/inveniosoftware/pynpm.svg
:target: https://github.com/inveniosoftware/pynpm/releases
.. image:: https://img.shields.io/pypi/dm/pynpm.svg
:target: https://pypi.python.org/pypi/pynpm
.. image:: https://img.shields.io/github/license/inveniosoftware/pynpm.svg
:target: https://github.com/inveniosoftware/pynpm/blob/master/LICENSE
Python interface to your NPM and package.json.
Further documentation is available on https://pynpm.readthedocs.io/.
Installation
============
PyNPM is on PyPI so all you need is:
.. code-block:: console
$ pip install pynpm
Usage
=====
First point PyNPM to your ``package.json``:
.. code-block:: python
from pynpm import NPMPackage
pkg = NPMPackage('path/to/package.json')
Now you can run e.g. ``npm install`` from within Python:
.. code-block:: python
pkg.install()
Arguments are also support so you can run e.g. ``npm run build --report``:
.. code-block:: python
pkg.run_script('build', '--report')
Want to use ``yarn`` instead?
.. code-block:: python
from pynpm import YarnPackage
pkg = YarnPackage('path/to/package.json')
pkg.install()
By default NPM output is piped through and the function call will wait for NPM
to finish. If you want to silence the output or interact with process pass
``wait=False`` and you will get a subprocess.POpen object back:
.. code-block:: python
p = pkg.install(wait=False)
p.wait()
By default you can run the following NPM commands:
* ``build``
* ``init``
* ``install``
* ``link``
* ``run-script``
* ``start``
* ``stop``
* ``test``
You can also run other NPM commands or restrict which commands you can run:
.. code-block:: python
pkg = NPMPackage('path/to/package.json', commands=['install'])
Trouble shooting
================
Windows user may face the following error when running the ``NPM`` command:
.. code-block:: console
[WinError 2] The system cannot find the file specified
It means supbrossess is unable to run the specific command. To fix this issue,
use the ``shell=True`` option uppon class initialization:
.. code-block:: python
pkg = NPMPackage('path/to/package.json', shell=True)
.. danger::
This option is not recommended for security reasons. It should only be used
on trusted inputs.
Changes
=======
Version 0.2.0 (released 2023-11-27)
- Added ``shell`` argument.
- Package structure update.
- Added ``black`` formatting.
- Dropped Python 3.6 support.
Version 0.1.2 (released 2020-05-06)
- Deprecated Python versions lower than 3.6.0. Now supporting 3.6.0 and 3.7.0.
Version 0.1.1 (released 2017-05-16)
- Fix problem with testing click CLI output.
Version 0.1.0 (released 2017-05-12)
- Initial public release.
Raw data
{
"_id": null,
"home_page": "https://github.com/inveniosoftware/pynpm",
"name": "pynpm",
"maintainer": "",
"docs_url": "https://pythonhosted.org/pynpm/",
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "npm node package.json",
"author": "CERN",
"author_email": "info@inveniosoftware.org",
"download_url": "https://files.pythonhosted.org/packages/d1/92/3cf16ff9171d104fff241d13037f4977d328aae61b4dbf610d70c734c042/pynpm-0.2.0.tar.gz",
"platform": "any",
"description": "=======\n PyNPM\n=======\n\n.. image:: https://github.com/inveniosoftware/pynpm/workflows/CI/badge.svg\n :target: https://github.com/inveniosoftware/pynpm/actions?query=workflow%3ACI\n\n.. image:: https://img.shields.io/coveralls/inveniosoftware/pynpm.svg\n :target: https://coveralls.io/r/inveniosoftware/pynpm\n\n.. image:: https://img.shields.io/github/tag/inveniosoftware/pynpm.svg\n :target: https://github.com/inveniosoftware/pynpm/releases\n\n.. image:: https://img.shields.io/pypi/dm/pynpm.svg\n :target: https://pypi.python.org/pypi/pynpm\n\n.. image:: https://img.shields.io/github/license/inveniosoftware/pynpm.svg\n :target: https://github.com/inveniosoftware/pynpm/blob/master/LICENSE\n\nPython interface to your NPM and package.json.\n\nFurther documentation is available on https://pynpm.readthedocs.io/.\n\nInstallation\n============\n\nPyNPM is on PyPI so all you need is:\n\n.. code-block:: console\n\n $ pip install pynpm\n\nUsage\n=====\n\nFirst point PyNPM to your ``package.json``:\n\n.. code-block:: python\n\n from pynpm import NPMPackage\n pkg = NPMPackage('path/to/package.json')\n\nNow you can run e.g. ``npm install`` from within Python:\n\n.. code-block:: python\n\n pkg.install()\n\nArguments are also support so you can run e.g. ``npm run build --report``:\n\n.. code-block:: python\n\n pkg.run_script('build', '--report')\n\nWant to use ``yarn`` instead?\n\n.. code-block:: python\n\n from pynpm import YarnPackage\n pkg = YarnPackage('path/to/package.json')\n pkg.install()\n\nBy default NPM output is piped through and the function call will wait for NPM\nto finish. If you want to silence the output or interact with process pass\n``wait=False`` and you will get a subprocess.POpen object back:\n\n.. code-block:: python\n\n p = pkg.install(wait=False)\n p.wait()\n\nBy default you can run the following NPM commands:\n\n* ``build``\n* ``init``\n* ``install``\n* ``link``\n* ``run-script``\n* ``start``\n* ``stop``\n* ``test``\n\nYou can also run other NPM commands or restrict which commands you can run:\n\n.. code-block:: python\n\n pkg = NPMPackage('path/to/package.json', commands=['install'])\n\nTrouble shooting\n================\n\nWindows user may face the following error when running the ``NPM`` command:\n\n.. code-block:: console\n\n [WinError 2] The system cannot find the file specified\n\nIt means supbrossess is unable to run the specific command. To fix this issue, \nuse the ``shell=True`` option uppon class initialization:\n\n.. code-block:: python\n\n pkg = NPMPackage('path/to/package.json', shell=True)\n\n.. danger:: \n\n This option is not recommended for security reasons. It should only be used\n on trusted inputs.\n\nChanges\n=======\n\nVersion 0.2.0 (released 2023-11-27)\n\n- Added ``shell`` argument.\n- Package structure update.\n- Added ``black`` formatting.\n- Dropped Python 3.6 support.\n\nVersion 0.1.2 (released 2020-05-06)\n\n- Deprecated Python versions lower than 3.6.0. Now supporting 3.6.0 and 3.7.0.\n\nVersion 0.1.1 (released 2017-05-16)\n\n- Fix problem with testing click CLI output.\n\nVersion 0.1.0 (released 2017-05-12)\n\n- Initial public release.\n\n\n",
"bugtrack_url": null,
"license": "BSD",
"summary": "\"Python interface to your NPM and package.json.\"",
"version": "0.2.0",
"project_urls": {
"Homepage": "https://github.com/inveniosoftware/pynpm"
},
"split_keywords": [
"npm",
"node",
"package.json"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "06b22289344ef62fd677ec87a453849bcb21b6c1531f5fee821f3ffe343c58f7",
"md5": "a6c0a4763bfde618f95deb83d5883dd9",
"sha256": "a04d58e4c3d46be26eaae9abd1cf59109a7670c5edd9cacd90e1d3b3afdd77c0"
},
"downloads": -1,
"filename": "pynpm-0.2.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "a6c0a4763bfde618f95deb83d5883dd9",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.7",
"size": 6100,
"upload_time": "2023-11-27T14:41:24",
"upload_time_iso_8601": "2023-11-27T14:41:24.410198Z",
"url": "https://files.pythonhosted.org/packages/06/b2/2289344ef62fd677ec87a453849bcb21b6c1531f5fee821f3ffe343c58f7/pynpm-0.2.0-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d1923cf16ff9171d104fff241d13037f4977d328aae61b4dbf610d70c734c042",
"md5": "14a9d3f39d0b4fd619b763c88db2ce2d",
"sha256": "212a1e5f86fe8b790945dd856682c6dcd8eddc6f8803a51e7046fe427d7f801b"
},
"downloads": -1,
"filename": "pynpm-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "14a9d3f39d0b4fd619b763c88db2ce2d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 17522,
"upload_time": "2023-11-27T14:41:26",
"upload_time_iso_8601": "2023-11-27T14:41:26.003548Z",
"url": "https://files.pythonhosted.org/packages/d1/92/3cf16ff9171d104fff241d13037f4977d328aae61b4dbf610d70c734c042/pynpm-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-27 14:41:26",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "inveniosoftware",
"github_project": "pynpm",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pynpm"
}