[SOLVED] How to Install dependency module locally?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am very new to python (though I have some programming experience), so I am not sure if I understand it correctly or not.
I have two projects A, and B where A depends on B (both contains setup.py files). Usually I will do following operations
Code:
vritualenv -p python3 .env
source .env/bin/activate
pip3 install <moudule name 1>
pip3 install <moudule name 2>
...
Now I want to modify the dependency B in order to test some functions in the project A. After searching on the internet, it seems that I can simply execute
Code:
python3 install -e .
to install the project. But how can I install module/ project B in the project A? I am confused with this because if I execute in the project A dir, then it simply installs project A by python3 install -e .. Is there any way to achieve my goal?
Thanks for any suggestions.
Last edited by shogun1234; 03-04-2020 at 08:02 AM.
That's close to what I am looking for. But the projects are more complicated (My explanation could be wrong because I am not familiar with python. Apologize if my explanation is still not clear enough).
Suppose the project A has a setup.py file where the project B is another complicated project (and the project B can be installed by pip as well). Now I want to modify the code in the project B (the project B is downloaded by `git clone https://github.com/... /path/to/projectB`). And I want the change (in the project B) to be reflected in the project A (which is also downloaded by `git clone https://github.com/... /path/to/projectA`). For instance, A call a function in the project B which originally throws an APIError, which extends IOError. Now I want to modify the code in the project B by switching class APIError(IOError) to class APIError(HttpError). After modifying the code in the project B, how can I make this change to be reflected in the project A?
Hope this explanation would be a bit more clear. Thank you again for your help!
Code:
install_requires = [
"python-dateutil<2.8.1,>=2.1",
"ply>=3.9",
"colorama>=0.3.9",
...
]
...
setup(
name=...,
version=version,
description="...",
long_description=open("README.rst", "r").read(),
author="...",
author_email="...",
download_url="https://github.com/...",
license="Apache License 2.0",
install_requires=install_requires,
extras_require={
"all": ["project_B>=1.4.5", ...], # the project B is one of dep of the project A
...
}
...
)
Quote:
Originally Posted by teckk
If I understand what you are wanting.
a.py
Code:
from time import sleep
def count():
for i in range(0, 10)
print(i)
sleep(1)
b.py
Code:
import sys
sys.path.append('/dir/where/a.py/is')
from a import count
count()
After modifying the code in the project B, how can I make this change to be reflected in the project A?
I think this Python documentation is saying you update the version number then run pip install with --upgrade parameter - changing the version alone is not enough. (Seems like a flaw in pip that it can't detect that and upgrade for you.)
Really sorry that my explain looks not very clear, or if I misunderstand the meaning for my bad English : (
I don't have privilege to touch the project B's repo. So I can't publish project B's artifact to public remote repo, and then do `pip install ...` operation. What I want to do is more close to publishM2 or publish-local so that I can test if my change looks working or not. I might submit my patch to upstream (i.e. project B) but basically my primary intention is to test my change locally before doing anything else. So the procedure I am looking to is
1. Modify some code in the project B
2. Publish the change of project B locally which can be referenced by the project A.
3. Test the change in the project A to see if the change (in the project B) is working or not.
In addition, the project A uses virtualenv with the param -p python3. So I want to publish the project B artifact to project A's virtualenv in fact. For instance, searching the file I want to modify, I find the module is located at following path
Code:
./.env/lib/python3.7/site-packages/<project B>
Many thanks for all your help.
Last edited by shogun1234; 03-04-2020 at 05:13 AM.
Before the step 2, you might want to check if the project B's artifact has already been installed or not. If it shows something as below, one can unisntall first by pip3 uninstall projectB
Code:
Requirement already satisfied: projectB==<version> from file:///path/to/projectB/dist/projectB-<version>-py3-none-any.whl in /path/to/projectB (<version>)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.