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

Rename to conda-pypi #18

Merged
merged 6 commits into from
Apr 30, 2024
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
37 changes: 16 additions & 21 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
pull_request:
paths:
- ".github/workflows/test.yml"
- "conda_pip/**"
- "conda_pypi/**"
- "tests/**"
- "pyproject.toml"
- "pixi.toml"
Expand All @@ -24,37 +24,32 @@ concurrency:

jobs:
tests:
name: ${{ matrix.os }}, Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}-latest
name: ${{ matrix.os }}, py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu, windows]
python-version: ["3.8", "3.9", "3.10", "3.11"]
os: [ubuntu-latest, windows-latest]
python-version: ["38", "39", "310", "311"]
include:
- os: macos
python-version: "3.10"

- os: macos-13
python-version: "310"
- os: macos-14
python-version: "311"
env:
PIXI_ENV_NAME: test-py${{ matrix.python-version }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: prefix-dev/setup-pixi@v0.4.1
with:
cache: false
run-install: false
- uses: prefix-dev/setup-pixi@v0.6.0
- name: Setup project
run: |
pixi add "python=${{ matrix.python-version }}.*=*cpython*"
pixi run dev
pixi run conda info
- name: Configure conda
run: |
echo "channels: [conda-forge]" > .pixi/envs/default/.condarc
- name: Patch history file (temporary)
run: echo "//fix" > .pixi/envs/default/conda-meta/history
pixi run --environment ${{ env.PIXI_ENV_NAME }} dev
echo "channels: [conda-forge]" > .pixi/envs/${{ env.PIXI_ENV_NAME }}/.condarc
pixi run --environment ${{ env.PIXI_ENV_NAME }} conda info
- name: Run tests
run: pixi run test --basetemp=${{ runner.os == 'Windows' && 'D:\\temp' || runner.temp }}
run: pixi run --environment ${{ env.PIXI_ENV_NAME }} test --basetemp=${{ runner.os == 'Windows' && 'D:\\temp' || runner.temp }}
- name: Build recipe
run: pixi run build
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
conda_pip/data/*
conda_pypi/data/*
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# conda-pip
# conda-pypi

`pip` wrappers to make it work with `conda` in a better way.
Better PyPI interoperability for the conda ecosystem.

Includes:

- `conda pip`: A subcommand that wraps `pip` to make it work with `conda` in a better way.
- Adds `EXTERNALLY-MANAGED` to your environments.
3 changes: 0 additions & 3 deletions conda_pip/__init__.py

This file was deleted.

3 changes: 3 additions & 0 deletions conda_pypi/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
conda-pypi
"""
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions conda_pip/main.py → conda_pypi/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,33 +120,33 @@ def run_pip_install(

def ensure_externally_managed(prefix: os.PathLike = None) -> Path:
"""
conda-pip places its own EXTERNALLY-MANAGED file when it is installed in an environment.
conda-pypi places its own EXTERNALLY-MANAGED file when it is installed in an environment.
We also need to place it in _new_ environments created by conda. We do this by implementing
some extra plugin hooks.
"""
target_path = next(get_externally_managed_path(prefix))
if target_path.exists():
return target_path
logger.info("Placing EXTERNALLY-MANAGED in %s", target_path.parent)
resource = importlib_files("conda_pip") / "data" / "EXTERNALLY-MANAGED"
resource = importlib_files("conda_pypi") / "data" / "EXTERNALLY-MANAGED"
target_path.write_text(resource.read_text())
return target_path


def ensure_target_env_has_externally_managed(command: str):
"""
post-command hook to ensure that the target env has the EXTERNALLY-MANAGED file
even when it is created by conda, not 'conda-pip'.
even when it is created by conda, not 'conda-pypi'.
"""
if os.environ.get("CONDA_BUILD_STATE") == "BUILD":
return
base_prefix = Path(context.conda_prefix)
target_prefix = Path(context.target_prefix)
if base_prefix == target_prefix:
return
# ensure conda-pip was explicitly installed in base env (and not as a dependency)
# ensure conda-pypi was explicitly installed in base env (and not as a dependency)
requested_specs_map = History(base_prefix).get_requested_specs_map()
if requested_specs_map and "conda-pip" not in requested_specs_map:
if requested_specs_map and "conda-pypi" not in requested_specs_map:
return
prefix_data = PrefixData(target_prefix)
if command in {"create", "install", "update"}:
Expand Down
5 changes: 1 addition & 4 deletions conda_pip/plugin.py → conda_pypi/plugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# Copyright (C) 2022 Anaconda, Inc
# Copyright (C) 2023 conda
# SPDX-License-Identifier: BSD-3-Clause
from conda import plugins

from .cli import configure_parser, execute
Expand All @@ -19,7 +16,7 @@ def conda_subcommands():
@plugins.hookimpl
def conda_post_commands():
yield plugins.CondaPostCommand(
name="conda-pip-ensure-target-env-has-externally-managed",
name="conda-pypi-ensure-target-env-has-externally-managed",
action=ensure_target_env_has_externally_managed,
run_for={"install", "create", "update", "remove"},
)
File renamed without changes.
Loading
Loading