Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

344
Visualizações
Distributing multiple packages using setup.py for Python

I'm trying to setup some Python packages that will share a common set of "utilities" but need to be able to distribute them as separate "packages." Assume the following structure:

/packages
    |-setup.py
    |-__init__.py
    |-MANIFEST.in
    |-com
    |    |-__init__.py
    |    |-company
    |    |    |-__init__.py
    |    |    |-subdir1
    |    |    |    |-__init__.py
    ...
    |-utilities
    |    |-__init__.py
    |    |-utils1.py
    |    |-utils2.py
    |    |-...
    |-package1
    |    |-__init__.py
    |    |-package1_1.py
    |    |-package1_2.py
    |    |-...
    |-package2
    |    |-__init__.py
    |    |-package2_1.py
    |    |-package2_2.py
    |    |-...

I would like to be able to use setup.py for building either package1 or package2 both of which should include the same utilities.

All of the tutorials I've found use a simple single project which makes using a single setup.py fairly straightforward. But how do I create multiple different packages from the same directory (it's a git repository) structure? At the moment I'm using package1_setup.py to build package1 that looks similar to:

from setuptools import setup,find_packages
import sys, os

version = '0.1'

setup(name = 'package1',
      version = version,
      description = 'Package 1',
      author = 'Rob Marshall',
      author_email = 'rob.marshall17@gmail.com',
      url = None,
      packages = ["package1","utils","com"],
      include_package_data = True,
      zip_safe = False,
      entry_points = {
                      'console_scripts':[
                                         'tool1 = package1.package1_1:main',
                                         'tool2 = package1.package1_2:main',
                                         ],
                      },
      install_requires = [
                          'boto >= 2.40',
                          'python-swiftclient >= 3.2.0',
                          'fabric >= 1.13.0',
                          ],
      )

So when I want to build package1 I do:

% python package1_setup.py sdist

Which creates an installable source package but is somewhat "awkward" because the setup.py is called package1_setup.py. Not that that is tragic, but I was wondering if there's a better way to do this.

Thanks,

Rob

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I may have answered my own question: If I modify the setup.py to use:

packages = find_packages(),

and change the directory structure to:

...
|-package1
|    |-setup.py
|    |-MANIFEST.in
|    |-com (symlink to ../com)
|    |-utilities (symlink to ../utilities)
|    |-package1
|    |    |-__init__.py
|    |    |-package1_1.py
|    |    |-package1_2.py
|    |    |-...

If I then cd into package1 and do:

% python setup.py sdist

It seems to create the distribution correctly.

Rob

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda