mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-26 17:24:41 +03:00
Make wheel the default format and update docs [ci skip]
This commit is contained in:
parent
b9573e9e22
commit
a59f3fcf5d
|
@ -188,8 +188,9 @@ command, or manually by pointing pip to a path or URL.
|
|||
# Download best-matching version of specific model for your spaCy installation
|
||||
python -m spacy download en_core_web_sm
|
||||
|
||||
# pip install .tar.gz archive from path or URL
|
||||
# pip install .tar.gz archive or .whl from path or URL
|
||||
pip install /Users/you/en_core_web_sm-3.0.0.tar.gz
|
||||
pip install /Users/you/en_core_web_sm-3.0.0-py3-none-any.whl
|
||||
pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.0.0/en_core_web_sm-3.0.0.tar.gz
|
||||
```
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ def download_cli(
|
|||
ctx: typer.Context,
|
||||
model: str = Arg(..., help="Name of pipeline package to download"),
|
||||
direct: bool = Opt(False, "--direct", "-d", "-D", help="Force direct download of name + version"),
|
||||
wheel: bool = Opt(False, "--wheel", "-W", help="Download binary wheel")
|
||||
sdist: bool = Opt(False, "--sdist", "-S", help="Download sdist (.tar.gz) archive instead of pre-built binary wheel")
|
||||
# fmt: on
|
||||
):
|
||||
"""
|
||||
|
@ -32,10 +32,10 @@ def download_cli(
|
|||
DOCS: https://spacy.io/api/cli#download
|
||||
AVAILABLE PACKAGES: https://spacy.io/models
|
||||
"""
|
||||
download(model, direct, wheel, *ctx.args)
|
||||
download(model, direct, sdist, *ctx.args)
|
||||
|
||||
|
||||
def download(model: str, direct: bool = False, wheel: bool = False, *pip_args) -> None:
|
||||
def download(model: str, direct: bool = False, sdist: bool = False, *pip_args) -> None:
|
||||
if (
|
||||
not (is_package("spacy") or is_package("spacy-nightly"))
|
||||
and "--no-deps" not in pip_args
|
||||
|
@ -49,7 +49,7 @@ def download(model: str, direct: bool = False, wheel: bool = False, *pip_args) -
|
|||
"dependencies, you'll have to install them manually."
|
||||
)
|
||||
pip_args = pip_args + ("--no-deps",)
|
||||
suffix = WHEEL_SUFFIX if wheel else SDIST_SUFFIX
|
||||
suffix = SDIST_SUFFIX if sdist else WHEEL_SUFFIX
|
||||
dl_tpl = "{m}-{v}/{m}-{v}{s}#egg={m}=={v}"
|
||||
if direct:
|
||||
components = model.split("-")
|
||||
|
|
|
@ -29,8 +29,6 @@ Download [trained pipelines](/usage/models) for spaCy. The downloader finds the
|
|||
best-matching compatible version and uses `pip install` to download the Python
|
||||
package. Direct downloads don't perform any compatibility checks and require the
|
||||
pipeline name to be specified with its version (e.g. `en_core_web_sm-3.0.0`).
|
||||
Setting the `--wheel` flag will download a binary wheel file instead of an
|
||||
archive, which can be faster and more memory efficient.
|
||||
|
||||
> #### Downloading best practices
|
||||
>
|
||||
|
@ -44,14 +42,14 @@ archive, which can be faster and more memory efficient.
|
|||
> project.
|
||||
|
||||
```cli
|
||||
$ python -m spacy download [model] [--wheel] [--direct] [pip_args]
|
||||
$ python -m spacy download [model] [--direct] [--sdist] [pip_args]
|
||||
```
|
||||
|
||||
| Name | Description |
|
||||
| ------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `model` | Pipeline package name, e.g. [`en_core_web_sm`](/models/en#en_core_web_sm). ~~str (positional)~~ |
|
||||
| `--wheel`, `-W` <Tag variant="new">3</Tag> | Download binary wheel package instead of `.tar.gz` archive. Can make download and installation faster and more memory efficient. ~~bool (flag)~~ |
|
||||
| `--direct`, `-D` | Force direct download of exact package version. ~~bool (flag)~~ |
|
||||
| `--sdist`, `-S` <Tag variant="new">3</Tag> | Download the source package (`.tar.gz` archive) instead of the default pre-built binary wheel. ~~bool (flag)~~ |
|
||||
| `--help`, `-h` | Show help message and available arguments. ~~bool (flag)~~ |
|
||||
| pip args <Tag variant="new">2.1</Tag> | Additional installation options to be passed to `pip install` when installing the pipeline package. For example, `--user` to install to the user home directory or `--no-deps` to not install package dependencies. ~~Any (option/flag)~~ |
|
||||
| **CREATES** | The installed pipeline package in your `site-packages` directory. |
|
||||
|
|
|
@ -283,9 +283,6 @@ $ python -m spacy download en_core_web_sm
|
|||
|
||||
# Download exact package version
|
||||
$ python -m spacy download en_core_web_sm-3.0.0 --direct
|
||||
|
||||
# Download binary wheel (can be more efficient)
|
||||
$ python -m spacy download en_core_web_sm --wheel
|
||||
```
|
||||
|
||||
The download command will [install the package](/usage/models#download-pip) via
|
||||
|
@ -306,15 +303,18 @@ doc = nlp("This is a sentence.")
|
|||
|
||||
To download a trained pipeline directly using
|
||||
[pip](https://pypi.python.org/pypi/pip), point `pip install` to the URL or local
|
||||
path of the archive file. To find the direct link to a package, head over to the
|
||||
path of the wheel file or archive. Installing the wheel is usually more
|
||||
efficient. To find the direct link to a package, head over to the
|
||||
[releases](https://github.com/explosion/spacy-models/releases), right click on
|
||||
the archive link and copy it to your clipboard.
|
||||
|
||||
```bash
|
||||
# With external URL
|
||||
$ pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.0.0/en_core_web_sm-3.0.0-py3-none-any.whl
|
||||
$ pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.0.0/en_core_web_sm-3.0.0.tar.gz
|
||||
|
||||
# With local file
|
||||
$ pip install /Users/you/en_core_web_sm-3.0.0-py3-none-any.whl
|
||||
$ pip install /Users/you/en_core_web_sm-3.0.0.tar.gz
|
||||
```
|
||||
|
||||
|
|
|
@ -658,8 +658,9 @@ $ python -m spacy package ./en_example_pipeline ./packages
|
|||
```
|
||||
|
||||
This command will create a pipeline package directory and will run
|
||||
`python setup.py sdist` in that directory to create `.tar.gz` archive of your
|
||||
package that can be installed using `pip install`.
|
||||
`python setup.py sdist` in that directory to create a binary `.whl` file or
|
||||
`.tar.gz` archive of your package that can be installed using `pip install`.
|
||||
Installing the binary wheel is usually more efficient.
|
||||
|
||||
```yaml
|
||||
### Directory structure
|
||||
|
|
|
@ -51,25 +51,16 @@ const data = [
|
|||
id: 'config',
|
||||
title: 'Options',
|
||||
multiple: true,
|
||||
options: [
|
||||
{
|
||||
id: 'wheel',
|
||||
title: 'Download binary wheel',
|
||||
help: 'Can make download and installation more efficient',
|
||||
},
|
||||
{ id: 'example', title: 'Show text example' },
|
||||
],
|
||||
options: [{ id: 'example', title: 'Show text example' }],
|
||||
},
|
||||
]
|
||||
|
||||
const QuickstartInstall = ({ id, title, description, children }) => {
|
||||
const [lang, setLang] = useState(DEFAULT_LANG)
|
||||
const [wheel, setWheel] = useState(false)
|
||||
const [efficiency, setEfficiency] = useState(DEFAULT_OPT === 'efficiency')
|
||||
const setters = {
|
||||
lang: setLang,
|
||||
optimize: v => setEfficiency(v.includes('efficiency')),
|
||||
config: v => setWheel(v.includes('wheel')),
|
||||
}
|
||||
return (
|
||||
<StaticQuery
|
||||
|
@ -96,10 +87,7 @@ const QuickstartInstall = ({ id, title, description, children }) => {
|
|||
const exampleText = example || 'No text available yet'
|
||||
return lang !== code ? null : (
|
||||
<Fragment key={code}>
|
||||
<QS>
|
||||
python -m spacy download {pkg}
|
||||
{wheel ? ' --wheel' : ''}
|
||||
</QS>
|
||||
<QS>python -m spacy download {pkg}</QS>
|
||||
<QS divider />
|
||||
<QS load="spacy" prompt="python">
|
||||
import spacy
|
||||
|
|
Loading…
Reference in New Issue
Block a user