I am trying to install a local package from source with pip, but my code does not get copied in the site-packages folder. Instead a folder is created with a json file linking to the path of my python source code. Is this expected behaviour ? what is the difference with the difference with installation in developement mode (with the -e flag).
My working path looks like this:
├── setup.py
└── my_package
├── __init__.py
└── module.py
My setup.py file looks like this:
import setuptools
setuptools.setup(name='my_package', version='0.0.1')
I am typing:
python -m pip install .
and then when I import my package in python, it tells me the imported package is located in my source code folder:
>>> import my_package
>>> my_package.__file__
path/to/my/desktop
What would be the recommended way to distribute my package to my collegues, without uploading it on PyPi ? Also can someone please explain to me the differences between .wheel, .tar.gz, and .egg files that can be generated with setuptools, and their use case ?
I found a solution that suits me. I generate a .whl file from my package using the command
python -m pip wheel .
In the folder containing the setup.py. This generates a .whl file, that my collegues can install using the command
python -m pip install .\my_package-0.0.1-py3-none-any.whl
ziping you source code (including the setup.py) would work too, but it looks less clean.
Also i found out why installing from source without the -e flag was not copying my code in my "site-package" folder. Installing a package generates two folder: A "my_package-0.0.1.dist-info" folder and "my_module" folder. I was missing the "package" kwarg in my setup.py script, so the version info folder was created but not the folder containing the code. Here below a corrected setup.py
import setuptools
setuptools.setup(name="my_package", version='0.0.1', packages=["my_package"])
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With