Skip to content

Commit

Permalink
Merge branch 'main' into feature/229-relative-sources-rebased
Browse files Browse the repository at this point in the history
  • Loading branch information
maresb authored Feb 6, 2023
2 parents f558cba + cfebac2 commit cf80ff4
Show file tree
Hide file tree
Showing 22 changed files with 154 additions and 64 deletions.
24 changes: 0 additions & 24 deletions .github/workflows/pre-commit.yml

This file was deleted.

13 changes: 12 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ name: test
on:
pull_request:
push:
branches:
- main

concurrency:
# Concurrency group that uses the workflow name and PR number if available
# or commit SHA as a fallback. If a new build is triggered under that
# concurrency group while a previous build is running it will be canceled.
# Repeated pushes to a PR will cancel all previous builds, while multiple
# merges to main will not cancel.
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true

jobs:
test-windows:
Expand Down Expand Up @@ -46,7 +57,7 @@ jobs:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest ]
python-version: [ '3.7', '3.8', "3.10" ]
python-version: [ "3.8", "3.11" ]
defaults:
run:
shell: bash -l {0}
Expand Down
14 changes: 9 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
# disable autofixing PRs, commenting "pre-commit.ci autofix" on a pull request triggers a autofix
ci:
autofix_prs: false

exclude: ^conda_lock/_vendor/.*$

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: trailing-whitespace
exclude: "^.*\\.patch$"
- id: check-ast

- repo: https://github.com/psf/black
rev: 22.10.0
rev: 23.1.0
hooks:
- id: black
language_version: python3

- repo: https://github.com/pycqa/flake8
rev: 5.0.4
rev: 6.0.0
hooks:
- id: flake8

- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]
Expand All @@ -30,4 +34,4 @@ repos:
hooks:
- id: mypy
additional_dependencies: [types-filelock, types-requests, types-toml, types-PyYAML, types-freezegun, types-setuptools, pydantic]
exclude: ^tests/test-local-pip/setup.py$
exclude: ^(tests/test-local-pip/setup.py$|tests/test_conda_lock.py)
20 changes: 20 additions & 0 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Conda Organization Code of Conduct

