Pipeline fail to publish to pypi when package contains dependencies
Asked by diego.magalhaes:

I'm trying to publish a python package but build fails on pipe

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/118106iDB4C1293B3570E85/image-size/large?v=v2&px=999 "image.png")

My package requires requests and pytz so, on setup.py I have install_requires=\['requests', 'pytz'\]

The atlassian/pypi-publish:0.3.1 image can't find pytz module so, how I can handle this?  

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/118107iF78A5DAC70F600DA/image-size/large?v=v2&px=999 "image.png")


Answers:
author: Halyna Berezovska
body: [@diego.magalhaes](/t5/user/viewprofilepage/user-id/4159189)

follow Python Packaging guide <https://packaging.python.org/tutorials/packaging-projects/#generating-distribution-archives>

and use appropriate DISTRIBUTIONS.

Like  
'DISTRIBUTIONS': 'sdist bdist_wheel'  
This should help you.  
You also may want some of the next commands to put in DISTRIBUTIONS variable instead of that, depending on your case (generally you need either bdist_wheel distributions or just execute the command Before publishing : \`python setup.py install\`, e.g.).  
You can find more commands cli man , typing  
\`python setup.py --help-commands\`  
Regards, Galyna

comments: author: diego.magalhaes
body: Hey [@Halyna Berezovska](/t5/user/viewprofilepage/user-id/3865505) thanks for the reply but it will not help.

I already following this exactly Python Package guide and have the DISTRIBUTION set on my bitbucket-pipelines.yml. Using a python venv without pytz, the behavior is the same when I ran "python setup.py " ModuleNotFoundError: No module named 'pytz'

Since pytz and requests are needed, I need to install it on [pypi-publish](https://bitbucket.org/atlassian/pypi-publish/)before [pipe.py](https://bitbucket.org/atlassian/pypi-publish/src/master/pipe/pipe.py) run.


author: Halyna Berezovska
body: [@diego.magalhaes](/t5/user/viewprofilepage/user-id/4159189)

try to run

```
python setup.py install
```

or

```
python setup.py develop
```

instead, before using the pipe publishing. This should install needed things.

I have tested this with pytz also and with other packages and this works for our repository also where we publish package with dependencies.

E.g.

```
deploy: &deploy
  step:
    name: Deploy to PyPI
    script:
    - python setup.py install
    - pipe: atlassian/pypi-publish:0.2.3
      variables:
        PYPI_USERNAME: $USERNAME
        PYPI_PASSWORD: $PASSWORD
```


author: Halyna Berezovska
body: [@diego.magalhaes](/t5/user/viewprofilepage/user-id/4159189) if doesn't , please share full logs, we'll try to investigate


author: diego.magalhaes
body: [@Halyna Berezovska](/t5/user/viewprofilepage/user-id/3865505)

I found a way to solve this problem before your reply. The pipe was removed from yaml and I used twine to upload and it directly so:

```
script: 
  - export BUILD_VERSION=${BITBUCKET_TAG}
  - pip install twine requests pytz
  - python setup.py sdist bdist_wheel
  - twine check dist/*
  - twine upload -u ${PYPI_USERNAME} -p ${PYPI_PASSWORD} dist/*
```

Thank's for your support!


Tags: bitbucket-pipelines

publish

python