diff --git a/docs/basics.rst b/docs/basics.rst index ee2e6621..00f4c7d9 100644 --- a/docs/basics.rst +++ b/docs/basics.rst @@ -367,18 +367,18 @@ The only optional section is the ``@`` section. When using git o Note that it is **strongly recommended** that you install any version-controlled dependencies in editable mode, using ``pipenv install -e``, in order to ensure that dependency resolution can be performed with an up to date copy of the repository each time it is performed, and that it includes all known dependencies. -Below is an example usage which installs the git repository located at ``https://github.com/requests/requests.git`` from tag ``v2.19.1`` as package name ``requests``:: +Below is an example usage which installs the git repository located at ``https://github.com/requests/requests.git`` from tag ``v2.20.1`` as package name ``requests``:: - $ pipenv install -e git+https://github.com/requests/requests.git@v2.19#egg=requests + $ pipenv install -e git+https://github.com/requests/requests.git@v2.20.1#egg=requests Creating a Pipfile for this project... - Installing -e git+https://github.com/requests/requests.git@v2.19.1#egg=requests... + Installing -e git+https://github.com/requests/requests.git@v2.20.1#egg=requests... [...snipped...] - Adding -e git+https://github.com/requests/requests.git@v2.19.1#egg=requests to Pipfile's [packages]... + Adding -e git+https://github.com/requests/requests.git@v2.20.1#egg=requests to Pipfile's [packages]... [...] $ cat Pipfile [packages] - requests = {git = "https://github.com/requests/requests.git", editable = true, ref = "2.19.1"} + requests = {git = "https://github.com/requests/requests.git", editable = true, ref = "v2.20.1"} Valid values for ```` include ``git``, ``bzr``, ``svn``, and ``hg``. Valid values for ```` include ``http``, ``https``, ``ssh``, and ``file``. In specific cases you also have access to other schemes: ``svn`` may be combined with ``svn`` as a scheme, and ``bzr`` can be combined with ``sftp`` and ``lp``. diff --git a/news/3222.bugfix.rst b/news/3222.bugfix.rst new file mode 100644 index 00000000..2f71f552 --- /dev/null +++ b/news/3222.bugfix.rst @@ -0,0 +1 @@ +Pipenv will no longer disable user-mode installation when the ``--system`` flag is passed in. diff --git a/pipenv/core.py b/pipenv/core.py index 28d5f9a8..7624db8b 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -725,7 +725,8 @@ def batch_install(deps_list, procs, failed_deps_queue, extra_indexes = indexes[1:] with vistir.contextmanagers.temp_environ(): - os.environ["PIP_USER"] = vistir.compat.fs_str("0") + if not allow_global: + os.environ["PIP_USER"] = vistir.compat.fs_str("0") c = pip_install( dep, ignore_hashes=any([ignore_hashes, dep.editable, dep.is_vcs]), @@ -1896,7 +1897,8 @@ def do_install( ) # pip install: with vistir.contextmanagers.temp_environ(), create_spinner("Installing...") as sp: - os.environ["PIP_USER"] = vistir.compat.fs_str("0") + if not system: + os.environ["PIP_USER"] = vistir.compat.fs_str("0") try: pkg_requirement = Requirement.from_line(pkg_line) except ValueError as e: diff --git a/pipenv/project.py b/pipenv/project.py index 334782d9..f3a11f69 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -728,6 +728,18 @@ class Project(object): data[u"requires"] = {"python_version": version[: len("2.7")]} self.write_toml(data) + @classmethod + def populate_source(cls, source): + """Derive missing values of source from the existing fields.""" + # Only URL pararemter is mandatory, let the KeyError be thrown. + if "name" not in source: + source["name"] = get_url_name(source["url"]) + if "verify_ssl" not in source: + source["verify_ssl"] = "https://" in source["url"] + if not isinstance(source["verify_ssl"], bool): + source["verify_ssl"] = source["verify_ssl"].lower() == "true" + return source + def get_or_create_lockfile(self): from pipenv.vendor.requirementslib.models.lockfile import Lockfile as Req_Lockfile lockfile = None @@ -748,15 +760,7 @@ class Project(object): elif not isinstance(sources, list): sources = [sources,] lockfile_dict["_meta"]["sources"] = [ - { - "name": s.get("name", get_url_name(s.get("url"))), - "url": s["url"], - "verify_ssl": ( - s["verify_ssl"] if isinstance(s["verify_ssl"], bool) else ( - True if s["verify_ssl"].lower() == "true" else False - ) - ) - } for s in sources + self.populate_source(s) for s in sources ] _created_lockfile = Req_Lockfile.from_data( path=self.lockfile_location, data=lockfile_dict, meta_from_project=False diff --git a/tests/integration/test_lock.py b/tests/integration/test_lock.py index 2b520808..f2f0ac76 100644 --- a/tests/integration/test_lock.py +++ b/tests/integration/test_lock.py @@ -486,3 +486,20 @@ def test_lockfile_with_empty_dict(PipenvInstance): assert c.return_code == 0 assert 'Pipfile.lock is corrupted' in c.err assert p.lockfile['_meta'] + + +@pytest.mark.lock +@pytest.mark.install +def test_lock_with_incomplete_source(PipenvInstance, pypi): + with PipenvInstance(pypi=pypi, chdir=True) as p: + with open(p.pipfile_path, 'w') as f: + f.write(""" +[[source]] +url = "https://test.pypi.org/simple" + +[packages] +requests = "*" + """) + c = p.pipenv('install') + assert c.return_code == 0 + assert p.lockfile['_meta']['sources']