Skip to content

Commit

Permalink
Handle requirement local path in editable mode
Browse files Browse the repository at this point in the history
Fixes arkq#36
  • Loading branch information
arkq committed Apr 5, 2021
1 parent f399728 commit bedd1a3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/flake8_requirements/checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,9 @@ def resolve_requirement(cls, requirement, max_depth=0, path=None):
option = option_match.group(1)
requirement = option_match.group(2).lstrip()

editable = False
if option in ("-e", "--editable"):
editable = True
# We do not care about installation mode.
option = None

Expand All @@ -466,7 +468,7 @@ def resolve_requirement(cls, requirement, max_depth=0, path=None):
# Skip whole line if option was not processed earlier.
return []

# Check for a requirement given as a VSC link.
# Check for a requirement given as a VCS link.
vcs_match = cls._requirement_match_vcs(requirement)
vcs_spec_match = cls._requirement_match_vcs_spec(
vcs_match.group(2) if vcs_match is not None else "")
Expand All @@ -485,6 +487,14 @@ def resolve_requirement(cls, requirement, max_depth=0, path=None):
"{} == {}".format(name, version[1:])
]

# Editable installation is made either from local path or from VCS
# URL. In case of VCS, the URL should be already handled in the if
# block above. Here we shall get a local project path.
if editable:
requirement = os.path.basename(requirement)
if requirement.split()[0] == ".":
requirement = ""

# Extract requirement specifier (skip in-line options).
spec_match = cls._requirement_match_spec(requirement)
if spec_match is not None:
Expand Down
1 change: 1 addition & 0 deletions test/test_requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,5 +223,6 @@ def test_init_misc(self):
"exPackage_paint == 1.4.8.dev1984+49a8814",
"package-one",
"package-two",
"whiteBox",
])),
)
6 changes: 6 additions & 0 deletions test/test_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,9 @@ http://example.com/snapshot-builds/exPackage_paint-1.4.8.dev1984+49a8814-cp34-no
###### Requirements from a VCS ######
git+git://github.com/path/to/package-one@releases/tag/v3.1.4#egg=package-one
git+git://github.com/path/to/package-two@master#egg=package-two&subdirectory=src

###### Install local project in a develop mode ######
--editable /opt/whiteBox # Local proprietary package

###### Install THIS project in a develop mode ######
--editable .

0 comments on commit bedd1a3

Please sign in to comment.