[Python-Dev] Feature request: Change a Dependency Package Version During Package Initiation

Q qiang.fang at zoho.com.cn
Fri May 17 22:26:04 EDT 2019


>From the viewpoint of the package user, people don't want to change every import to "require a version at runtime". If "set up a python path in a wrapper script" is a better strategy, can you please give an example for the following use case:


The abaqus python distribution has libA 1.0, the external package to be installed is LibB, which requires libA2.0, and we don't want to change every import in LibB to be import libA 1.0, because the source code may have not been provided.

In emacs, you can always advice a command to change its behaviour, which makes it very user friendly, and that what all the following suggestion is about. I have no idea at all how it could be implemented though.

https://github.com/mitsuhiko/multiversion/issues/1

"The work around is to let a version to be set within a package and have that propagate to all modules in that package. For example in the root init.py if I set tonado version to be 2.2.1 then all modules in that package will use tornado 2.2.1 when I import tornado."



---- 在 星期五, 2019-05-17 23:38:55 Daniel Holth <dholth at gmail.com> 撰写 ----



This sounds exactly like what people used to do with eggs. You could have multiple versions of a package on the path as eggs and then require a version at runtime. The approach has problems. Ruby also abandoned a strategy where random app code depends on package management code at runtime.



One better strategy is to set up a python path in a wrapper script.




On Fri, May 17, 2019, 11:27 Brett Cannon <mailto:bcannon at gmail.com> wrote:





Thanks for the idea but there are currently no plans to support such a feature. If you would like to see it then you will need to write a PEP with a proof-of-concept to demonstrate how you would expect such a feature to work.



On Fri., May 17, 2019, 07:55 Q via Python-Dev, <mailto:python-dev at python.org> wrote:



A lot of the Python code we use in production are used directly as imports in other python

distributions (such as the python comes with the finite element software Abaqus and MSC Marc), many

packages (such as matplotlib, numpy) that may have varying versioned dependencies.



I was wondering if this could be expanded to allow a version to be set within a package and have

that propagate to all modules in that package. For example in the root init.py if I set

multiversion(tornado, 2.2.1) then all modules in that package will use tornado 2.2.1 when I import

tornado.



See a relevant issue on github:

https://github.com/mitsuhiko/multiversion/issues/1



Thank you!

Qiang





_______________________________________________

 Python-Dev mailing list

 mailto:Python-Dev at python.org

 https://mail.python.org/mailman/listinfo/python-dev

 Unsubscribe: https://mail.python.org/mailman/options/python-dev/brett%40python.org



_______________________________________________

 Python-Dev mailing list

 mailto:Python-Dev at python.org

 https://mail.python.org/mailman/listinfo/python-dev

 Unsubscribe: https://mail.python.org/mailman/options/python-dev/dholth%40gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20190518/f7e3a65e/attachment.html>


More information about the Python-Dev mailing list