- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 636
 
Add support for relative requirements in pip_install #433
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
          
     Merged
      
      
            alexeagle
  merged 10 commits into
  bazel-contrib:main
from
aaliddell:support-local-wheel-alt
  
      
      
   
  Oct 26, 2021 
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            10 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      cc64022
              
                Run pip within the directory containing the requirements.txt file
              
              
                aaliddell dd1c8cf
              
                Print test errors of sub-workspaces in bazel_integration_test
              
              
                aaliddell e3b8daa
              
                Add example of relative requirement as test
              
              
                aaliddell 10e1624
              
                Explicitly cast Path to str to support Python 3.5
              
              
                aaliddell d4940e8
              
                Merge branch 'master' into support-local-wheel-alt
              
              
                aaliddell 2cc295b
              
                Merge branch 'main' into support-local-wheel-alt
              
              
                aaliddell 550afc9
              
                Fix multiple declarations of pip_args
              
              
                aaliddell 96c30be
              
                Apply buildifier fix
              
              
                aaliddell 31dcf04
              
                Merge branch 'main' into support-local-wheel-alt
              
              
                alexeagle 5a04eb2
              
                Merge branch 'main' into support-local-wheel-alt
              
              
                alexeagle File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| load("@pip//:requirements.bzl", "requirement") | ||
| load("@rules_python//python:defs.bzl", "py_test") | ||
| 
     | 
||
| py_test( | ||
| name = "main", | ||
| srcs = ["main.py"], | ||
| deps = [ | ||
| requirement("relative_package_name"), | ||
| ], | ||
| ) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # relative_requirements example | ||
| 
     | 
||
| This example shows how to use pip to fetch relative dependencies from a requirements.txt file, | ||
| then use them in BUILD files as dependencies of Bazel targets. | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| workspace(name = "example_repo") | ||
| 
     | 
||
| load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | ||
| 
     | 
||
| http_archive( | ||
| name = "rules_python", | ||
| sha256 = "b6d46438523a3ec0f3cead544190ee13223a52f6a6765a29eae7b7cc24cc83a0", | ||
| url = "https://github.com/bazelbuild/rules_python/releases/download/0.1.0/rules_python-0.1.0.tar.gz", | ||
| ) | ||
| 
     | 
||
| load("@rules_python//python:pip.bzl", "pip_install") | ||
| 
     | 
||
| pip_install( | ||
| requirements = "//:requirements.txt", | ||
| ) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| import relative_package_name | ||
| 
     | 
||
| if __name__ == "__main__": | ||
| # Run a function from the relative package | ||
| print(relative_package_name.test()) | 
        
          
  
    
      
          
            2 changes: 2 additions & 0 deletions
          
          2 
        
  examples/relative_requirements/relative_package/relative_package_name/__init__.py
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| def test(): | ||
| return True | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| from setuptools import setup | ||
| 
     | 
||
| setup( | ||
| name='relative_package_name', | ||
| version='1.0.0', | ||
| packages=['relative_package_name'], | ||
| ) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ./relative_package | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.