> **Note**
> Below is the short version of our CoC, see the long version [here](https://github.com/conda-incubator/governance/blob/main/CODE_OF_CONDUCT.md).
# The Short Version

Be kind to others. Do not insult or put down others. Behave professionally. Remember that harassment and sexist, racist, or exclusionary jokes are not appropriate for the conda Organization.

All communication should be appropriate for a professional audience including people of many different backgrounds. Sexual language and imagery is not appropriate.

The conda Organization is dedicated to providing a harassment-free community for everyone, regardless of gender, sexual orientation, gender identity and expression, disability, physical appearance, body size, race, or religion. We do not tolerate harassment of community members in any form.

Thank you for helping make this a welcoming, friendly community for all.

## Report an Incident

* Report a code of conduct incident [using a form](https://form.jotform.com/221527028480048).
* Report a code of conduct incident via email: [conduct@conda.org](mailto:conduct@conda.org).
* Contact [an individual committee member](#committee-membership) or [CoC event representative](#coc-representatives) to report an incident in confidence.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# conda-lock

[![GitHub deployments](https://img.shields.io/github/deployments/conda-incubator/conda-lock/github-pages?label=docs&style=for-the-badge)](https://conda-incubator.github.io/conda-lock/)
[![GitHub deployments](https://img.shields.io/github/deployments/conda/conda-lock/github-pages?label=docs&style=for-the-badge)](https://conda.github.io/conda-lock/)
[![PyPI](https://img.shields.io/pypi/v/conda-lock?style=for-the-badge)](https://pypi.org/project/conda-lock/)
[![Conda](https://img.shields.io/conda/v/conda-forge/conda-lock?style=for-the-badge)](https://github.com/conda-forge/conda-lock-feedstock)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?style=for-the-badge)](https://results.pre-commit.ci/latest/github/conda/conda-lock/main)

Conda lock is a lightweight library that can be used to generate fully reproducible lock files for [conda][conda]
environments.
Expand Down Expand Up @@ -161,6 +162,8 @@ Right now `conda-lock` only supports [legacy](https://warehouse.pypa.io/api-refe
poetry config repositories.foo https://username:password@foo.repo/simple/
```

The private repo will be used in addition to `pypi.org`. For projects using `pyproject.toml`, it is possible to [disable `pypi.org` entirely](#disabling-pypiorg).

### --dev-dependencies/--no-dev-dependencies

By default conda-lock will include dev dependencies in the specification of the lock (if the files that the lock
Expand Down Expand Up @@ -390,6 +393,14 @@ In both these cases, the dependencies of `pip`-installable packages will also be
installed with `pip`, unless they were already requested by a `conda`
dependency.
#### Disabling pypi.org
When using private pip repos, it is possible to disable `pypi.org` entirely. This can be useful when using `conda-lock` behind a network proxy that does not allow access to `pypi.org`.
```toml
[tool.conda-lock]
allow-pypi-requests = false
```
## Dockerfile example
In order to use conda-lock in a docker-style context you want to add the lockfile to the
Expand Down
2 changes: 1 addition & 1 deletion conda_lock/click_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def __init__(
self,
name: Optional[str] = None,
commands: Optional[Mapping[str, click.Command]] = None,
**kwargs: Any
**kwargs: Any,
):
super(OrderedGroup, self).__init__(name, commands, **kwargs)
#: the registered subcommands by their exported names.
Expand Down
3 changes: 1 addition & 2 deletions conda_lock/conda_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ def do_conda_install(
file: pathlib.Path,
copy: bool,
) -> None:

_conda = partial(_invoke_conda, conda, prefix, name, check_call=True)

kind = "env" if file.name.endswith(".yml") else "explicit"
Expand Down Expand Up @@ -743,6 +742,7 @@ def _solve_for_arch(
conda_locked={dep.name: dep for dep in conda_deps.values()},
python_version=conda_deps["python"].version,
platform=platform,
allow_pypi_requests=spec.allow_pypi_requests,
)
else:
pip_deps = {}
Expand Down Expand Up @@ -797,7 +797,6 @@ def create_lockfile_from_spec(
locked: Dict[Tuple[str, str, str], LockedDependency] = {}

for platform in platforms or spec.platforms:

deps = _solve_for_arch(
conda=conda,
spec=spec,
Expand Down
2 changes: 1 addition & 1 deletion conda_lock/lockfile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def write_section(text: str) -> None:

write_section(
f"""
This lock file was generated by conda-lock (https://github.com/conda-incubator/conda-lock). DO NOT EDIT!
This lock file was generated by conda-lock (https://github.com/conda/conda-lock). DO NOT EDIT!
A "lock file" contains a concrete list of package versions (with checksums) to be installed. Unlike
e.g. `conda env create`, the resulting environment will not change as new package versions become
Expand Down
1 change: 0 additions & 1 deletion conda_lock/lockfile/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ def ensure_channels(cls, v: List[Union[str, Channel]]) -> List[Channel]:


class Lockfile(StrictModel):

version: ClassVar[int] = 1

package: List[LockedDependency]
Expand Down
37 changes: 26 additions & 11 deletions conda_lock/pypi_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ def solve_pypi(
conda_locked: Dict[str, lockfile.LockedDependency],
python_version: str,
platform: str,
allow_pypi_requests: bool = True,
verbose: bool = False,
) -> Dict[str, lockfile.LockedDependency]:
"""
Expand All @@ -199,6 +200,8 @@ def solve_pypi(
Version of Python in conda_locked
platform :
Target platform
allow_pypi_requests :
Add pypi.org to the list of repositories (pip packages only)
verbose :
Print chatter from solver
Expand All @@ -210,17 +213,7 @@ def solve_pypi(
for dep in dependencies:
dummy_package.add_dependency(dep)

factory = Factory()
config = factory.create_config()
repos = [
factory.create_legacy_repository(
{"name": source[0], "url": source[1]["url"]}, config
)
for source in config.get("repositories", {}).items()
]

pypi = PyPiRepository()
pool = Pool(repositories=[*repos, pypi])
pool = _prepare_repositories_pool(allow_pypi_requests)

installed = Repository()
locked = Repository()
Expand Down Expand Up @@ -327,3 +320,25 @@ def solve_pypi(
lockfile._apply_categories(requested=pip_specs, planned=planned)

return {dep.name: dep for dep in requirements}


def _prepare_repositories_pool(allow_pypi_requests: bool) -> Pool:
"""
Prepare the pool of repositories to solve pip dependencies
Parameters
----------
allow_pypi_requests :
Add pypi.org to the list of repositories
"""
factory = Factory()
config = factory.create_config()
repos = [
factory.create_legacy_repository(
{"name": source[0], "url": source[1]["url"]}, config
)
for source in config.get("repositories", {}).items()
]
if allow_pypi_requests:
repos.append(PyPiRepository())
return Pool(repositories=[*repos])
2 changes: 2 additions & 0 deletions conda_lock/scripts/vendor_poetry/migration.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import re
import subprocess

Expand Down
1 change: 0 additions & 1 deletion conda_lock/scripts/vendor_poetry/vendor_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ def _root_license(self) -> License:
)

def search_vendored_dependencies(self) -> dict[str, DependencyData]:

candidate_licenses = [
m
for m in self._tarfile_obj.getmembers()
Expand Down
2 changes: 1 addition & 1 deletion conda_lock/src_parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class LockSpecification(BaseModel):
platforms: List[str]
sources: List[pathlib.Path]
virtual_package_repo: Optional[FakeRepoData] = None
allow_pypi_requests: bool = True

def content_hash(self) -> Dict[str, str]:
return {
Expand Down Expand Up @@ -108,7 +109,6 @@ def validate_channels(cls, v: List[Union[Channel, str]]) -> List[Channel]:
def aggregate_lock_specs(
lock_specs: List[LockSpecification],
) -> LockSpecification:

# unique dependencies
unique_deps: Dict[Tuple[str, str], Dependency] = {}
for dep in chain.from_iterable(
Expand Down
3 changes: 3 additions & 0 deletions conda_lock/src_parser/pyproject_toml.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,9 @@ def specification_with_dependencies(
channels=get_in(["tool", "conda-lock", "channels"], toml_contents, []),
platforms=get_in(["tool", "conda-lock", "platforms"], toml_contents, []),
sources=[path],
allow_pypi_requests=get_in(
["tool", "conda-lock", "allow-pypi-requests"], toml_contents, True
),
)


Expand Down
2 changes: 1 addition & 1 deletion docs/output.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Conda lock's default output format is a unified multi-platform lockfile.

This is defined by a [pydantic](https://pydantic-docs.helpmanual.io/usage/models/) model
[here](https://github.com/conda-incubator/conda-lock/blob/main/conda_lock/src_parser/__init__.py#L126)
[conda_lock.lockfile.Lockfile](https://github.com/conda/conda-lock/blob/main/conda_lock/lockfile/models.py)

In order to explicitly use this format

Expand Down
2 changes: 1 addition & 1 deletion example/pangeo/conda-lock.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This lock file was generated by conda-lock (https://github.com/conda-incubator/conda-lock). DO NOT EDIT!
# This lock file was generated by conda-lock (https://github.com/conda/conda-lock). DO NOT EDIT!
#
# A "lock file" contains a concrete list of package versions (with checksums) to be installed. Unlike
# e.g. `conda env create`, the resulting environment will not change as new package versions become
Expand Down
2 changes: 1 addition & 1 deletion example/zlib/conda-lock.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This lock file was generated by conda-lock (https://github.com/conda-incubator/conda-lock). DO NOT EDIT!
# This lock file was generated by conda-lock (https://github.com/conda/conda-lock). DO NOT EDIT!
#
# A "lock file" contains a concrete list of package versions (with checksums) to be installed. Unlike
# e.g. `conda env create`, the resulting environment will not change as new package versions become
Expand Down
4 changes: 2 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
site_name: conda-lock
repo_url: https://github.com/conda-incubator/conda-lock
repo_url: https://github.com/conda/conda-lock
theme:
name: material
features:
Expand Down Expand Up @@ -62,4 +62,4 @@ extra:
- mariusvniekerk
social:
- icon: fontawesome/brands/github
link: https://github.com/conda-incubator/conda-lock
link: https://github.com/conda/conda-lock
13 changes: 6 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@ authors = [
]
readme = "README.md"
license = "MIT"
requires-python = ">=3.6"
requires-python = ">=3.8"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"Operating System :: OS Independent",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
dynamic = ["dependencies", "version"]
license-files = { paths = ["LICENSE"] }
Expand All @@ -31,10 +30,10 @@ license-files = { paths = ["LICENSE"] }
conda-lock = "conda_lock:main"

[project.urls]
Homepage = "https://github.com/conda-incubator/conda-lock"
Repository = "https://github.com/conda-incubator/conda-lock"
Documentation = "https://conda-incubator.github.io/conda-lock/"
"Issue Tracker" = "https://github.com/conda-incubator/conda-lock/issues"
Homepage = "https://github.com/conda/conda-lock"
Repository = "https://github.com/conda/conda-lock"
Documentation = "https://conda.github.io/conda-lock/"
"Issue Tracker" = "https://github.com/conda/conda-lock/issues"
"Conda-Forge Feedstock" = "https://github.com/conda-forge/conda-lock-feedstock"
"Anaconda.org" = "https://anaconda.org/conda-forge/conda-lock"

Expand Down
Empty file added tests/__init__.py
Empty file.
Loading

0 comments on commit cf80ff4

Please sign in to comment.