

GitHub - dephell/dephell: Python project management. Manage packages: convert be...
source link: https://github.com/dephell/dephell
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md
DepHell -- project management for Python.
- Manage dependencies: convert between formats, instаll, lock, add new, resolve conflicts.
- Manage virtual environments: create, remove, inspect, run shell, run commands inside.
- Install CLI tools into isolated environments.
- Manage packages: install, list, search on PyPI.
- Build packages (to upload on PyPI), test, bump project version.
- Discover licenses of all project dependencies, show outdated packages, find security issues.
- Generate .editorconfig, LICENSE, AUTHORS, .travis.yml.
See documentation for more details.
Installation
The simplest way:
python3 -m pip install --user dephell[full]
See installation documentation for better ways.
Supported formats
- Archives:
- *.egg-info (
egginfo
) - *.tar.gz (
sdist
) - *.whl (
wheel
)
- *.egg-info (
- pip:
- requirements.txt (
pip
) - requirements.lock (
piplock
)
- requirements.txt (
- pipenv:
- Pipfile (
pipfile
) - Pipfile.lock (
pipfilelock
)
- Pipfile (
- pоetry:
- pyproject.toml (
poetry
) - poetry.lock (
poetrylock
)
- pyproject.toml (
- Other:
- setup.py (
setuppy
) - pyproject.toml build-system requires (
pyproject
) - Installed packages (
installed
).
- setup.py (
Usage
First of all, install DepHell and activate autocomplete:
python3 -m pip install --user dephell[full] dephell autocomplete
Let's get sampleproject and make it better.
git clone https://github.com/pypa/sampleproject.git
cd sampleproject
This project uses setup.py for dependenciesand metainfo. However, this format over-complicated for most of projects. Let's convert it into poetry:
dephell deps convert --from=setup.py --to=pyproject.toml
It will make next pyproject.toml
:
[tool.poetry] name = "sampleproject" version = "1.2.0" description = "A sample Python project" authors = ["The Python Packaging Authority <[email protected]>"] readme = "README.md" [tool.poetry.scripts] sample = "sample:main" [tool.poetry.dependencies] python = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,<4,>=2.7" coverage = {optional = true} peppercorn = "*" [tool.poetry.dev-dependencies] check-manifest = "*" [tool.poetry.extras] test = ["coverage"]
Now, let's generate some useful files:
dephell generate authors
dephell generate license MIT
# https://editorconfig.org/
dephell generate editorconfig
Our users, probably, has no installed poetry, but they, definitely, has pip that can install files from setup.py. Let's make it easier to generate setup.py
from our pyproject.toml
. Also, it points for DepHell your default dependencies file. Add next lines in the pyproject.toml
:
[tool.dephell.main] from = {format = "poetry", path = "pyproject.toml"} to = {format = "setuppy", path = "setup.py"}
You can see full real world example of config in DepHell's own pyproject.toml.
Now we can call DepHell commands without explicitly specifying from
and to
:
dephell deps convert
It will make setup.py and README.rst from pyproject.toml and README.md.
Now let's test our code into virtual environment:
$ dephell venv run pytest WARNING venv does not exist, creating... (project=/home/gram/Documents/sampleproject, env=main, path=/home/gram/.local/share/dephell/venvs/sampleproject-Whg0/main) INFO venv created (path=/home/gram/.local/share/dephell/venvs/sampleproject-Whg0/main) WARNING executable does not found in venv, trying to install... (executable=pytest) INFO build dependencies graph... INFO installation... # ... pip output # ... pytest output
Also, we can just activate virtual environment for project and run any commands inside:
dephell venv shell
Ugh, we has tests, but has no pytest
in our dependencies file. Let's add it:
dephell deps add --envs dev test -- pytest
Afer that our dev-dependencies looks like this:
[tool.poetry.dev-dependencies] check-manifest = "*" pytest = "*" [tool.poetry.extras] test = ["coverage", "pytest"]
One day we will have really many dependencies. Let's have a look how many of them we have now:
$ dephell deps tree - check-manifest [required: *, locked: 0.37, latest: 0.37] - coverage [required: *, locked: 4.5.3, latest: 4.5.3] - peppercorn [required: *, locked: 0.6, latest: 0.6] - pytest [required: *, locked: 4.4.0, latest: 4.4.0] - atomicwrites [required: >=1.0, locked: 1.3.0, latest: 1.3.0] - attrs [required: >=17.4.0, locked: 19.1.0, latest: 19.1.0] - colorama [required: *, locked: 0.4.1, latest: 0.4.1] - funcsigs [required: >=1.0, locked: 1.0.2, latest: 1.0.2] - more-itertools [required: <6.0.0,>=4.0.0, locked: 5.0.0, latest: 7.0.0] - six [required: <2.0.0,>=1.0.0, locked: 1.12.0, latest: 1.12.0] - more-itertools [required: >=4.0.0, locked: 7.0.0, latest: 7.0.0] - pathlib2 [required: >=2.2.0, locked: 2.3.3, latest: 2.3.3] - scandir [required: *, locked: 1.10.0, latest: 1.10.0] - six [required: *, locked: 1.12.0, latest: 1.12.0] - pluggy [required: >=0.9, locked: 0.9.0, latest: 0.9.0] - py [required: >=1.5.0, locked: 1.8.0, latest: 1.8.0] - setuptools [required: *, locked: 41.0.0, latest: 41.0.0] - six [required: >=1.10.0, locked: 1.12.0, latest: 1.12.0]
Hm... Is it many or not? Let's look on their size.
$ dephell inspect venv --filter=lib_size 11.96Mb
Ugh... Ok, it's Python. Are they actual?
$ dephell deps outdated [ { "description": "More routines for operating on iterables, beyond itertools", "installed": [ "5.0.0" ], "latest": "7.0.0", "name": "more-itertools", "updated": "2019-03-28" }, ]
Pytest
requires old version of more-itertools
. That happens.
If our tests and dependencies are OK, it's time to deploy. First of all, increment project version:
$ dephell project bump minor INFO generated new version (old=1.2.0, new=1.3.0)
And then build packages:
$ dephell project build INFO dumping... (format=setuppy) INFO dumping... (format=egginfo) INFO dumping... (format=sdist) INFO dumping... (format=wheel) INFO builded
Now, we can upload these packages on PyPI with twine.
This is some of the most useful commands. See documentation for more details.
Compatibility
DepHell tested on Linux and Mac OS X with Python 3.5, 3.6, 3.7. And one of the coolest things that DepHell ran by DepHell on Travis CI.
How can I help
- Star project on Github. Developers believe in the stars.
- Tell your fellows that Gram has made cool thing for you.
- Open an issue if you have thoughts how to make DepHell better.
- Things that you can contribute in any project in DepHell ecosystem:
- Fix grammar and typos.
- Document new things.
- Tests, we always need more tests.
- Make READMEs more nice and friendly.
- See issues by help wanted label to find things that you can fix.
- Anything what you want. If it is a new feature, please, open an issue before writing code.
Thank you ❤️
Recommend
-
151
Free Software Foundation Skip to main text
-
66
README.rst unyt
-
89
C2F is an interesting little project. I hope to find a way to convert css styles to flutter styles. I believe many web developers wil...
-
37
README.md TYPO3 CMS
-
21
README.md
-
5
20 Go Packages You Can Use in Your Next ProjectImprove your application and save your time.
-
6
Swift Packages – Dependency Management of the FuturePackage Management has been around for decades. There’s everything from APT to Maven to chocolatey. For those who work in the Apple space we are probably more familiar with Coc...
-
3
TYPO3 CMS TYPO3 is an open source PHP based web content management system released under the GNU GPL. TYPO3 is copyright (c) 1999-2021 by Kasper Skaarhoj. This document provides a basic introduction to TYPO3. Getting S...
-
10
epassaro Posted on Nov 19
-
4
Project: Convert Any Art To Music Using Python And Machine Learning Machine Learning ...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK