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

add casefold to sorting #11

Merged
merged 5 commits into from
Feb 2, 2023
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
95 changes: 59 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,63 @@
# pydeps2env

An easy way to create conda environment files from you python project dependencies.
Creates a conda `environment.yml` file from python package dependencies listed in a `setup.cfg` or `pyproject.toml` file.
Creates a conda `environment.yml` file from python package dependencies listed in a `pyproject.toml` or `setup.cfg` file.

## basic usage

By default, the action will parse a `setup.cfg` file in your root directory into `environment.yml`. Here is an example
By default, the action will parse a `pyproject.toml` file in your root directory into `environment.yml`. Here is an example
of a simple setup:

```yaml
steps:
- uses: CagtayFabry/pydeps2env@v0.2.0
- uses: CagtayFabry/pydeps2env@v0.2.2
```

```cfg
[options]
python_requires = >=3.8,<3.10
setup_requires =
setuptools >=38.3.0
setuptools_scm
install_requires =
numpy >=1.20
pandas >=1.0

[options.extras_require]
test =
pytest
```toml
[project]
requires-python = ">=3.8,<3.10"
dependencies = [
"numpy >=1.20",
"pandas >=1.0",
"IPython",
"boltons",
]
[project.optional-dependencies]
test = ["pytest"]
pip_only = ["bidict"]
]
```

The default parameters will output this `environment.yml`:
The default parameters will output this sorted `environment.yml`:

```yaml
channels:
- defaults
dependencies:
- python>=3.8
- boltons
- IPython
- numpy>=1.20
- pandas>=1.0
- python>=3.8,<3.10
```

A full output with options `--setup_requires include --extras test pip_only --pip bidict`

```yaml
channels:
- defaults
dependencies:
- boltons
- IPython
- numpy>=1.20
- pandas>=1.0
- pytest
- python>=3.8,<3.10
- setuptools>=40.9.0
- setuptools_scm
- wheel
- pip:
- bidict
```

## configuration options
Expand Down Expand Up @@ -84,33 +105,35 @@ steps:
pip: 'bidict'
```

```cfg
[options]
python_requires = >=3.8,<3.10
setup_requires =
setuptools >=38.3.0
setuptools_scm
install_requires =
numpy >=1.20
pandas >=1.0
bidict

[options.extras_require]
test =
pytest
```toml
[project]
requires-python = ">=3.8,<3.10"
dependencies = [
"numpy >=1.20",
"pandas >=1.0",
"IPython",
"boltons",
]
[project.optional-dependencies]
test = ["pytest"]
pip_only = ["bidict"]
]
```

```yaml
channels:
- conda-forge
- defaults
dependencies:
- python>=3.8,<3.10
- setuptools>=38.3.0
- setuptools_scm
- boltons
- IPython
- numpy>=1.20
- pandas>=1.0
- pytest
- python>=3.8,<3.10
- setuptools>=40.9.0
- setuptools_scm
- wheel
- pip:
- bidict
- bidict
```
4 changes: 2 additions & 2 deletions create_conda_env_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ class MetadataType:
env["dependencies"] = list(set(env["dependencies"]) - set(pip))

# sort output
env["dependencies"] = sorted(env["dependencies"])
pip = sorted(pip)
env["dependencies"] = sorted(env["dependencies"], key=str.casefold)
pip = sorted(pip, key=str.casefold)

output = "channels:"
output += "\n - ".join([""] + env["channels"])
Expand Down
10 changes: 5 additions & 5 deletions test/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ author = "Cagtay Fabry <cagtay.fabry@bam.de>"
author_email = "cagtay.fabry@bam.de"

requires-python = ">=3.8,<3.10"

dependencies = [
"numpy >=1.20",
"pandas >=1.0",
"IPython",
"boltons",
]

[project.urls]
home_page = "https://github.com/CagtayFabry/pydeps2env"

[project.optional-dependencies]
test = ["pytest"]
pip_only = ["bidict"]

[project.urls]
home_page = "https://github.com/CagtayFabry/pydeps2env"

# Build system config, pip creates a temporary env with "requires" pkgs.
[build-system]
requires = [
Expand Down