Skip to main content

Manage Python / Django projects

Project description

manageprojects - Manage Python / Django projects

tests codecov manageprojects @ PyPi Python Versions License GPL

Mix the idea of Ansible with CookieCutter Templates and Django Migrations to manage and update your Python Packages and Django Projects...

The main idea it to transfer changes of a CookieCutter template back to the created project. Manageproject used git to create a patch of the template changes and applies it to the created project.

install

Currently just clone the project and just start the cli (that will create a virtualenv and installs every dependencies)

e.g.:

~$ git clone https://github.com/jedie/manageprojects.git
~$ cd manageprojects
~/manageprojects$ ./cli.py --help

workflow

1. Create a new project

Use start-project command and a github url as Cookiecutter template, e.g.:

~/manageprojects$ ./cli.py start-project https://github.com/jedie/cookiecutter_templates/ --directory piptools-python ~/my_new_project/
~/manageprojects$ cd ~/my_new_project/your_cool_package/
~/my_new_project/your_cool_package/$ git init
~/my_new_project/your_cool_package/$ git add .
~/my_new_project/your_cool_package/$ git commit --message "my cool new project"

Note: https://github.com/jedie/cookiecutter_templates is a multi template repository, the piptools-python template is here: https://github.com/jedie/cookiecutter_templates/tree/main/piptools-python

After running the start-project command, look into the created files. Manage projects stores all needed meta information about the used Cookiecutter template into pyproject.toml, e.g.:

~/manageprojects$ cat ~/my_new_project/your_cool_package/pyproject.toml
...
[manageprojects] # https://github.com/jedie/manageprojects
initial_revision = "6e4c875"
initial_date = 2022-11-10T12:37:20+01:00
cookiecutter_template = "https://github.com/jedie/cookiecutter_templates/"
cookiecutter_directory = "piptools-python"

[manageprojects.cookiecutter_context.cookiecutter]
...

2. Update existing project

If the source Cookiecutter changed, then you can apply these changes to your created project, e.g.:

~/manageprojects$ ./cli.py update-project ~/my_new_project/your_cool_package/

After this, manageproject will update the own meta information in pyproject.toml by add applied_migrations with the information about the current Cookiecutter version, e.g.:

~/manageprojects$ cat ~/my_new_project/your_cool_package/pyproject.toml
...
[manageprojects] # https://github.com/jedie/manageprojects
initial_revision = "6e4c875"
initial_date = 2022-11-10T12:37:20+01:00
cookiecutter_template = "https://github.com/jedie/cookiecutter_templates/"
cookiecutter_directory = "piptools-python"
applied_migrations = [
    "dd69dcf", # 2022-11-22T19:48:28+01:00
]
...

How?

Everything is based on git ;)

  • manageprojects knows the git hash of the used Cookiecutter Template at creation time and the current git hash.
  • It builds a git patch between these two commits.
  • This patch will be applied to the created project sources.

So theoretically the changes in the template are applied to the project.

However, this does not work in every case, because git can't match the changes.

See below:

drawbacks

One problem is that git can't apply all changes.

But git apply is used with --reject. It applies the parts of the patch that are applicable, and leave the rejected hunks in corresponding *.rej files.

There is a cool tool, called wiggle: https://github.com/neilbrown/wiggle

It tries to apply rejected patches by perform word-wise diffs.

Just run wiggle via manageproject CLI, e.g.:

~/manageprojects$ ./cli.py wiggle ~/my_new_project/your_cool_package/

Helper: Reverse a project into a Cookiecutter template

A existing managed project can be converted back to a Cookiecutter template, e.g.:

~/manageprojects$ ./cli.py reverse ~/my_new_project/ ~/cookiecutter_template/

Links

Project details


Release history Release notifications | RSS feed

This version

0.5.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

manageprojects-0.5.0.tar.gz (41.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

manageprojects-0.5.0-py3-none-any.whl (50.9 kB view details)

Uploaded Python 3

File details

Details for the file manageprojects-0.5.0.tar.gz.

File metadata

  • Download URL: manageprojects-0.5.0.tar.gz
  • Upload date:
  • Size: 41.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for manageprojects-0.5.0.tar.gz
Algorithm Hash digest
SHA256 d0e3dd3dd8d9eebf05b9e93a0fef740222d54aeb4f60ae03e61a0d4e58cd7bf7
MD5 7b2a18362bd185e5a77c0cabd7927b22
BLAKE2b-256 e6398a8d44f5d16666706cd0aa7fcb48ced722e4cfaf1be7d01f677214f7d942

See more details on using hashes here.

File details

Details for the file manageprojects-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: manageprojects-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 50.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for manageprojects-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c1f014430fc506a5ca103b73a6793447ee5bb55aa0bf782d14c171189b1d7952
MD5 a4699d0738e1a3f4589a8433115b61fe
BLAKE2b-256 d57381623fab1a8d7512b038a4e86b0e0ed37c29416aed714ec54d0a3540574a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page