Python configuration requirements module name setup.py

I have a codebase that needs a specific version of a module. I also have another tool that I am using that uses a different version of the module. I am trying to get these two code files to play well with each other.

For example: Codebase A requires foomodule == 1.2 and Codebase B requires foomodule == 2.0

How to install Codebase A using pip (so through setup.py) so that it doesn't overwrite foomodule == 2.0

setup.py

setup_options = dict(
    install_requires=['foomodule==1.2']

      


If I go and manually change the folder name foomodule

in the dist packages to foomodule1.2

, I can then fix the problem by replacing all occurrences of "foomodule" in my codebase. But how to do this programmatically during setup.py?

I can potentially install foomodule somewhere else, rename it and move it to dist packages. Is there a way to install the required package to a custom location?

Perhaps something like:

setup_options = dict(
    install_requires=[('foomodule==1.2', location_of_install)]
)

setup(**setup_options)

new_location = os.join(distutils.sysconfig.get_python_lib(), 'foomodule1.2')
shutil.copyfile(location_of_install, new_location)

      

+3


source to share





All Articles