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'])
Related
I have a project that makes use of certain C package. Building the package is done as below in a setup.py file:
from setuptools import setup
import torch
if torch.cuda.is_available():
from torch.utils.cpp_extension import BuildExtension, CUDAExtension
setup(
name='iou3d',
ext_modules=[
CUDAExtension('iou3d_cuda', [
'src/iou3d.cpp',
'src/iou3d_kernel.cu',
],
extra_compile_args={'cxx': ['-g'],
'nvcc': ['-O2']})
],
cmdclass={'build_ext': BuildExtension})
Now this is being setup correctly if I already have pytorch installed in my environment.
But if I am doing a fresh install on a clean environment using requirements.txt, and I want to install everything in one shot by pip install -r requirements.txt I am not sure how can I get to install pytorch first to be able to import it in the setup.py.
Appreciate your help.
So what i mean by the title is like this, I'm gonna create a python package and it needs pygame for my package to work, but I can't figure out how do you add that in setup.py
from setuptools import setup
setup(
...
install_reqs=[
"pygame",
],
...
)
I change install_reqs into???
install_requires.
See documentation of the setup function
I am trying to install hw3 package which has a dependency package hw2. My setup.py looks as follows -
setup(
name='hw3',
version='0.1',
packages = find_packages(),
install_requires = 'hw2',
dependency_links = [
r'svn+https://server.local/svn/Libraries/testPkg2/trunk#egg=hw2'
]
)
I get the following error when I run python setup.py install in windows cmd
svn: E170013: Unable to connect to a repository at URL 'svn+https://server.local/svn/Libraries/testPkg2/trunk'
svn: E125002: Undefined tunnel scheme 'https'
Alternatively, I have requirements.txt which is as follows
svn+https://server.local/svn/Libraries/testPkg2/trunk#egg=hw2
If I run pip install -r requirements.txt, it installs hw2 package successfully.
My svn version is
svn, version 1.9.7 (r1800392) compiled Aug 8 2017, 22:14:48 on
x86-microsoft-windows
how to resolve this error? Thanks
I am getting the same error for 'http' and 'svn'.
For 'ssh' it is
svn: E170012: Can't create tunnel
svn: E720002: Can't create tunnel: The system cannot find the file specified.
Maybe try it directly with the install_requires option (requires pip>=18.1):
setup(
name='hw3',
version='0.1',
packages = find_packages(),
install_requires = ['hw2#svn+https://server.local/svn/Libraries/testPkg2/trunk#egg=hw2'],
)
See also this answer to a related question https://stackoverflow.com/a/54216163/13835019.
Is possible to avoid using pip and requirements.txt in favor of just using setup.py to install missing libraries but not having build all other stuff?
Normally it's looks like (and is run python setup.py install:
from setuptools import setup, find_packages
setup(
name="HelloWorld",
version="0.1",
packages=find_packages(),
install_requires=['docutils>=0.3'],
)
And I wish to use only install_requires=['docutils>=0.3'] to have those dependencies resolved and avoid all build artifacts.
Depending on the setup you are using, there is:
install_requires with setuptools
See also:
https://packaging.python.org/requirements/
Adding 'install_requires' to setup.py when making a python package
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]".