I'm working on a Python project that uses pyproject.toml, which is part of the PEP517 feature set. While this file often utilizes setuptools, I still rely on a setup.py file that includes arguments like --no-cuda. I'm trying to figure out how to pass these arguments to setup.py when my project is configured and built with pyproject.toml. Any insights would be appreciated!
5 Answers
Instead of passing arguments to setup.py directly, consider making CUDA support optional dependencies. For instance, you could structure it like this: `pip install foo[cuda]`.
Can you share an example of what you're trying to achieve? Generally, with a pyproject.toml, setup.py isn't even needed anymore, and using install-time CLI arguments isn't recommended since they can be tough to access via package managers.
You might just want to stop using setup.py altogether. It's quite outdated.
Have you thought about using a config.yaml file instead? Users could easily edit the YAML file to toggle settings like this. The PyYAML library makes loading it into your scripts super simple! For example:
```yaml
# config.yaml
use_cuda: true
```
And then in your Python script, you can load it like this:
```python
import yaml
config_path = 'path/to/config.yaml'
with open(config_path, 'r') as file:
config_dict = yaml.safe_load(file)
use_cuda = config['use_cuda']
...```
Are you really looking to pass CLI arguments to setup.py, or do you actually want to send CLI args to your app's entry point when it's executing?

That's a great point! It makes it easier for users to install only the features they need.