anaconda / anaconda-project

Tool for encapsulating, running, and reproducing data science projects
https://anaconda-project.readthedocs.io/en/latest/
Other
217 stars 88 forks source link

Enable pip package locking #317

Closed AlbertDeFusco closed 3 years ago

AlbertDeFusco commented 3 years ago

This PR adds several pip improvements (see #181)

TODO:

pip install output

# anaconda-project.yml file
name: pip-pkgs

packages:
- python=3.7
- pip:
  - chardet
channels: []

env_specs:
  default: {}
  test:
    packages:
    - pip:
      - requests
    channels: []
platforms:
- linux-64
- osx-64
- win-64
> anaconda-project prepare
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

## Package Plan ##

  environment location: /Users/adefusco/Development/AnacondaPlatform/anaconda-project/examples/pip/envs/default

  added / updated specs:
    - python=3.7

The following NEW packages will be INSTALLED:

  ca-certificates    pkgs/main/osx-64::ca-certificates-2021.4.13-hecd8cb5_1
  certifi            pkgs/main/osx-64::certifi-2020.12.5-py37hecd8cb5_0
  libcxx             pkgs/main/osx-64::libcxx-10.0.0-1
  libffi             pkgs/main/osx-64::libffi-3.3-hb1e8313_2
  ncurses            pkgs/main/osx-64::ncurses-6.2-h0a44026_1
  openssl            pkgs/main/osx-64::openssl-1.1.1k-h9ed2024_0
  pip                pkgs/main/osx-64::pip-21.0.1-py37hecd8cb5_0
  python             pkgs/main/osx-64::python-3.7.10-h88f2d9e_0
  readline           pkgs/main/osx-64::readline-8.1-h9ed2024_0
  setuptools         pkgs/main/osx-64::setuptools-52.0.0-py37hecd8cb5_0
  sqlite             pkgs/main/osx-64::sqlite-3.35.4-hce871da_0
  tk                 pkgs/main/osx-64::tk-8.6.10-hb0a8c7a_0
  wheel              pkgs/main/noarch::wheel-0.36.2-pyhd3eb1b0_0
  xz                 pkgs/main/osx-64::xz-5.2.5-h1de35cc_0
  zlib               pkgs/main/osx-64::zlib-1.2.11-h1de35cc_3

Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
#
# To activate this environment, use
#
#     $ conda activate /Users/adefusco/Development/AnacondaPlatform/anaconda-project/examples/pip/envs/default
#
# To deactivate an active environment, use
#
#     $ conda deactivate

Collecting chardet
  Using cached chardet-4.0.0-py2.py3-none-any.whl (178 kB)
Installing collected packages: chardet
Successfully installed chardet-4.0.0
The project is ready to run commands.
Use `anaconda-project list-commands` to see what's available.

list pip packages

>anaconda-project list-packages
Conda packages for environment 'default':

python=3.7

Pip packages for environment 'default':

chardet

locking with pip packages

> anaconda-project lock
Updating locked dependencies for env spec default...
Resolving conda packages for osx-64
Resolving conda packages for linux-64
Resolving conda packages for win-64
...

> tail -n 10 anaconda-project-lock.yml 
      - openssl=1.1.1k=h2bbff1b_0
      - pip=21.0.1=py37haa95532_0
      - python=3.7.10=h6244533_0
      - setuptools=52.0.0=py37haa95532_0
      - sqlite=3.35.4=h2bbff1b_0
      - vc=14.2=h21ff451_1
      - vs2015_runtime=14.27.29016=h5e58377_2
      - wincertstore=0.2=py37_0
      pip:
      - chardet==4.0.0

add pip packages

packages added to default env-spec

> anaconda-project add-packages --pip requests
Collecting requests
  Using cached requests-2.25.1-py2.py3-none-any.whl (61 kB)
Collecting urllib3<1.27,>=1.21.1
  Using cached urllib3-1.26.4-py2.py3-none-any.whl (153 kB)
Requirement already satisfied: certifi>=2017.4.17 in ./envs/default/lib/python3.7/site-packages (from requests) (2020.12.5)
Collecting idna<3,>=2.5
  Using cached idna-2.10-py2.py3-none-any.whl (58 kB)
Requirement already satisfied: chardet<5,>=3.0.2 in ./envs/default/lib/python3.7/site-packages (from requests) (4.0.0)
Installing collected packages: urllib3, idna, requests
Successfully installed idna-2.10 requests-2.25.1 urllib3-1.26.4
Using Conda environment /Users/adefusco/Development/AnacondaPlatform/anaconda-project/examples/pip/envs/default.
Added packages to project file: requests.

add pip packages to env-spec

> anaconda-project prepare --env-spec test
...
Executing transaction: ...working... done
#
# To activate this environment, use
#
#     $ conda activate /Users/adefusco/Development/AnacondaPlatform/anaconda-project/examples/pip/envs/test
#
# To deactivate an active environment, use
#
#     $ conda deactivate

Collecting chardet
  Using cached chardet-4.0.0-py2.py3-none-any.whl (178 kB)
Collecting requests
  Using cached requests-2.25.1-py2.py3-none-any.whl (61 kB)
Requirement already satisfied: certifi>=2017.4.17 in ./envs/test/lib/python3.7/site-packages (from requests) (2020.12.5)
Collecting idna<3,>=2.5
  Using cached idna-2.10-py2.py3-none-any.whl (58 kB)
Collecting urllib3<1.27,>=1.21.1
  Using cached urllib3-1.26.4-py2.py3-none-any.whl (153 kB)
Installing collected packages: urllib3, idna, chardet, requests
Successfully installed chardet-4.0.0 idna-2.10 requests-2.25.1 urllib3-1.26.4
The project is ready to run commands.
Use `anaconda-project list-commands` to see what's available.
> anaconda-project add-packages --pip --env-spec test pytest
Collecting pytest
  Using cached pytest-6.2.3-py3-none-any.whl (280 kB)
Collecting py>=1.8.2
  Using cached py-1.10.0-py2.py3-none-any.whl (97 kB)
Collecting toml
  Using cached toml-0.10.2-py2.py3-none-any.whl (16 kB)
Collecting packaging
  Using cached packaging-20.9-py2.py3-none-any.whl (40 kB)
Collecting attrs>=19.2.0
  Using cached attrs-20.3.0-py2.py3-none-any.whl (49 kB)
Collecting importlib-metadata>=0.12
  Using cached importlib_metadata-4.0.1-py3-none-any.whl (16 kB)
Collecting iniconfig
  Using cached iniconfig-1.1.1-py2.py3-none-any.whl (5.0 kB)
Collecting pluggy<1.0.0a1,>=0.12
  Using cached pluggy-0.13.1-py2.py3-none-any.whl (18 kB)
Collecting typing-extensions>=3.6.4
  Using cached typing_extensions-3.7.4.3-py3-none-any.whl (22 kB)
Collecting zipp>=0.5
  Using cached zipp-3.4.1-py3-none-any.whl (5.2 kB)
Collecting pyparsing>=2.0.2
  Using cached pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
Installing collected packages: zipp, typing-extensions, pyparsing, importlib-metadata, toml, py, pluggy, packaging, iniconfig, attrs, pytest
Successfully installed attrs-20.3.0 importlib-metadata-4.0.1 iniconfig-1.1.1 packaging-20.9 pluggy-0.13.1 py-1.10.0 pyparsing-2.4.7 pytest-6.2.3 toml-0.10.2 typing-extensions-3.7.4.3 zipp-3.4.1
Using Conda environment /Users/adefusco/Development/AnacondaPlatform/anaconda-project/examples/pip/envs/test.
Added packages to environment test in project file: pytest.
AlbertDeFusco commented 3 years ago

Docs have been added to address the following issues

jbednar commented 3 years ago

Also, thanks for adding to the docs here in general; those were some serious holes in the docs before!