I’m trying to generate a Python module with information provided from the pip install
command. I have project with the following structure:
top_repository/
|/setup.py
|/requirements.txt
|/my_proj
|/__init__.py
|/__main__.py
|/_version.py
|/conf.py
The setup.py
is:
from setuptools import setup, find_packages
from distutils.util import convert_path
def get_requirements():
with open('requirements.txt') as fp:
return fp.read()
def get_version():
st = {}
version_file = convert_path('my_proj/_version.py')
with open(version_file) as f:
exec(f.read(), st)
return st['_version']
setup(name='my_proj',
version=get_version(),
description='My Proj',
packages=find_packages(),
zip_safe=False)
Then, I create the wheel with python setup.py bdist_wheel
I’m looking for a way to get an argument from a pip option and add the argument (say --cfg_dir
) to the conf.py
file during the wheel installation. For instance, if I run:
$ pip install my_proj-0.0.1-py3-none-any.whl --target /usr/alternate/site-packages --cfg_dir /path/to/cfg_dir
Pip/setuptools will update the conf.py
with:
CONF_DIR="/path/to/cfg_dir"
I’m using Python 3.9.18 and setuptools 53.0;0
I appreciate any help! Thanks in advance.
At this point, I have been searching around without any good pointers.
lrbbs is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.