script analysis
Dependencies
The script starts by importing necessary modules:
platform
module to retrieve information about the operating system.re
module for regular expressions.PackageNotFoundError
andversion
fromimportlib.metadata
for handling package versions.find_packages
andsetup
fromsetuptools
for package discovery and setup configuration.
Parse Requirements
The parse_requirements()
function is defined to parse the requirements.txt
file:
It initializes two lists:
_install_requires
for standard package requirements and_dependency_links
for custom index URLs.It opens the
requirements.txt
file, reads each line, and strips any whitespace.It checks each line to determine if it is an extra requirement (e.g., "flash-attn", "deepspeed", etc.) or a standard package requirement.
If the line starts with "--extra-index-url", it extracts the URL and appends it to
_dependency_links
.If the line is not an extra requirement and is not empty or a comment, it appends the line to
_install_requires
.
Platform-specific requirements
If the operating system is "Darwin" (macOS), it removes the "xformers==0.0.22" requirement from
_install_requires
.If the operating system is not "Darwin", it retrieves the version of the "torch" package using
version("torch")
.It appends the "torch" package requirement with the specific version to
_install_requires
.It parses the "torch" version using a regular expression to extract the major, minor, and patch version numbers.
If the "torch" version is greater than or equal to "2.1", it removes the "xformers==0.0.22" requirement and appends "xformers>=0.0.23" to
_install_requires
.If the "torch" package is not found, it skips this step.
The setup()
function is called to configure the package
setup()
function is called to configure the packageIt sets the package name to "axolotl".
It specifies the version as "0.4.0".
It provides a short description and a long description for the package.
It sets the package directory to "src".
It uses
find_packages()
to automatically discover packages within the "src" directory.It sets the
install_requires
parameter to theinstall_requires
list obtained fromparse_requirements()
.It sets the
dependency_links
parameter to thedependency_links
list obtained fromparse_requirements()
.It defines extra requirements using the
extras_require
parameter, specifying additional dependencies for different features like "flash-attn", "deepspeed", "mamba-ssm", "auto-gptq", "mlflow", "lion-pytorch", and "galore".
Overall, this setup.py script is responsible for configuring the "axolotl" package, specifying its dependencies, handling platform-specific requirements, and defining extra requirements for optional features.
It provides a flexible and customisable setup for the package, allowing users to install the necessary dependencies based on their specific needs.
Last updated