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
anddeps
.
- Generate BUILD file of all packages in a virtual environment
- Generate BUILD file of a package and its dependencies
- Activate virtual environment into the project
- 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 generatepip_library()
of all the packages and its dependencies into a BUILD file for please.build or plz.build.
- Variables
ENV_NAME
: the name of the virtual environment containing the dependencies. By default isvenv
.PYTHON_PACKAGE
: the name of the python interpreter inside the virtual environment. By default ispython
.
- Note: To generate
pip_library()
for the packages into the BUILD file, make sure that- You have virtual environment activated with the same name as the
ENV_NAME
- Have
pipdeptree
installed inside the virtual environment
- You have virtual environment activated with the same name as the
- Generating the BUILD file
-
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.
- 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- You have virtual environment activated with the same name as the
ENV_NAME
- Have
pipdeptree
installed inside the virtual environment - Have the package specified in
PACKAGE_NAME
variable installed inside the virtual environment
- You have virtual environment activated with the same name as the
- Generating the BUILD file
-
Install the specified package in the virtual environment
# Example pip install flask
-
Provide the package name in
build_package_venv_generator.py
# Example PACKAGE_NAME = 'flask'
-
Running the python file and it will generate a BUILD file
(venv)$ python build_package_venv_generator.py
-
python3 -m virtualenv venv
source venv/bin/activate
(venv)$ pip install pipdeptree
pip install pip-autoremove