mirror of
https://github.com/kennethreitz/pipenv.git
synced 2026-06-05 22:50:18 +00:00
Merge pull request #3264 from pypa/bugfix/3260
Fix pipfile creation with unnamed project
This commit is contained in:
@@ -0,0 +1 @@
|
||||
Fixed an issue which sometimes prevented successful creation of project pipfiles.
|
||||
+7
-7
@@ -1712,14 +1712,8 @@ def do_install(
|
||||
# Don't search for requirements.txt files if the user provides one
|
||||
if requirements or package_args or project.pipfile_exists:
|
||||
skip_requirements = True
|
||||
# Don't attempt to install develop and default packages if Pipfile is missing
|
||||
if not project.pipfile_exists and not (package_args or dev) and not code:
|
||||
if not (ignore_pipfile or deploy):
|
||||
raise exceptions.PipfileNotFound(project.path_to("Pipfile"))
|
||||
elif ((skip_lock and deploy) or ignore_pipfile) and not project.lockfile_exists:
|
||||
raise exceptions.LockfileNotFound(project.path_to("Pipfile.lock"))
|
||||
concurrent = not sequential
|
||||
# Ensure that virtualenv is available.
|
||||
# Ensure that virtualenv is available and pipfile are available
|
||||
ensure_project(
|
||||
three=three,
|
||||
python=python,
|
||||
@@ -1729,6 +1723,12 @@ def do_install(
|
||||
skip_requirements=skip_requirements,
|
||||
pypi_mirror=pypi_mirror,
|
||||
)
|
||||
# Don't attempt to install develop and default packages if Pipfile is missing
|
||||
if not project.pipfile_exists and not (package_args or dev) and not code:
|
||||
if not (ignore_pipfile or deploy):
|
||||
raise exceptions.PipfileNotFound(project.path_to("Pipfile"))
|
||||
elif ((skip_lock and deploy) or ignore_pipfile) and not project.lockfile_exists:
|
||||
raise exceptions.LockfileNotFound(project.path_to("Pipfile.lock"))
|
||||
# Load the --pre settings from the Pipfile.
|
||||
if not pre:
|
||||
pre = project.settings.get("allow_prereleases")
|
||||
|
||||
@@ -693,6 +693,7 @@ class Project(object):
|
||||
ConfigOptionParser, make_option_group, index_group
|
||||
)
|
||||
|
||||
name = self.name if self.name is not None else "Pipfile"
|
||||
config_parser = ConfigOptionParser(name=self.name)
|
||||
config_parser.add_option_group(make_option_group(index_group, config_parser))
|
||||
install = config_parser.option_groups[0]
|
||||
|
||||
@@ -223,13 +223,14 @@ class _PipenvInstance(object):
|
||||
os.umask(self.original_umask)
|
||||
|
||||
def pipenv(self, cmd, block=True):
|
||||
if self.pipfile_path:
|
||||
if self.pipfile_path and os.path.isfile(self.pipfile_path):
|
||||
os.environ['PIPENV_PIPFILE'] = fs_str(self.pipfile_path)
|
||||
# a bit of a hack to make sure the virtualenv is created
|
||||
|
||||
with TemporaryDirectory(prefix='pipenv-', suffix='-cache') as tempdir:
|
||||
os.environ['PIPENV_CACHE_DIR'] = fs_str(tempdir.name)
|
||||
c = delegator.run('pipenv {0}'.format(cmd), block=block)
|
||||
c = delegator.run('pipenv {0}'.format(cmd), block=block,
|
||||
cwd=os.path.abspath(self.path))
|
||||
if 'PIPENV_CACHE_DIR' in os.environ:
|
||||
del os.environ['PIPENV_CACHE_DIR']
|
||||
|
||||
|
||||
@@ -418,3 +418,16 @@ requests
|
||||
)
|
||||
c = p.pipenv("install --system")
|
||||
assert c.return_code == 0
|
||||
|
||||
|
||||
@pytest.mark.install
|
||||
def test_install_creates_pipfile(PipenvInstance):
|
||||
with PipenvInstance(chdir=True) as p:
|
||||
if os.path.isfile(p.pipfile_path):
|
||||
os.unlink(p.pipfile_path)
|
||||
if "PIPENV_PIPFILE" in os.environ:
|
||||
del os.environ["PIPENV_PIPFILE"]
|
||||
assert not os.path.isfile(p.pipfile_path)
|
||||
c = p.pipenv("install")
|
||||
assert c.return_code == 0
|
||||
assert os.path.isfile(p.pipfile_path)
|
||||
|
||||
Reference in New Issue
Block a user