cs01/create-python-package

Pipenv integration

florimondmanca opened this issue · 7 comments

create-python-package creates a virtualenv by default. While I think this is a fair default, more and more people (myself included) made the switch to pipenv to manage dependencies.

I'd love to see a --pipenv option that would run:

pipenv install -e .

for us. After that, we can switch to use pipenv so this wouldn't interfere with the current shortcuts around virtualenvs.

cs01 commented

This has been added in 0.2.0.2.

This message is printed if Pipenv is chosen

pipenv install -e .  # install this package in editable mode

Any other feedback or contributions are welcome! I don't use Pipenv, so I will be very receptive to any other workflow suggestions you have.

This project is very young, so please feel free to add more issues/pull requests for anything else you think of.

I recently added tests, so you can run python setup.py test. I use makefiles, so I added make targets like make publish. Let me know what you think!

Tried this out too — it works quite well!

However I'm not sure adding an empty Pipfile is enough. When running pipenv install in the newly created package, pipenv actually recreates the Pipfile which then looks like this:

[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true

[dev-packages]

[packages]

[requires]
python_version = "3.7"

There are few items that are installation-dependant (e.g. the Python version), so I think we could just run pipenv install similarly to python -m venv being run when virtualenv is chosen. And we'd let it fail if pipenv is not installed.

What do you think?

cs01 commented

I think we could just run pipenv install

Sounds good!

And we'd let it fail if pipenv is not installed.

I think it should be more friendly here. CPP could check if the pipenv executable exists (from distutils.spawn import find_executable). If it does, run it.

If not, print something like

You can start working on your project by installing pipenv, then running pipenv install from the root of the package.

I will defer to you on what the best pipenv command is to start working (pipenv install -e vs pipenv install, etc).

cs01 commented

This has been added in 0.2.1.0. Let me know what you think! 😄

Just gave this a shot — the Pipfile and Pipfile.lock file along with the virtualenv were correctly generated! Well done. It doesn't install -e ., but I'm okay with that, it's not something absolutely required for a minimal yet functional Python package installation. :-)

cs01 commented

Great! Is it more common to kick off the project with pipenv install -e? It's easy enough to change, just say the word.

Well, it's not for a regular project, but now that I think about it, in the context of a Python package I think that's actually a very common thing to do. At least, I do it every time.

The exact command would be:

pipenv install -e .