3

I have 2 package uploaded which are in my gitlab repository, if I want to install them in my system using pip, it's easy because gitlab helps you:

https://docs.gitlab.com/ee/user/packages/pypi_repository/index.html

pip install <package-name> --extra-index-url https://<username>:<your_personal_token>@gitlab.com/api/v4/projects/<project ID>/packages/pypi/simple

the name of those two package:

  • core_1
  • service_1

What I want it's to create other package where it download those two private package and I need to configurate in setup.py:

this is my setup.py

from setuptools import setup, find_packages

setup(
name='my_project',
version='0.1.0',
packages=find_packages(),
package_data = {
    'config':['*.yaml']
    },
include_package_data=True,
install_requires=[
    'click', 
    'colorama',
    'core_1 --extra-index-url https://joelbarrantespalacios:<personal_token>@gitlab.com/api/v4/projects/<project_ID>/packages/pypi/simple',
    'service_1 --extra-index-url https://joelbarrantespalacios:<personal_token>@gitlab.com/api/v4/projects/<project_ID>/packages/pypi/simple'
],
entry_points={
    'console_scripts': [
        'darit = core_project.cli:start',
    ],
},

)

of course, <personal_token> and <project_ID> needs to be add however I'm not giving you because it's a private package.

joelbarrantespalacios: it's my username

this is what I found in setuptools's Documentation where it shows how to create a Dependencies that aren’t in PyPI, but it's not clear for me

https://setuptools.pypa.io/en/latest/userguide/dependency_management.html

I really need you helps guys, give me some hope.

1 Answers1

2

You should add the index/authentication information to a pip.cfg file or ~/.pypirc file.

Using a ~/.pypirc file:

[gitlab]
repository = https://gitlab.example.com/api/v4/projects/<project_id>/packages/pypi
username = <username>
password = <token>

Where <token> is an API token with API scope. Alternatively, provide the index/auth information to pip when installing your packages.

Your setup.py dependencies should simply declare the name of the package. e.g.

# ...
install_requires=[
    'core_1',
    'service_1',
#...

pip will resolve it from the configured registries in your pip.cfg or .pypirc file (or pip CLI options) automatically.

Your setup.py gets bundled with your package when it is uploaded to the registry and is downloaded by its users, so it obviously shouldn't contain sensitive information like your passwords/tokens anyhow!

sytech
  • 29,298
  • 3
  • 45
  • 86
  • yeah, when i ask this question, i've made a mistake 'cause i tried to install 'my_project' compiled in my system and I hoped it installs core_1 and service_1, of course i didn't upload 'my_project' to PyPI. afterwards, I uploaded 'my_project' to PyPI and then It just installs core_1 and service_1. PD: we need to pu this in setup.py install_requires=[ 'core_1', 'service_1'] – Joel Barrantes Jan 20 '22 at 18:35