0

I'm building a small Python package with a friend.

.
├── __init__.py
└── memoized.py

During the development process, I want to test the installed package - for example, to make sure that some __init__.py code runs as expected.

The current way to achieve this is:

  1. Create a virtualenv on /tmp
  2. Activate it
  3. cd to the repo dir
  4. python setup.py install
  5. cd elsewhere (to avoid importing from the directory instead of importing from the installed package)
  6. Test the import
  7. pip uninstall memoized
  8. Repeat steps 3-7

This is long and cumbersome, and I vaguely remember there's a way to install a package in a way that does not copy its code to the virtualenv, but links to it instead. This way changing the code would be reflected at the next import, without re-installing.

I've searched for "Dynamic importing" and alike but it refers to a different feature.

How can I install a local Python package so that changes to the package code would be immediately reflected?

1
  • 1
    Did you create setup.py file ? Working in development mode is done with python setup.py develop Commented Jul 4, 2021 at 10:29

1 Answer 1

4

You could activate the virtualenv first and navigate to the project directory. Then run

pip install --editable . 

--editable install a project in editable mode and uses current working directory instead of copying the source code.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.