Search code examples
pythongitclonesetuptools

Change package name when running setup.py


I have forked a repo and now I have cloned it. When running the setup.py file inside, Python installs the package inside site-packages as an obscure name, that of which importing this within a Python file will not be viable.

For example, I fork and clone a repo called foo. I can also see this in the setup.py file:

setup(
    name='foo',
    version='3.3.0-rc6',
    packages=find_packages('src'),
    package_dir={'': 'src'},
    include_package_data=True,

When I run python setup.py install, I find the package has been installed as foo-3.3.0rc6-py3.6.egg. I do not want to have to import the package as this name in every one of my projects utilizing it.

How can I just change the package name to foo (when running/installing via setup.py), so that I can run import foo and not import foo-3.3...?

I feel I can not just rename it, as if I wanted other users to clone the repo and not have to go through the same trouble as me. Is the package name embedded somewhere in the setup.py folder?

Let me know if you need anything else, I'm willing to have this issue resolved.


Solution

  • You don't have to import foo-3.3; actually you cannot import as it's SyntaxError.

    You don't have to import foo-3.3 from foo-3.3.0rc6-py3.6.egg because distutils/setuptools configured correct import path for eggs. Look into easy-install.pth file and you find there ./foo-3.3.0rc6-py3.6.egg. Run python and verify sys.path — there have to be foo-3.3.0rc6-py3.6.egg entry so that import foo works.