Fix handling git requirements in setup

pull/2477/head
vzotova 2020-12-20 12:27:59 +03:00
parent c6491f548d
commit a2b133354a
1 changed files with 17 additions and 1 deletions

View File

@ -24,6 +24,8 @@ import os
import subprocess
import sys
from pathlib import Path
from urllib.parse import urlparse
from setuptools import find_packages, setup
from setuptools.command.develop import develop
from setuptools.command.install import install
@ -98,7 +100,21 @@ class PostDevelopCommand(develop):
def read_requirements(path):
with open(os.path.join(BASE_DIR, path)) as f:
_pipenv_flags, *requirements = f.read().split('\n')
_pipenv_flags, *lines = f.read().split('\n')
# Transforms VCS requirements to PEP 508
requirements = []
for line in lines:
if line.startswith('-e git:') or line.startswith('-e git+') or \
line.startswith('git:') or line.startswith('git+'):
# parse out egg=... fragment from VCS URL
parsed = urlparse(line)
egg_name = parsed.fragment.partition("egg=")[-1]
without_fragment = parsed._replace(fragment="").geturl()
requirements.append(f"{egg_name} @ {without_fragment}")
else:
requirements.append(line)
return requirements