I am trying to create a library distributed with pip.
sudo python setup.py sdist upload -r pypitest
when I try to install it with
sudo pip install -i https://testpypi.python.org/pypi abce
It fails with
Could not find a version that satisfies the requirement pandas>=0.17 (from abce) (from versions: )
No matching distribution found for pandas>=0.17 (from abce)
I tried no for a day, but I can't make it work. When I install pandas with pip install pandas it installs the 0.18.1 version. What am I doing wrong?
The setup.py is the following:
#!/usr/bin/env python
import os
try:
from setuptools import setup
from setuptools import Extension
except ImportError:
from distutils.core import setup
from distutils.extension import Extension
cmdclass = { }
ext_modules = [ ]
try:
from Cython.Distutils import build_ext
ext_modules += [
Extension("abce.trade", [ "abce/trade.pyx" ]),
]
cmdclass.update({ 'build_ext': build_ext })
except ImportError:
ext_modules += [
Extension("abce.trade", [ "abce/trade.c" ]),
]
setup(name='abce',
version='0.5.07b',
author='Davoud Taghawi-Nejad',
author_email='Davoud#Taghawi-Nejad.de',
description='Agent-Based Complete Economy modelling platform',
url='https://github.com/DavoudTaghawiNejad/abce.git',
package_dir={'abce': 'abce'},
packages=['abce'],
long_description=open('README.rst').read(),
install_requires=['numpy>=1.9',
'pandas>=0.17',
'networkx>=1.9',
'flask>=0.10',
'bokeh>=0.11',
'matplotlib>=1.3'],
include_package_data=True,
ext_modules=ext_modules,
cmdclass=cmdclass)
On day later:
pip was searching the packages on piptest, but actually the ABCE package should come from piptest and the requirments should come from pip:
sudo pip install -i https://testpypi.python.org/pypi --extra-index-url https://pypi.python.org/pypi abce
Related
Using pip, you can easily install a package in tar form as in:
pip install https://path/to/respository/ending/with/en_core_web_sm-2.1.0/en_core_web_sm-2.1.0.tar.gz
However, I can't seem to get python setup.py install to find this same remote repository.
In setup.py, I have:
from setuptools import setup
setup(name='blah',
version='0.1.0',
description='A library',
install_requires=[
'en_core_web_sm-2.1.0.tar.gz'
],
dependency_links=[
'https://path/to/respository/ending/with/en_core_web_sm-2.1.0/en_core_web_sm-2.1.0.tar.gz'
],
packages=['blah'])
My error message is:
No local packages or working download links found for en_core_web_sm-2.1.0.tar.gz
error: Could not find suitable distribution for Requirement.parse('en_core_web_sm-2.1.0.tar.gz')
How can I accomplish the same with setup.py that I can with pip?
Figured it out. This tip from the spacy docs:
https://spacy.io/usage/models#production
You need to add #egg=en_core_web_sm to the end of the dependency_link. Final file looks like this:
from setuptools import setup
setup(name='blah',
version='0.1.0',
description='A library',
install_requires=[
'en-core-web-sm'
],
dependency_links=[
'https://path/to/respository/ending/with/en_core_web_sm-2.1.0/en_core_web_sm-2.1.0.tar.gz#egg=en_core_web_sm'
],
packages=['blah'])
I have the following directory structure:
/modules/
/modules/setup.py
/modules/setup.cfg
/modules/module1/
/modules/module1/__init__.py
/modules/module1/tool1/__init__.py
/modules/module1/tool1/tool1.py
/modules/module2/
/modules/module2/__init__.py
/modules/module2/tool2/__init__.py
/modules/module2/tool2/tool2.py
/modules/module2/tool3/__init__.py
/modules/module2/tool3/tool3.py
And I want to install these modules using setup.py and setup.cfg and import them later on like this:
import my_project.module1.tool1
import my_project.module2.tool2
import my_project.module2.tool3
These are my installation files:
setup.py
import setuptools
setuptools.setup(
setup_requires=['paramiko>=2.0.1'],
paramiko=True)
setup.cfg
[metadata]
name = my_project
summary = my project modules
[files]
packages =
module1
module2
It fails when I try to install the packages:
/modules# pip install -e .
Obtaining file:///modules
Installing collected packages: UNKNOWN
Found existing installation: UNKNOWN 0.0.0
Can't uninstall 'UNKNOWN'. No files were found to uninstall.
Running setup.py develop for UNKNOWN
Successfully installed UNKNOWN
Try using the find_packages function:
from setuptools import setup, find_packages
...
setup(
...
packages=find_packages(),
...
According to Dependency section in the setuptools manual git repository URLs can be specified in the dependency_links argument to setup with git+URL. Yet,
cd /tmp
mkdir py-test
cd py-test
touch __init__.py
and creation of a setup.py file with
from setuptools import setup, find_packages
from pkg_resources import parse_version
setup(
name = "py-test",
version = "1.0",
packages = ["."],
dependency_links = [
"git+https://github.com/wxWidgets/wxPython.git"
],
install_requires = ["wxPython"],
)
causes the error Download error on git+https://github.com/wxWidgets/wxPython.git: unknown url type: git+https -- Some packages may not be found! when I run python setup.py build && sudo setup.py install.
The installation of the package python-setuptools-git doesn't help.
I'm using setuptools 18.2 with python 2.7 on Ubuntu 15.04.
From the setuptools docs:
In the case of a VCS checkout, you should also append #egg=project-version in order to identify for what package that checkout should be used
So the fix is just to append the #egg=wxPython fragment onto the end:
dependency_links = [
"git+https://github.com/wxWidgets/wxPython.git#egg=wxPython"
]
I wrote a package available in pypi, python repository and it depends of other packages as I show with the following code of setup.py file.
try:
from setuptools import setup
except ImportError:
from distutils.core import setup
setup(
name='aTXT',
packages=['aTXT'],
# package_data={ '':['*.py'],
# 'bin': ['bin/*'], 'docx': ['docx/*'], 'pdfminer': ['pdfminer']},
version=VERSION,
include_package_data=True,
# arbitrary keywords
install_requires=[
'lxml>=3.2.3',
'docx>=0.2.0',
'pdfminer',
'docopt>=0.6.2',
'PySide',
'kitchen>=1.1.1',
'scandir>=0.8'
],
requires=['docopt', 'scandir', 'lxml', 'PySide', 'kitchen'],
)
When I'd tried to install from pip with:
pip install aTXT
If some of the requirements package are not installed, it raise a Import Error.
But, why not pip try to install all dependencies?
The following is an example if I don't have lxml package installed.
ImportError: No module named lxml
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
I have package "A" with a setup.py and an extras_requires line like:
extras_require = {
'ssh': ['paramiko'],
},
And a package "B" that depends on util:
install_requires = ['A[ssh]']
If I run python setup.py install on package B, which uses setuptools.command.easy_install under the hood, the extras_requires is correctly resolved, and paramiko is installed.
However, if I run pip /path/to/B or pip hxxp://.../b-version.tar.gz, package A is installed, but paramiko is not.
Because pip "installs from source", I'm not quite sure why this isn't working. It should be invoking the setup.py of B, then resolving & installing dependencies of both B and A.
Is this possible with pip?
We use setup.py and pip to manage development dependencies for our packages, though you need a newer version of pip (we're using 1.4.1 currently).
#!/usr/bin/env python
from setuptools import setup
from myproject import __version__
required = [
'gevent',
'flask',
...
]
extras = {
'develop': [
'Fabric',
'nose',
]
}
setup(
name="my-project",
version=__version__,
description="My awsome project.",
packages=[
"my_project"
],
include_package_data=True,
zip_safe=False,
scripts=[
'runmyproject',
],
install_requires=required,
extras_require=extras,
)
To install the package:
$ pip install -e . # only installs "required"
To develop:
$ pip install -e .[develop] # installs develop dependencies
This is suppported since pip 1.1, which was released in February 2012 (one year after this question was asked).
The answer from #aaronfay is completely correct but it may be nice to point out that if you're using zsh that the install command pip install -e .[dev] needs to be replaced by pip install -e ".[dev]".