question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Integrating with distutils/setuptools

See original GitHub issue

Hello all,

Is there a clean and recommended way to integrate distutils/setuptools in a Visual Studio Python project?

I’m specifically looking at this from the context of a Python library developed under Visual Studio and distributed according to the Python Packaging Guidelines.

Ideally, any setup.py command could be run from Visual Studio, including OTOH :

  • bdist_wheel to generate a Wheel package
  • bdist_wininst to generate a Windows installer
  • test for integrating unit/integration test frameworks (e.g. PyTest)

This is a hack, but adding this custom AfterBuild target in the .pyproj file generates a Windows installer when clicking on Rebuild project :

<Target Name="AfterBuild">
  <RunPythonCommand Target="setup.py" TargetType="script" Arguments="bdist_wininst" />
</Target>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
kraigbcommented, Feb 12, 2018

@fxthomas Thanks. The article is on https://docs.microsoft.com/en-us/visualstudio/python/defining-custom-python-project-commands now; I’ll be adding your examples shortly.

1reaction
int19hcommented, Jan 24, 2018

The snippet above is missing a quote in Outputs, and should result in the project not being loadable due to being invalid XML. If it’s a copy/pasted snippet, then perhaps you were accidentally editing the wrong file?

If that’s not the case, try setting MSBuild verbosity to diagnostic (Tools -> Options -> Projects and Solutions -> Build and Run) - build output should then be detailed enough to see when it was considering your target, and why exactly it wasn’t run.

@(Compile) should be fine - it basically makes it depend on all project items that are defined as <Compile Include="...">, which should include all .py files by default.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Porting from Distutils - Setuptools - Python Packaging Authority
Setuptools and the PyPA have a stated goal to make Setuptools the reference API for distutils. Since the 60.0.0 release, Setuptools includes a...
Read more >
6. Distutils Examples — Python 3.11.4 documentation
This chapter provides a number of basic examples to help get started with distutils. Additional information about using distutils can be found in...
Read more >
2. Writing the Setup Script — Python 3.11.4 documentation
The setup script is the centre of all activity in building, distributing, and installing modules using the Distutils. The main purpose of the...
Read more >
distutils/setuptools integration - python-for-android
This is functionality to run setup.py INSIDE `p4a apk`, as opposed to the other section below, which is about running p4a inside setup.py....
Read more >
setuptools vs. distutils: why is distutils still a thing?
Secondly, setuptools provides enhancements to distutils. It is therefore modeled after the distutils tool set and takes all of it's structure ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found