0

I want to use setuptools to create a package consisting of two files: foo.py (script) and foo.conf.

Then I want to publish the package on my devpi-server and then install the package using pip.

Suppose I that initially I have my current working directory clean

$ ls -l
total 0

Then I issue pip install (or download?) command

$ pip install -i http://mydevpi.server foo

And get a dir with my two files created

$ tree
.
|
foo
|
|\_ foo.py
|
 \_ foo.conf

So questions are:

  • what setuptools configuration should I use?
  • what exact pip command should I use to install the package the way I want? Will pip install -i http://mydevpi.server --target=. do the trick?
konstunn
  • 355
  • 4
  • 17
  • You can install in local directory and use `setuptools` to write a `setup.py` – aristotll Jul 29 '17 at 12:52
  • Yes, that's what I want. Will `pip install -i http://mydevpi.server --target=.` do the trick? – konstunn Jul 29 '17 at 12:53
  • Maybe you can create a wheel file from the source, see https://pip.pypa.io/en/stable/reference/pip_wheel/ and install using `pip install the_wheel_file_path` – aristotll Jul 29 '17 at 12:58

1 Answers1

0

First write somethings as setup.py in foo directory like:

import setuptools

setuptools.setup(
    name='foo_pip',
    version='1',
    packages=[''],
    url='1',
    license='1',
    author='1',
    author_email='1',
    description='1'
)

(You can use distutils or setuptools)

Then python setup.py bdist_wheel -d TARGET and there will be a whl file in target directory, copy the path.

You can now install using pip install the_wheel_file_path --prefix="the_path_to_install"

Something like this

Processing .../TARGET/foo_pip-1-py2-none-any.whl
Installing collected packages: foo-pip
Successfully installed foo-pip-1

Then use it by import foo

aristotll
  • 8,694
  • 6
  • 33
  • 53
  • What would be the `pip install` command to install the package that way but not from local path, but from `pypi`? – konstunn Jul 29 '17 at 13:14
  • @konstunn You should first upload the package to pypi see https://packaging.python.org/tutorials/distributing-packages/#uploading-your-project-to-pypi – aristotll Jul 29 '17 at 13:19
  • The solution you have provided does not solve my problem. Maybe I want to use things the wrong way, but I want to install the package in custom working directory. You have suggested creating a wheel in custom working directory, but after `pip install` this wheel will be installed in usual manner. – konstunn Jul 29 '17 at 14:59
  • @konstunn sorry about the mistake, but you can use `--prefix"` to specify the install directory – aristotll Jul 29 '17 at 15:04