Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change lock file name from pyproject.lock to poetry.lock #447

Merged
merged 2 commits into from
Oct 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions docs/docs/basic-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Poetry uses this information to search for the right set of files in package "re
in the `tool.poetry.repositories` section, or on [PyPI](https://pypi.org) by default.

Also, instead of modifying the `pyproject.toml` file by hand, you can use the `add` command.

```bash
$ poetry add pendulum
```
Expand All @@ -75,50 +75,50 @@ Please read [versions](/versions/) for more in-depth information on versions, ho
!!!note

**How does Poetry download the right files?**

When you specify a dependency in `pyproject.toml`, Poetry first take the name of the package
that you have requested and searches for it in any repository you have registered using the `repositories` key.
If you have not registered any extra repositories, or it does not find a package with that name in the
repositories you have specified, it falls back on PyPI.

When Poetry finds the right package, it then attempts to find the best match
for the version constraint you have specified.


## Installing dependencies

To install the defined dependencies for your project, just run the `install` command.

```bash
poetry install
```

When you run this command, one of two things may happen:

### Installing without `pyproject.lock`
### Installing without `poetry.lock`

If you have never run the command before and there is also no `pyproject.lock` file present,
If you have never run the command before and there is also no `poetry.lock` file present,
Poetry simply resolves all dependencies listed in your `pyproject.toml` file and downloads the latest version of their files.

When Poetry has finished installing, it writes all of the packages and the exact versions of them that it downloaded to the `pyproject.lock` file,
When Poetry has finished installing, it writes all of the packages and the exact versions of them that it downloaded to the `poetry.lock` file,
locking the project to those specific versions.
You should commit the `pyproject.lock` file to your project repo so that all people working on the project are locked to the same versions of dependencies (more below).
You should commit the `poetry.lock` file to your project repo so that all people working on the project are locked to the same versions of dependencies (more below).


### Installing with `pyproject.lock`
### Installing with `poetry.lock`

This brings us to the second scenario. If there is already a `pyproject.lock` file as well as a `pyproject.toml` file
This brings us to the second scenario. If there is already a `poetry.lock` file as well as a `pyproject.toml` file
when you run `poetry install`, it means either you ran the `install` command before,
or someone else on the project ran the `install` command and committed the `pyproject.lock` file to the project (which is good).
or someone else on the project ran the `install` command and committed the `poetry.lock` file to the project (which is good).

Either way, running `install` when a `pyproject.lock` file is present resolves and installs all dependencies that you listed in `pyproject.toml`,
but Poetry uses the exact versions listed in `pyproject.lock` to ensure that the package versions are consistent for everyone working on your project.
Either way, running `install` when a `poetry.lock` file is present resolves and installs all dependencies that you listed in `pyproject.toml`,
but Poetry uses the exact versions listed in `poetry.lock` to ensure that the package versions are consistent for everyone working on your project.
As a result you will have all dependencies requested by your `pyproject.toml` file,
but they may not all be at the very latest available versions
(some of the dependencies listed in the `pyproject.lock` file may have released newer versions since the file was created).
(some of the dependencies listed in the `poetry.lock` file may have released newer versions since the file was created).
This is by design, it ensures that your project does not break because of unexpected changes in dependencies.

### Commit your `pyproject.lock` file to version control
### Commit your `poetry.lock` file to version control

Committing this file to VC is important because it will cause anyone who sets up the project
to use the exact same versions of the dependencies that you are using.
Expand All @@ -132,20 +132,20 @@ the dependencies installed are still working even if your dependencies released
!!!note

For libraries it is not necessary to commit the lock file.


## Updating dependencies to their latest versions

As mentioned above, the `pyproject.lock` file prevents you from automatically getting the latest versions
As mentioned above, the `poetry.lock` file prevents you from automatically getting the latest versions
of your dependencies.
To update to the latest versions, use the `update` command.
This will fetch the latest matching versions (according to your `pyproject.toml` file)
and update the lock file with the new versions.
(This is equivalent to deleting the `pyproject.lock` file and running `install` again.)
(This is equivalent to deleting the `poetry.lock` file and running `install` again.)

!!!note

Poetry will display a **Warning** when executing an install command if `pyproject.lock` and `pyproject.toml`
Poetry will display a **Warning** when executing an install command if `poetry.lock` and `pyproject.toml`
are not synchronized.


Expand All @@ -159,7 +159,7 @@ or create a brand new one for you to always work isolated from your global Pytho

The created virtualenv will use the Python executable for which
`poetry` has been installed.

What this means is if you project is Python 2.7 only you should
install `poetry` for your global Python 2.7 executable and use
it to manage your project.
8 changes: 4 additions & 4 deletions docs/docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ resolves the dependencies, and installs them.
poetry install
```

If there is a `pyproject.lock` file in the current directory,
If there is a `poetry.lock` file in the current directory,
it will use the exact versions from there instead of resolving them.
This ensures that everyone using the library will get the same versions of the dependencies.

If there is no `pyproject.lock` file, Poetry will create one after dependency resolution.
If there is no `poetry.lock` file, Poetry will create one after dependency resolution.

You can specify to the command that you do not want the development dependencies installed by passing
the `--no-dev` option.
Expand All @@ -131,14 +131,14 @@ poetry install -E mysql -E pgsql

## update

In order to get the latest versions of the dependencies and to update the `pyproject.lock` file,
In order to get the latest versions of the dependencies and to update the `poetry.lock` file,
you should use the `update` command.

```bash
poetry update
```

This will resolve all dependencies of the project and write the exact versions into `pyproject.lock`.
This will resolve all dependencies of the project and write the exact versions into `poetry.lock`.

If you just want to update a few packages and not all, you can list them as such:

Expand Down
6 changes: 3 additions & 3 deletions docs/docs/libraries.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This has many advantages for the end users and allows them to set appropriate

## Lock file

For your library, you may commit the `pyproject.lock` file if you want to.
For your library, you may commit the `poetry.lock` file if you want to.
This can help your team to always test against the same dependency versions.
However, this lock file will not have any effect on other projects that depend on it.
It only has an effect on the main project.
Expand Down Expand Up @@ -59,10 +59,10 @@ and you have [configured your credentials](/repositories/#adding-credentials) pr
!!!note

The `publish` command does not execute `build` by default.

If you want to build and publish your packages together,
just pass the `--build` option.

Once this is done, your library will be available to anyone.


Expand Down
4 changes: 2 additions & 2 deletions pyproject.lock → poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion poetry/console/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class InstallCommand(EnvCommand):
{ --develop=* : Install given packages in development mode. }
"""

help = """The <info>install</info> command reads the <comment>pyproject.lock</> file from
help = """The <info>install</info> command reads the <comment>poetry.lock</> file from
the current directory, processes it, and downloads and installs all the
libraries and dependencies outlined in that file. If the file does not
exist it will look for <comment>pyproject.toml</> and do the same.
Expand Down
2 changes: 1 addition & 1 deletion poetry/console/commands/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class LockCommand(EnvCommand):
"""

help = """The <info>lock</info> command reads the <comment>pyproject.toml</> file from
the current directory, processes it, and locks the depdencies in the <comment>pyproject.lock</> file.
the current directory, processes it, and locks the depdencies in the <comment>poetry.lock</> file.
<info>poetry lock</info>
"""
Expand Down
11 changes: 10 additions & 1 deletion poetry/poetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from __future__ import unicode_literals

import json
import shutil

from .__version__ import __version__
from .config import Config
Expand Down Expand Up @@ -165,7 +166,15 @@ def create(cls, cwd): # type: (Path) -> Poetry
if "packages" in local_config:
package.packages = local_config["packages"]

locker = Locker(poetry_file.with_suffix(".lock"), local_config)
# Moving lock if necessary (pyproject.lock -> poetry.lock)
lock = poetry_file.parent / "poetry.lock"
if not lock.exists():
# Checking for pyproject.lock
old_lock = poetry_file.with_suffix(".lock")
if old_lock.exists():
shutil.move(old_lock, lock)

locker = Locker(poetry_file.parent / "poetry.lock", local_config)

return cls(poetry_file, local_config, package, locker)

Expand Down
2 changes: 1 addition & 1 deletion poetry/puzzle/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def name_for_explicit_dependency_source(self): # type: () -> str

@property
def name_for_locking_dependency_source(self): # type: () -> str
return "pyproject.lock"
return "poetry.lock"

def is_debugging(self):
return self._is_debugging
Expand Down