Skip to content

Commit

Permalink
Merge branch 'release/v0.10.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
wpk committed Nov 17, 2023
2 parents 03110e6 + 49c5529 commit 4a0af4e
Show file tree
Hide file tree
Showing 33 changed files with 1,614 additions and 1,044 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ See the fragment files in [changelog.d]

<!-- scriv-insert-here -->

## v0.10.0 — 2023-11-17

### Added

- Can now specify conda changes using `tool.pyproject2conda.dependencies` table.
This is an alternative to using `# p2c:` comments.
- Refactored code. Split `parser` to `requirements` and `overrides`. Also
cleaned up the parsing logic to hopefully make future changes simpler.

## v0.9.0 — 2023-11-14

### Added
Expand Down
47 changes: 38 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ Note the comment lines `# p2c:...`. These are special tokens that

<!-- prettier-ignore-start -->
<!-- markdownlint-disable-next-line MD013 -->
<!-- [[[cog run_command("""python -c "from pyproject2conda.parser import _default_parser; _default_parser().parse_args(['--help'])" """, include_cmd=False, wrapper="bash")]]] -->
<!-- [[[cog run_command("""python -c "from pyproject2conda.overrides import p2c_argparser; p2c_argparser().parse_args(['--help'])" """, include_cmd=False, wrapper="bash")]]] -->
```bash
usage: -c [-h] [-c CHANNEL] [-p] [-s] [package ...]
usage: -c [-h] [-c CHANNEL] [-p] [-s] [packages ...]

Parser searches for comments '# p2c: [OPTIONS] CONDA-PACKAGES
positional arguments:
package
packages
options:
-h, --help show this help message and exit
Expand Down Expand Up @@ -195,6 +195,35 @@ dependencies:
<!-- [[[end]]] -->
### Alternate syntax: using table instead of comments
While using comments to mark options has the convenience of placing the changes
right next to the dependency, it can becore a bit cumbersome. If you feel this
way, then you can use an alternative method to map `pip` dependencies to `conda`
dependencies. For this, use the `tool.pyproject2.conda.dependencies` table. For
example, we can do the same thing as above with:
<!-- markdownlint-disable-next-line MD013 -->
<!-- [[[cog cat_lines(path="tests/data/test-pyproject-alt.toml", begin="[tool.pyproject2conda.dependencies]", end="[tool.pyproject2conda.envs.base]")]]] -->
```toml
# ...
[tool.pyproject2conda.dependencies]
athing = { pip = true }
bthing = { skip = true, packages = "bthing-conda" }
cthing = { channel = "conda-forge" }
pytest = { channel = "conda-forge" }
matplotlib = { skip = true, packages = [
"additional-thing; python_version < '3.9'",
"conda-matplotlib"
] }
build = { channel = "pip" }
# ...
```
<!-- [[[end]]] -->
### Specify python version
To specify a specific value of python in the output, pass a value with:
Expand Down Expand Up @@ -454,8 +483,8 @@ dependencies:
`pyproject2conda` can also be used within python:
```pycon
>>> from pyproject2conda import PyProject2Conda
>>> p = PyProject2Conda.from_path("./tests/data/test-pyproject.toml")
>>> from pyproject2conda.requirements import ParseDepends
>>> p = ParseDepends.from_path("./tests/data/test-pyproject.toml")
# Basic environment
>>> print(p.to_conda_yaml(python_include="infer").strip())
Expand Down Expand Up @@ -583,11 +612,11 @@ dependencies:
or
```pycon
>>> from pyproject2conda import PyProject2Conda
>>> p = PyProject2Conda.from_path("./tests/data/test-pyproject.toml")
>>> from pyproject2conda.requirements import ParseDepends
>>> p = ParseDepends.from_path("./tests/data/test-pyproject.toml")
# Basic environment
>>> print(p.to_conda_yaml(extras='dist-pypi', include_base_dependencies=False).strip())
>>> print(p.to_conda_yaml(extras='dist-pypi', include_base=False).strip())
channels:
- conda-forge
dependencies:
Expand Down Expand Up @@ -661,7 +690,7 @@ $ p2c project -f tests/data/test-pyproject.toml --dry
# Creating requirements base.txt
athing
bthing
cthing;python_version<'3.10'
cthing;python_version<"3.10"
# --------------------
# Creating yaml py310-test-extras.yaml
channels:
Expand Down
3 changes: 2 additions & 1 deletion docs/reference/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ Modules
:toctree: generated/
:template: autodocsumm/module.rst
parser
overrides
requirements
config
cli
Expand Down
16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ dynamic = ["readme", "version"]
requires-python = ">=3.8"
dependencies = [
"tomli",
"ruamel.yaml",
"tomlkit",
"typer",
"packaging",
Expand All @@ -52,7 +51,7 @@ test = [
]
dev-extras = [
"setuptools-scm>=8.0", #
"pytest-accept", # p2c: -p
"pytest-accept",
# "nbval",
"ipython",
"ipykernel",
Expand All @@ -66,11 +65,7 @@ typing = [
"pyproject2conda[typing-extras]", #
"pyproject2conda[test]",
]
nox = [
"nox",
"noxopt", # p2c: -p
"ruamel.yaml",
]
nox = ["nox", "noxopt", "ruamel.yaml"]
dev = [
"pyproject2conda[test]", #
"pyproject2conda[typing-extras]",
Expand All @@ -79,7 +74,7 @@ dev = [
tools = [
"pre-commit", #
# "cruft",
"scriv", # p2c: -p
"scriv",
"nbqa",
"pyright",
]
Expand Down Expand Up @@ -112,6 +107,11 @@ dist-conda = [
]
cog = ["cogapp"]

[tool.pyproject2conda.dependencies]
pytest-accept = { pip = true }
noxopt = { pip = true }
scriv = { pip = true }

[tool.pyproject2conda]
user_config = "config/userconfig.toml"
template_python = "requirements/py{py}-{env}"
Expand Down
3 changes: 1 addition & 2 deletions requirements/cog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
#
cogapp
packaging
ruamel.yaml
tomli
tomlkit
typer
typing-extensions;python_version<'3.9'
typing-extensions;python_version<"3.9"
5 changes: 2 additions & 3 deletions requirements/dev-base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ pytest-accept
pytest-cov
pytest-sugar
pytest-xdist
pytype;python_version<'3.11'
ruamel.yaml
pytype;python_version<"3.11"
setuptools-scm>=8.0
tomli
tomlkit
typer
types-click
typing-extensions;python_version<'3.9'
typing-extensions;python_version<"3.9"
4 changes: 2 additions & 2 deletions requirements/dev-complete.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ pytest-accept
pytest-cov
pytest-sugar
pytest-xdist
pytype;python_version<'3.11'
pytype;python_version<"3.11"
ruamel.yaml
scriv
setuptools-scm>=8.0
tomli
tomlkit
typer
types-click
typing-extensions;python_version<'3.9'
typing-extensions;python_version<"3.9"
4 changes: 2 additions & 2 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ pytest-accept
pytest-cov
pytest-sugar
pytest-xdist
pytype;python_version<'3.11'
pytype;python_version<"3.11"
ruamel.yaml
setuptools-scm>=8.0
tomli
tomlkit
typer
types-click
typing-extensions;python_version<'3.9'
typing-extensions;python_version<"3.9"
3 changes: 1 addition & 2 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ ipython
myst-nb
packaging
pyenchant
ruamel.yaml
sphinx-autobuild
sphinx-book-theme
sphinx-click
Expand All @@ -23,4 +22,4 @@ sphinxcontrib-spelling
tomli
tomlkit
typer
typing-extensions;python_version<'3.9'
typing-extensions;python_version<"3.9"
1 change: 0 additions & 1 deletion requirements/py310-dev-base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ dependencies:
- pytest-sugar
- pytest-xdist
- pytype
- ruamel.yaml
- setuptools-scm>=8.0
- tomli
- tomlkit
Expand Down
3 changes: 1 addition & 2 deletions requirements/py310-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ dependencies:
- myst-nb
- packaging
- pyenchant
- ruamel.yaml
- sphinx>=5.3.0
- sphinx-autobuild
- sphinx-book-theme
- sphinx-click
- sphinx-copybutton
- sphinx>=5.3.0
- sphinxcontrib-spelling
- tomli
- tomlkit
Expand Down
1 change: 0 additions & 1 deletion requirements/py310-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ dependencies:
- pytest-cov
- pytest-sugar
- pytest-xdist
- ruamel.yaml
- tomli
- tomlkit
- typer
1 change: 0 additions & 1 deletion requirements/py310-typing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ dependencies:
- pytest-sugar
- pytest-xdist
- pytype
- ruamel.yaml
- tomli
- tomlkit
- typer
Expand Down
1 change: 0 additions & 1 deletion requirements/py311-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ dependencies:
- pytest-cov
- pytest-sugar
- pytest-xdist
- ruamel.yaml
- tomli
- tomlkit
- typer
1 change: 0 additions & 1 deletion requirements/py311-typing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ dependencies:
- pytest-cov
- pytest-sugar
- pytest-xdist
- ruamel.yaml
- tomli
- tomlkit
- typer
Expand Down
1 change: 0 additions & 1 deletion requirements/py312-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ dependencies:
- pytest-cov
- pytest-sugar
- pytest-xdist
- ruamel.yaml
- tomli
- tomlkit
- typer
1 change: 0 additions & 1 deletion requirements/py312-typing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ dependencies:
- pytest-cov
- pytest-sugar
- pytest-xdist
- ruamel.yaml
- tomli
- tomlkit
- typer
Expand Down
1 change: 0 additions & 1 deletion requirements/py38-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ dependencies:
- pytest-cov
- pytest-sugar
- pytest-xdist
- ruamel.yaml
- tomli
- tomlkit
- typer
Expand Down
1 change: 0 additions & 1 deletion requirements/py38-typing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ dependencies:
- pytest-sugar
- pytest-xdist
- pytype
- ruamel.yaml
- tomli
- tomlkit
- typer
Expand Down
1 change: 0 additions & 1 deletion requirements/py39-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ dependencies:
- pytest-cov
- pytest-sugar
- pytest-xdist
- ruamel.yaml
- tomli
- tomlkit
- typer
1 change: 0 additions & 1 deletion requirements/py39-typing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ dependencies:
- pytest-sugar
- pytest-xdist
- pytype
- ruamel.yaml
- tomli
- tomlkit
- typer
Expand Down
3 changes: 1 addition & 2 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ pytest
pytest-cov
pytest-sugar
pytest-xdist
ruamel.yaml
tomli
tomlkit
typer
typing-extensions;python_version<'3.9'
typing-extensions;python_version<"3.9"
5 changes: 2 additions & 3 deletions requirements/typing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ pytest
pytest-cov
pytest-sugar
pytest-xdist
pytype;python_version<'3.11'
ruamel.yaml
pytype;python_version<"3.11"
tomli
tomlkit
typer
types-click
typing-extensions;python_version<'3.9'
typing-extensions;python_version<"3.9"
2 changes: 0 additions & 2 deletions src/pyproject2conda/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
except PackageNotFoundError: # pragma: no cover
__version__ = "999"

from .parser import PyProject2Conda

__author__ = """William P. Krekelberg"""
__email__ = "[email protected]"


__all__ = [
"__version__",
"PyProject2Conda",
]
Loading

0 comments on commit 4a0af4e

Please sign in to comment.