Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is setup.py installing old files?

I'm working on a python module for a larger system. I did a setup.py package for installing it in the main module. It worked correctly, but then i did some changes to my module, mainly modified the names of the py files, and reorganize a bunch of classes.

Then I updated the version of the module, uninstall the old one with pip, and install the new version using python setup.py install and when i try to import in ipython found that i got the older, erased module.

Found it quite odd and checked my virtualenv lib folder and found both versions of the module, with the old classes structure and the new one. And both usable, as I imported both in ipython and tested it.

It doesn't raises any problem, as I can simply use the newest version, but is confusing. Any idea why this behaviour?

like image 841
cllamach Avatar asked Sep 12 '14 21:09

cllamach


People also ask

Is setup py outdated?

py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. I found a very detailed write-up explaining this issue: "Why you shouldn't invoke setup.py directly" (October 2021).

Is setup py install deprecated?

With the latest version of setuptools, the python setup.py install command is being deprecated (see https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for more info).

What does setup py clean do?

As far as I know, it just removes the the build subdirectory, where Python puts all the files to be installed, including extensions that need to be compiled.

What are setup py files?

The setup.py file is a Python file which indicates that the installation module/package is most likely packed and distributed using Distutils, the Python Module distribution standard.


1 Answers

If you don't install with pip, you can't uninstall with pip, so you never actually uninstalled the old version. python setup.py install will install different versions, but typically they install on top of the old versions (except for the .egg-info file or directory). You don't say how exactly the two versions were living side-by-side, because setup.py (or pip) won't rename site-packages/my_module to my_module_v1, for example. I assume that you changed the directory structure and .py file names enough that the two versions could coexist in the same parent directory, so in IPython you could run from my_module import OldClassName and from my_module import NewClassName.

like image 111
MattDMo Avatar answered Oct 06 '22 00:10

MattDMo