Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nxlv/python

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nxlv/python

Custom NX Plugin to support the Python language

  • 1.9.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
22K
increased by16.72%
Maintainers
1
Weekly downloads
 
Created
Source

@nxlv/python

This library was generated with Nx.

What is Nx

🔎 Extensible Dev Tools for Monorepos.

What is @nxlv/python

🔎 An Nx Custom Plugin to generate Python projects using Poetry, Tox and a custom dependency tree plugin

Getting Started

Add to an existing Nx Workspace

Install the npm dependency

npm install @nxlv/python --save-dev

Usage

  1. Update nx.json to add the property plugins with @nxlv/python value.

Example:

{
  ...
  "affected": {
    "defaultBase": "main"
  },
  "plugins": [
    "@nxlv/python"
  ],
  "cli": {
    "defaultCollection": "@nrwl/workspace"
  },
  ...
}
Add a new Python Project
nx generate @nxlv/python:project myproject
Options
OptionTypeDescriptionRequiredDefault
--typestringProject type application or librarytrueapplication
--descriptionstringProject descriptionfalse
--directorystringA directory where the project is placedfalse
--packageNamestringPackage nametrue
--publishablebooleanSpeficies if the project is publishable or notfalsetrue
--customSourcebooleanSpeficies if the project uses custom PyPi registryfalsefalse
--sourceNamestringCustom PyPi registry nameonly if the --customSource is true
--sourceUrlstringCustom PyPi registry urlonly if the --customSource is true
--sourceSecondarybooleanCustom PyPi registry secondary flagonly if the --customSource is truetrue
--tagsstringAdd tags to the projectfalse
Add a new dependency to a project
nx run {project}:add --name {projectName} --local
Add an external dependency to the project

To add a new dependency to the project use the nx run {project}:add command detailed below. This ensures that any dependent projects are updated.

nx run {project}:add --name {dependencyName}

Executors

sls-deploy

The @nxlv/python:sls-deploy executor handles npx sls deploy command for serverless framework projects.

This executor uses the @nxlv/python:build artifacts to generate a requirements.txt and to be used with serverless-python-requirements plugin.

Serverless YAML example:

service: myservice

plugins:
  - serverless-python-requirements

custom:
  pythonRequirements:
    usePoetry: false

The property usePoetry must be false, so, the serverless-python-requirements uses the requirements.txt file generated by this executor, this is required when the project has more than 2 levels of local dependencies.

Example:

- root:
  - sls-app
   - local-lib1
    - local-lib2

Using the native serverless-python-requirements plugin with poetry the 2 levels of local dependencies are not supported.

project.json example:

{
  "$schema": "../../node_modules/nx/schemas/project-schema.json",
  "projectType": "application",
  "sourceRoot": "apps/myapp/lambda_functions",
  "targets": {
    "deploy": {
      "executor": "@nxlv/python:sls-deploy",
      "dependsOn": ["build"],
      "options": {}
    },
    "package": {
      "executor": "@nxlv/python:sls-package",
      "dependsOn": ["build"],
      "options": {}
    },
    ...
    "build": {
      "executor": "@nxlv/python:build",
      "outputs": ["apps/myapp/dist"],
      "options": {
        "outputPath": "apps/myapp/dist",
        "publish": false
      }
    },
  }
}
Options
OptionTypeDescriptionRequiredDefault
--stagestringServerless Framework stahe nametrue
--verbosebooleanServerless Framework CLI verbose flagfalsetrue
--forcebooleanServerless Framework CLI force flagfalsefalse
add

The @nxlv/python:add executor handles poetry add command to provide a level of abstraction and control in the monorepo projects.

Features
  • Add new external dependencies
  • Add local dependencies

Both features updates the local workspace dependency tree to keep the lock/venv updated.

Options
OptionTypeDescriptionRequiredDefault
--namestringDependency name (if local dependency use the Nx project name)true
--argsstringCustom args to be used in the poetry add commandfalse
--localbooleanSpecifies if the dependency is localfalse (only if the --name is a local dependency)
update

The @nxlv/python:update executor handles poetry update command to provide a level of abstraction and control in the monorepo projects.

Features
  • Update external dependencies
  • Update local dependencies

Both features updates the local workspace dependency tree to keep the lock/venv updated.

Options
OptionTypeDescriptionRequiredDefault
--namestringDependency name (if local dependency use the Nx project name)false
--argsstringCustom args to be used in the poetry update commandfalse
--localbooleanSpecifies if the dependency is localfalse (only if the --name is a local dependency)
remove

The @nxlv/python:remove executor handles poetry remove command to provide a level of abstraction and control in the monorepo projects.

Features
  • Remove external dependencies
  • Remove local dependencies

Both features updates the local workspace dependency tree to keep the lock/venv updated.

Options
OptionTypeDescriptionRequiredDefault
--namestringDependency name (if local dependency use the Nx project name)true
--argsstringCustom args to be used in the poetry remove commandfalse
--localbooleanSpecifies if the dependency is localfalse (only if the --name is a local dependency)
build

The @nxlv/python:build command handles the sdist and wheel build generation. When the project has local dependencies the executor copies the package/dependencies recursively.

Options
OptionTypeDescriptionRequiredDefault
--silentbooleanHide output textfalsefalse
--outputPathstringOutput path for the python tar/whl filestrue
--keepBuildFolderbooleanKeep build folderfalsefalse
--ignorePathsarrayIgnore folder/files on build processfalse[".venv", ".tox", "tests"]
flake8

The @nxlv/python:flake8 handles the flake8 linting tasks and reporting generator.

Options
OptionTypeDescriptionRequiredDefault
--silentbooleanHide output textfalsefalse
--outputFilestringOutput pylint file pathtrue
install

The @nxlv/python:install handles the poetry install command for a project.

Options
OptionTypeDescriptionRequiredDefault
--silentbooleanHide output textfalsefalse
--argsstringCustom arguments (e.g --group dev)false
--cacheDirstringCustom poetry install cache directoryfalse
--verbosebooleanUse verbose mode in the install poetry install -vvfalsefalse
--debugbooleanUse debug mode in the install poetry install -vvvfalsefalse
tox

The @nxlv/python:tox handles tox executions for a project.

Options
OptionTypeDescriptionRequiredDefault
--silentbooleanHide output textfalsefalse
--argsstringCustom arguments (e.g -e py38)false

FAQs

Package last updated on 19 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc