linkedin / linkedin/pygradle

How to use a tar.gz as a dep in another project

Open
#218 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
603
Forks
142
PR merge metrics
No merged PRs in 30d

Description

I managed to build a tar.gz of a module using pygradle, and am now wanting to import it into another project and use it.

My gradle file has the following dependency from the tar.gz created before:

dependencies {
    python 'pypi:requests:2.9.1'
    python 'com.myawesomedomain.pyexample:helloworld:0.0.1' // My module
    test 'pypi:mock:1.3.0'
}

and the setup.py has the following setup portion:

setup(
    distclass=GradleDistribution,
    package_dir={'': 'src'},
    packages=find_packages('src'),
    include_package_data=True,
    entry_points={
        'console_scripts': [
            'import_example = import_example.run:main',
        ]
    }
)

However, when I build, all I get is another build/distributions/import_example-0.0.1.tar.gz which doesn't seem to contain the original helloworld-0.0.1.tar.gz package anywhere.

I do see the helloworld packages in build/venv/lib/python2.7/site-packages/helloworld, but that doesn't help with creating a publishable artifact since venv isn't a package.

Looking at the example projects provided, I get the impression that I was supposed to get a build/deployable artifact which might be what I am missing.

Also, how am I supposed to run this with the entry point? I thought it might be ./activate import_example but that clearly isn't it.

Also when I get the following errors when I try to run ./build/venv/bin/import_example

Traceback (most recent call last):
  File "./build/venv/bin/import_example", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/mnt/c/Users/myuser/Documents/dev/pyexample_import/build/venv/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3138, in <module>
    @_call_aside
  File "/mnt/c/Users/myuser/Documents/dev/pyexample_import/build/venv/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3124, in _call_aside
    f(*args, **kwargs)
  File "/mnt/c/Users/myuser/Documents/dev/pyexample_import/build/venv/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3151, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/mnt/c/Users/myuser/Documents/dev/pyexample_import/build/venv/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 661, in _build_master
    ws.require(__requires__)
  File "/mnt/c/Users/myuser/Documents/dev/pyexample_import/build/venv/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 962, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/mnt/c/Users/myuser/Documents/dev/pyexample_import/build/venv/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 849, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'helloworld' distribution was not found and is required by import-example

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Gradle dependency block and setup.py, then inspect the generated build/distributions/import_example-0.0.1.tar.gz and build/venv/bin/import_example. Reproduce the build and entry-point invocation, checking why helloworld is absent from the publishable artifact and produces DistributionNotFound. Done means the documented workflow produces a usable artifact and runs the import_example entry point.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.