Skip to content

Generate python-based please.build BUILD file imported from installed python third-party dependencies

Notifications You must be signed in to change notification settings

ThyMakra/python-please-build-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Generate please.build BUILD file for installed Python packages

While Please is a really great build system with many awesome features like cross-language support, explicit declaration etc. It is still a headache to import the installed packages/libraries into a BUILD file.

With the help of Python tools such as pipdeptree, it eases a lot of hard works but you still need to manually write down each build rule for every dependencies. It can get really challenging when you encounter with a library that has many dependencies and each has its own sub-level dependencies and so on.

This repository is created with the purpose to make the process of importing installed libraries into BUILD file quicker and easier.

Note: Important things to note is that this project can not be integrated (yet) into your existing project or application and need to be isolated with its own virtual environment.

  • It can be cloned to run independently to get build rules for one or more Python packages.
  • Though it still has limitations for it can only support 3 rules (currently) such as, name, version and deps.

Table of Content

  1. Generate BUILD file of all packages in a virtual environment
  2. Generate BUILD file of a package and its dependencies

Pre-requisite

  1. Activate virtual environment into the project
  2. Package pipdeptree installed inside the virtual environment

Generate plz.build BUILD file of all packages in a virtual environment

Generating a BUILD file from all packages inside a virtual environment. This can be used for :

  • When you have all required packages of a project (for example, inside a requirements.txt) and you want to generate pip_library() of all the packages and its dependencies into a BUILD file for please.build or plz.build.

Usage

  • Variables
    • ENV_NAME : the name of the virtual environment containing the dependencies. By default is venv.
    • PYTHON_PACKAGE : the name of the python interpreter inside the virtual environment. By default is python.
  • Note: To generate pip_library() for the packages into the BUILD file, make sure that
    1. You have virtual environment activated with the same name as the ENV_NAME
    2. Have pipdeptree installed inside the virtual environment
  • Generating the BUILD file
    1. Running the python file and it will generate a BUILD file

      (venv)$ python build_dep_venv_generator.py

Generate plz.build BUILD file of a package and its dependencies

Generating a BUILD file for only one package inside a virtual environment. This can be used for :

  • When you want to generate pip_library() for only one specific package and its dependencies into a BUILD file for please.build or plz.build.

Usage

  • Required Variables
    • PACKAGE_NAME : the name of the package that
  • Note: To generate pip_library() for the packages into the BUILD file, make sure that
    1. You have virtual environment activated with the same name as the ENV_NAME
    2. Have pipdeptree installed inside the virtual environment
    3. Have the package specified in PACKAGE_NAME variable installed inside the virtual environment
  • Generating the BUILD file
    1. Install the specified package in the virtual environment

      # Example
      pip install flask 
    2. Provide the package name in build_package_venv_generator.py

      # Example
      PACKAGE_NAME = 'flask'
    3. Running the python file and it will generate a BUILD file

      (venv)$ python build_package_venv_generator.py

Other Procedure

Activate a virtual environment

python3 -m virtualenv venv
source venv/bin/activate

Install pipdeptree

(venv)$ pip install pipdeptree

Install pip-autoremove

pip install pip-autoremove

About

Generate python-based please.build BUILD file imported from installed python third-party dependencies

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages