Is it possible to pass arguments to setup.py while creating own .whl file?
Question:
I often update my own libs using in my projects and i want to automate it so i wrote a script which calls command which builds a .whl lib by os.system
and setup.py
module gets build params by sys.argv
but it returns as response:
invalid command name '1.0.9'
command i call: python ./LoggerLib/setup.py bdist_wheel 1.0.9
sys.argv
: ['./LoggerLib/setup.py', 'bdist_wheel', '1.0.9']
The only way i know at this moment is to write the data to other file and read it in setup.py but it isn’t elegant.
Do you know how to do it in another way?
Answers:
Yes, it is possible to pass arguments to setup.py while creating a wheel (.whl) file. The setup.py script is used to define the metadata and build instructions for your Python package, and it can accept a number of arguments that allow you to customize the build process.
To pass arguments to setup.py, you can use the setup.py script’s setup() function, which takes a number of keyword arguments that control the build process. For example, you can use the install_requires argument to specify a list of dependencies that your package requires to be installed, like this:
setup(
name='my_package',
version='1.0.0',
install_requires=['numpy', 'pandas']
)
You can then pass these arguments to setup.py when you run the setup.py script to build the wheel file, like this:
python setup.py bdist_wheel
You can also pass additional arguments to the setup.py script directly on the command line, like this:
python setup.py bdist_wheel --install-requires 'numpy pandas'
I often update my own libs using in my projects and i want to automate it so i wrote a script which calls command which builds a .whl lib by os.system
and setup.py
module gets build params by sys.argv
but it returns as response:
invalid command name '1.0.9'
command i call: python ./LoggerLib/setup.py bdist_wheel 1.0.9
sys.argv
: ['./LoggerLib/setup.py', 'bdist_wheel', '1.0.9']
The only way i know at this moment is to write the data to other file and read it in setup.py but it isn’t elegant.
Do you know how to do it in another way?
Yes, it is possible to pass arguments to setup.py while creating a wheel (.whl) file. The setup.py script is used to define the metadata and build instructions for your Python package, and it can accept a number of arguments that allow you to customize the build process.
To pass arguments to setup.py, you can use the setup.py script’s setup() function, which takes a number of keyword arguments that control the build process. For example, you can use the install_requires argument to specify a list of dependencies that your package requires to be installed, like this:
setup(
name='my_package',
version='1.0.0',
install_requires=['numpy', 'pandas']
)
You can then pass these arguments to setup.py when you run the setup.py script to build the wheel file, like this:
python setup.py bdist_wheel
You can also pass additional arguments to the setup.py script directly on the command line, like this:
python setup.py bdist_wheel --install-requires 'numpy pandas'