How can I get the version defined in setup.py (setuptools) in my package?

Interrogate version string of already-installed distribution To retrieve the version from inside your package at runtime (what your question appears to actually be asking), you can use: import pkg_resources # part of setuptools version = pkg_resources.require(“MyProject”)[0].version Store version string for use during install If you want to go the other way ’round (which appears to … Read more

“pip install –editable ./” vs “python setup.py develop”

Try to avoid calling setup.py directly, it will not properly tell pip that you’ve installed your package. With pip install -e: For local projects, the “SomeProject.egg-info” directory is created relative to the project path. This is one advantage over just using setup.py develop, which creates the “egg-info” directly relative the current working directory. More: docs … Read more

Reference requirements.txt for the install_requires kwarg in setuptools setup.py file

On the face of it, it does seem that requirements.txt and setup.py are silly duplicates, but it’s important to understand that while the form is similar, the intended function is very different. The goal of a package author, when specifying dependencies, is to say “wherever you install this package, these are the other packages you … Read more

pip ignores dependency_links in setup.py

This answer should help. In a nutshell, you need to specify the version (or “dev”) for the #egg=python-s3 so it looks like #egg=python-s3-1.0.0. Updates based on @Cerin’s comment: Pip 1.5.x has a flag to enable dependency-links processing: –process-dependency-links. I haven’t tested it because I agree with the point below. This discussion seems to indicate that … Read more

Installing SetupTools on 64-bit Windows

Problem: you have 64-bit Python, and a 32-bit installer. This will cause problems for extension modules. The reasons why the installer doesn’t finds Python is the transparent 32-bit emulation from Windows 7. 64-bit and 32-bit programs will write to different parts of the Windows registry. 64-bit: HKLM|HKCU\SOFTWARE\ 32-bit: HKLM|HKCU\SOFTWARE\wow6432node\. This means that the 64-bit Python … Read more

Src layout to dispense .src prefix in imports? Activate venv in PyCharm terminal for development installs

Update / Workaround One can follow the steps in this link to mark a folder as a source root. From the link: Source roots the Source root icon contain the actual source files and resources. PyCharm uses the source roots as the starting point for resolving imports This way we don’t have to install It … Read more

How include static files to setuptools – python package

As pointed out in the comments, there are 2 ways to add the static files: 1 – include_package_data=True + MANIFEST.in A MANIFEST.in file in the same directory of setup.py that looks like this: include src/static/* include src/Potato/*.txt With include_package_data = True in setup.py. 2 – package_data in setup.py package_data = { ‘static’: [‘*’], ‘Potato’: [‘*.txt’] … Read more

How can I make setuptools install a package that’s not on PyPI?

The key is to tell easy_install where the package can be downloaded. In this particular case, it can be found at the url http://github.com/mtai/python-gearman/tarball/master. However, that link by itself won’t work, because easy_install can’t tell just by looking at the URL what it’s going to get. By changing it to http://github.com/mtai/python-gearman/tarball/master#egg=gearman-2.0.0beta instead, easy_install will be … Read more

Explain Python entry points?

An “entry point” is typically a function (or other callable function-like object) that a developer or user of your Python package might want to use, though a non-callable object can be supplied as an entry point as well (as correctly pointed out in the comments!). The most popular kind of entry point is the console_scripts … Read more