Skip to content

Commit

Permalink
v0.4.1 with --version and small improveements
Browse files Browse the repository at this point in the history
  • Loading branch information
paugier committed Nov 4, 2024
1 parent e0859bd commit ee4f8c8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/unix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
- name: test install mercurial
run: |
conda-app install mercurial
conda-app install pdm python=3.11
conda-app install pipx python=3.12
conda env list
conda-app list
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- name: test install mercurial
run: |
conda-app install mercurial
conda-app install pdm python=3.11
conda-app install pipx python=3.12
conda env list
conda-app list
Expand Down
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ test-run:
- conda --version
- pip install .
- conda-app install mercurial
- conda-app install pdm python=3.11
- conda-app install pipx python=3.11
- conda env list
- . ~/.bashrc
- hg debuginstall
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "pdm.backend"

[project]
name = "conda-app"
version = "0.4.0"
version = "0.4.1"
description = "Install applications with conda"
authors = [
{name = "Pierre Augier"},
Expand Down
20 changes: 10 additions & 10 deletions src/conda_app.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import sys
import json
import argparse
import platform
import subprocess

Expand All @@ -10,7 +9,7 @@

import click

open = partial(open, encoding="utf-8")
_open = partial(open, encoding="utf-8")


def check_command(conda_command):
Expand Down Expand Up @@ -46,7 +45,7 @@ def run_conda(*args, conda_command="conda", capture_output=True):

commands_app = {"mercurial": ["hg"], "tortoisehg": ["hg", "thg"]}
known_apps_with_app_package = ["mercurial"]
known_apps_without_app_package = ["spyder", "pdm", "nox"]
known_apps_without_app_package = ["spyder", "pipx", "pdm", "nox"]

special_hgrc_windows = ""
if os.name == "nt":
Expand Down Expand Up @@ -155,7 +154,7 @@ def modif_config_file(path_config, line_config, force=False):
if not line_config.endswith("\n"):
line_config = line_config + "\n"
if path_config.exists():
with open(path_config) as file:
with _open(path_config) as file:
lines = file.readlines()
if lines and lines[-1] and not lines[-1].endswith("\n"):
lines[-1] = lines[-1] + "\n"
Expand All @@ -165,10 +164,10 @@ def modif_config_file(path_config, line_config, force=False):
f"at the end of file {path_config}"
)

with open(path_config.with_name(path_config.name + ".orig"), "w") as file:
with _open(path_config.with_name(path_config.name + ".orig"), "w") as file:
file.write("".join(lines))

with open(path_config, "a") as file:
with _open(path_config, "a") as file:
file.write("\n# line added by conda-app\n" + line_config)


Expand All @@ -193,7 +192,7 @@ def get_env_names(conda_data):

def load_data():
if path_data.exists():
with open(path_data) as file:
with _open(path_data) as file:
data = json.load(file)
else:
data = {"installed_apps": []}
Expand All @@ -205,14 +204,15 @@ def add_to_app_list(app_name):
data = load_data()
if app_name not in data["installed_apps"]:
data["installed_apps"].append(app_name)
with open(path_data, "w") as file:
with _open(path_data, "w") as file:
json.dump(data, file)


CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])


@click.group(context_settings=CONTEXT_SETTINGS)
@click.version_option()
def main():
pass

Expand Down Expand Up @@ -331,7 +331,7 @@ def install(app_name, other_packages=None):
"Filling ~/.hgrc with reasonable default "
"(edit to fill correct username and email address!)"
)
with open(path_home_hgrc, "w") as file:
with _open(path_home_hgrc, "w") as file:
file.write(default_hgrc)

try:
Expand All @@ -341,7 +341,7 @@ def install(app_name, other_packages=None):

for command in commands:
if os.name == "nt":
with open(path_bin / (command + ".bat"), "w") as file:
with _open(path_bin / (command + ".bat"), "w") as file:
file.write(
"@echo off\n"
f"call conda activate {env_name}\n"
Expand Down

0 comments on commit ee4f8c8

Please sign in to comment.