-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Special variable inside requirements.txt which contains path to current requirements.txt #6905
Comments
This seems to be based on a misunderstanding. Pip doesn't read Requirements files are only ever read by pip when they are explicitly referenced on the command line using the |
@pfmoore thank you for answer. Yeah, it's my mistake, i should put two lines inside projects and packages requirements to make everything work: So
Same for I still need some way to specify paths to |
It still seems like you are misusing requirements files and should be using dependency metadata. |
@pfmoore do i understand correctly that i shouldn't use |
This might help clarify. |
Thank you for article! |
Typically you shouldn't reference local packages from a parent directory in requirements.txt. Try this instead:
Then do
The order only matters here because more than likely Later on, when
If you work this way then you only need to have the packages that you want to change. If you hard-code relative paths in |
Hi @chrahunt ! Thank you for answer and thank you for suggestions! |
First of all i'm sorry for my poor English and pip skills
What's the problem this feature will solve?
This feature request is based on my stackoverflow question https://stackoverflow.com/questions/57590215/path-to-current-file-inside-requirements-txt
Pip allow to specify path to other packages in requirements.txt. For example
-e path/to/some/package
. It allow pip users to reuse local packages between local projectsFor example suppose i have following structure of folders:
package2
depends onpackage1
, sopackage2/requirements.txt
contains following string-e ../package1/
. So if my projects depends onpackage2
i can perform something likepip install -e project2
and it will installpackage1
too. But unfortunately, it will not work if my project is not at the same folder level with my packages.For example, if my project is
project1
andproject1/requirements.txt
contains-e ../my_collection_of_packages/package2/
it's impossible to installpackage2/requirements.txt
because it contains relative path../package1/
which is equalproject1/../package1/
if we runpackage2/requirements.txt
.Describe the solution you'd like
From my point of view a special variable which contains path to current requirements.txt can be solution for this problem. I have no idea which name is better, but suppose it is
${requirements_pwd}
. So nowpackage2/requirements.txt
can referencepackage1
by-e ${requirements_pwd}/../package1/
Andproject1
can referencepackage2
as-e ${requirements_pwd}/../my_collection_of_packages/package2/
Alternative Solutions
It's possible to achieve same result by using absolute paths, but this makes usage of packages on different machines almost impossible.
For linux another solution is to define environment variable
${package_collection}
and use it insiderequirements.txt
. For examplepackage2/requirements.txt
should be${package_collection}/my_collection_of_packages/package1/
. Have no idea how to make it work on windows and linux simultaneouslyAdditional context
Link to stackoverflow question: https://stackoverflow.com/questions/57590215/path-to-current-file-inside-requirements-txt
Thank in advance. Please let me know if something wrong with my problem statement.
The text was updated successfully, but these errors were encountered: